Add session informations in live modal

pull/4977/head
Chocobozzz 2022-05-03 15:11:29 +02:00
parent 26e3e98ff0
commit 39e68a3254
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 54 additions and 4 deletions

View File

@ -154,7 +154,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView
getNormalLiveDescription () {
if (this.isReplayAllowed()) {
return $localize`Stream only once and save a replay of your live`
return $localize`Stream only once, replay will replace your live`
}
return $localize`Stream only once`
@ -162,7 +162,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView
getPermanentLiveDescription () {
if (this.isReplayAllowed()) {
return $localize`Stream multiple times, replays can't be saved`
return $localize`Stream multiple times, replays will be separate videos`
}
return $localize`Stream multiple times using the same URL`

View File

@ -31,6 +31,19 @@
<div class="form-group-description" i18n>⚠️ Never share your stream key with anyone.</div>
</div>
<div class="journal">
<label i18n>Latest live sessions</label>
<div class="journal-session" *ngFor="let session of latestLiveSessions">
<span i18n class="badge badge-success" *ngIf="!getErrorLabel(session)">Success</span>
<span class="badge badge-danger" *ngIf="getErrorLabel(session)">{{ getErrorLabel(session) }}</span>
<span i18n>Started on {{ session.startDate | date:'medium' }}</span>
<span i18n *ngIf="session.endDate">Ended on {{ session.endDate | date:'medium' }}</span>
<a i18n *ngIf="session.replayVideo" [routerLink]="getVideoUrl(session.replayVideo)" target="_blank">Go to replay</a>
</div>
</div>
</div>
<div class="modal-footer">

View File

@ -17,3 +17,12 @@ p-autocomplete {
font-size: 13px;
margin-right: 5px;
}
.journal-session {
margin-bottom: 5px;
span:not(.badge, :last-child)::after {
margin: 3px;
content: '';
}
}

View File

@ -1,7 +1,7 @@
import { Component, ElementRef, ViewChild } from '@angular/core'
import { Video } from '@app/shared/shared-main'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { LiveVideo } from '@shared/models'
import { LiveVideo, LiveVideoError, LiveVideoSession } from '@shared/models'
import { LiveVideoService } from './live-video.service'
@Component({
@ -14,6 +14,7 @@ export class LiveStreamInformationComponent {
video: Video
live: LiveVideo
latestLiveSessions: LiveVideoSession[] = []
constructor (
private modalService: NgbModal,
@ -30,8 +31,29 @@ export class LiveStreamInformationComponent {
.open(this.modal, { centered: true })
}
getVideoUrl (video: { shortUUID: string }) {
return Video.buildWatchUrl(video)
}
getErrorLabel (session: LiveVideoSession) {
if (!session.error) return undefined
const errors: { [ id in LiveVideoError ]: string } = {
[LiveVideoError.BAD_SOCKET_HEALTH]: $localize`Server too slow`,
[LiveVideoError.BLACKLISTED]: $localize`Live blacklisted`,
[LiveVideoError.DURATION_EXCEEDED]: $localize`Max duration exceeded`,
[LiveVideoError.FFMPEG_ERROR]: $localize`Server error`,
[LiveVideoError.QUOTA_EXCEEDED]: $localize`Quota exceeded`
}
return errors[session.error]
}
private loadLiveInfo (video: Video) {
this.liveVideoService.getVideoLive(video.id)
.subscribe(live => this.live = live)
this.liveVideoService.listSessions(video.id)
.subscribe(({ data }) => this.latestLiveSessions = data.slice(0, 5))
}
}

View File

@ -2,7 +2,7 @@ import { catchError } from 'rxjs/operators'
import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { RestExtractor } from '@app/core'
import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult } from '@shared/models'
import { LiveVideo, LiveVideoCreate, LiveVideoSession, LiveVideoUpdate, ResultList, VideoCreateResult } from '@shared/models'
import { environment } from '../../../environments/environment'
@Injectable()
@ -26,6 +26,12 @@ export class LiveVideoService {
.pipe(catchError(err => this.restExtractor.handleError(err)))
}
listSessions (videoId: number | string) {
return this.authHttp
.get<ResultList<LiveVideoSession>>(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId + '/sessions')
.pipe(catchError(err => this.restExtractor.handleError(err)))
}
updateLive (videoId: number | string, liveUpdate: LiveVideoUpdate) {
return this.authHttp
.put(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId, liveUpdate)