diff options
author | Chocobozzz <me@florianbigard.com> | 2022-05-03 15:11:29 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-05-03 15:21:42 +0200 |
commit | 39e68a3254242bd410ffc20b7f74b442a07b390f (patch) | |
tree | 3ad74189343796d52c8fd5c1825ac648dff15ea1 /client | |
parent | 26e3e98ff0e222a9fb9226938ac6902af77921bd (diff) | |
download | PeerTube-39e68a3254242bd410ffc20b7f74b442a07b390f.tar.gz PeerTube-39e68a3254242bd410ffc20b7f74b442a07b390f.tar.zst PeerTube-39e68a3254242bd410ffc20b7f74b442a07b390f.zip |
Add session informations in live modal
Diffstat (limited to 'client')
5 files changed, 54 insertions, 4 deletions
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts index 725120d16..d81f577b2 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts | |||
@@ -154,7 +154,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView | |||
154 | 154 | ||
155 | getNormalLiveDescription () { | 155 | getNormalLiveDescription () { |
156 | if (this.isReplayAllowed()) { | 156 | if (this.isReplayAllowed()) { |
157 | return $localize`Stream only once and save a replay of your live` | 157 | return $localize`Stream only once, replay will replace your live` |
158 | } | 158 | } |
159 | 159 | ||
160 | return $localize`Stream only once` | 160 | return $localize`Stream only once` |
@@ -162,7 +162,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView | |||
162 | 162 | ||
163 | getPermanentLiveDescription () { | 163 | getPermanentLiveDescription () { |
164 | if (this.isReplayAllowed()) { | 164 | if (this.isReplayAllowed()) { |
165 | return $localize`Stream multiple times, replays can't be saved` | 165 | return $localize`Stream multiple times, replays will be separate videos` |
166 | } | 166 | } |
167 | 167 | ||
168 | return $localize`Stream multiple times using the same URL` | 168 | return $localize`Stream multiple times using the same URL` |
diff --git a/client/src/app/shared/shared-video-live/live-stream-information.component.html b/client/src/app/shared/shared-video-live/live-stream-information.component.html index 35e894a55..01e305938 100644 --- a/client/src/app/shared/shared-video-live/live-stream-information.component.html +++ b/client/src/app/shared/shared-video-live/live-stream-information.component.html | |||
@@ -31,6 +31,19 @@ | |||
31 | 31 | ||
32 | <div class="form-group-description" i18n>⚠️ Never share your stream key with anyone.</div> | 32 | <div class="form-group-description" i18n>⚠️ Never share your stream key with anyone.</div> |
33 | </div> | 33 | </div> |
34 | |||
35 | <div class="journal"> | ||
36 | <label i18n>Latest live sessions</label> | ||
37 | |||
38 | <div class="journal-session" *ngFor="let session of latestLiveSessions"> | ||
39 | <span i18n class="badge badge-success" *ngIf="!getErrorLabel(session)">Success</span> | ||
40 | <span class="badge badge-danger" *ngIf="getErrorLabel(session)">{{ getErrorLabel(session) }}</span> | ||
41 | |||
42 | <span i18n>Started on {{ session.startDate | date:'medium' }}</span> | ||
43 | <span i18n *ngIf="session.endDate">Ended on {{ session.endDate | date:'medium' }}</span> | ||
44 | <a i18n *ngIf="session.replayVideo" [routerLink]="getVideoUrl(session.replayVideo)" target="_blank">Go to replay</a> | ||
45 | </div> | ||
46 | </div> | ||
34 | </div> | 47 | </div> |
35 | 48 | ||
36 | <div class="modal-footer"> | 49 | <div class="modal-footer"> |
diff --git a/client/src/app/shared/shared-video-live/live-stream-information.component.scss b/client/src/app/shared/shared-video-live/live-stream-information.component.scss index 7cd53478f..9c8ad12bd 100644 --- a/client/src/app/shared/shared-video-live/live-stream-information.component.scss +++ b/client/src/app/shared/shared-video-live/live-stream-information.component.scss | |||
@@ -17,3 +17,12 @@ p-autocomplete { | |||
17 | font-size: 13px; | 17 | font-size: 13px; |
18 | margin-right: 5px; | 18 | margin-right: 5px; |
19 | } | 19 | } |
20 | |||
21 | .journal-session { | ||
22 | margin-bottom: 5px; | ||
23 | |||
24 | span:not(.badge, :last-child)::after { | ||
25 | margin: 3px; | ||
26 | content: '•'; | ||
27 | } | ||
28 | } | ||
diff --git a/client/src/app/shared/shared-video-live/live-stream-information.component.ts b/client/src/app/shared/shared-video-live/live-stream-information.component.ts index 9a5d2809b..1cf6f8528 100644 --- a/client/src/app/shared/shared-video-live/live-stream-information.component.ts +++ b/client/src/app/shared/shared-video-live/live-stream-information.component.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Component, ElementRef, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, ViewChild } from '@angular/core' |
2 | import { Video } from '@app/shared/shared-main' | 2 | import { Video } from '@app/shared/shared-main' |
3 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 3 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
4 | import { LiveVideo } from '@shared/models' | 4 | import { LiveVideo, LiveVideoError, LiveVideoSession } from '@shared/models' |
5 | import { LiveVideoService } from './live-video.service' | 5 | import { LiveVideoService } from './live-video.service' |
6 | 6 | ||
7 | @Component({ | 7 | @Component({ |
@@ -14,6 +14,7 @@ export class LiveStreamInformationComponent { | |||
14 | 14 | ||
15 | video: Video | 15 | video: Video |
16 | live: LiveVideo | 16 | live: LiveVideo |
17 | latestLiveSessions: LiveVideoSession[] = [] | ||
17 | 18 | ||
18 | constructor ( | 19 | constructor ( |
19 | private modalService: NgbModal, | 20 | private modalService: NgbModal, |
@@ -30,8 +31,29 @@ export class LiveStreamInformationComponent { | |||
30 | .open(this.modal, { centered: true }) | 31 | .open(this.modal, { centered: true }) |
31 | } | 32 | } |
32 | 33 | ||
34 | getVideoUrl (video: { shortUUID: string }) { | ||
35 | return Video.buildWatchUrl(video) | ||
36 | } | ||
37 | |||
38 | getErrorLabel (session: LiveVideoSession) { | ||
39 | if (!session.error) return undefined | ||
40 | |||
41 | const errors: { [ id in LiveVideoError ]: string } = { | ||
42 | [LiveVideoError.BAD_SOCKET_HEALTH]: $localize`Server too slow`, | ||
43 | [LiveVideoError.BLACKLISTED]: $localize`Live blacklisted`, | ||
44 | [LiveVideoError.DURATION_EXCEEDED]: $localize`Max duration exceeded`, | ||
45 | [LiveVideoError.FFMPEG_ERROR]: $localize`Server error`, | ||
46 | [LiveVideoError.QUOTA_EXCEEDED]: $localize`Quota exceeded` | ||
47 | } | ||
48 | |||
49 | return errors[session.error] | ||
50 | } | ||
51 | |||
33 | private loadLiveInfo (video: Video) { | 52 | private loadLiveInfo (video: Video) { |
34 | this.liveVideoService.getVideoLive(video.id) | 53 | this.liveVideoService.getVideoLive(video.id) |
35 | .subscribe(live => this.live = live) | 54 | .subscribe(live => this.live = live) |
55 | |||
56 | this.liveVideoService.listSessions(video.id) | ||
57 | .subscribe(({ data }) => this.latestLiveSessions = data.slice(0, 5)) | ||
36 | } | 58 | } |
37 | } | 59 | } |
diff --git a/client/src/app/shared/shared-video-live/live-video.service.ts b/client/src/app/shared/shared-video-live/live-video.service.ts index 0d166e91d..11b9dd739 100644 --- a/client/src/app/shared/shared-video-live/live-video.service.ts +++ b/client/src/app/shared/shared-video-live/live-video.service.ts | |||
@@ -2,7 +2,7 @@ import { catchError } from 'rxjs/operators' | |||
2 | import { HttpClient } from '@angular/common/http' | 2 | import { HttpClient } from '@angular/common/http' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { RestExtractor } from '@app/core' | 4 | import { RestExtractor } from '@app/core' |
5 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult } from '@shared/models' | 5 | import { LiveVideo, LiveVideoCreate, LiveVideoSession, LiveVideoUpdate, ResultList, VideoCreateResult } from '@shared/models' |
6 | import { environment } from '../../../environments/environment' | 6 | import { environment } from '../../../environments/environment' |
7 | 7 | ||
8 | @Injectable() | 8 | @Injectable() |
@@ -26,6 +26,12 @@ export class LiveVideoService { | |||
26 | .pipe(catchError(err => this.restExtractor.handleError(err))) | 26 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
27 | } | 27 | } |
28 | 28 | ||
29 | listSessions (videoId: number | string) { | ||
30 | return this.authHttp | ||
31 | .get<ResultList<LiveVideoSession>>(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId + '/sessions') | ||
32 | .pipe(catchError(err => this.restExtractor.handleError(err))) | ||
33 | } | ||
34 | |||
29 | updateLive (videoId: number | string, liveUpdate: LiveVideoUpdate) { | 35 | updateLive (videoId: number | string, liveUpdate: LiveVideoUpdate) { |
30 | return this.authHttp | 36 | return this.authHttp |
31 | .put(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId, liveUpdate) | 37 | .put(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId, liveUpdate) |