From 2186386cca113506791583cb07d6ccacba7af4e0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 12 Jun 2018 20:04:58 +0200 Subject: Add concept of video state, and add ability to wait transcoding before publishing a video --- .../my-account-videos.component.html | 2 +- .../my-account-videos.component.ts | 60 +++++++++++++++------- 2 files changed, 42 insertions(+), 20 deletions(-) (limited to 'client/src/app/+my-account') diff --git a/client/src/app/+my-account/my-account-videos/my-account-videos.component.html b/client/src/app/+my-account/my-account-videos/my-account-videos.component.html index 35a99d0b3..eb24de7a7 100644 --- a/client/src/app/+my-account/my-account-videos/my-account-videos.component.html +++ b/client/src/app/+my-account/my-account-videos/my-account-videos.component.html @@ -18,7 +18,7 @@
{{ video.name }} {{ video.createdAt | myFromNow }} - {{ video.views | myNumberFormatter }} views -
{{ video.privacy.label }}
+
{{ video.privacy.label }} - {{ getStateLabel(video) }}
diff --git a/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts b/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts index eed4be01f..afc01073c 100644 --- a/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts +++ b/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts @@ -12,6 +12,7 @@ import { AbstractVideoList } from '../../shared/video/abstract-video-list' import { Video } from '../../shared/video/video.model' import { VideoService } from '../../shared/video/video.service' import { I18n } from '@ngx-translate/i18n-polyfill' +import { VideoState } from '../../../../../shared/models/videos' @Component({ selector: 'my-account-videos', @@ -59,7 +60,7 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni } isInSelectionMode () { - return Object.keys(this.checkedVideos).some(k => this.checkedVideos[k] === true) + return Object.keys(this.checkedVideos).some(k => this.checkedVideos[ k ] === true) } getVideosObservable (page: number) { @@ -74,47 +75,68 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni async deleteSelectedVideos () { const toDeleteVideosIds = Object.keys(this.checkedVideos) - .filter(k => this.checkedVideos[k] === true) - .map(k => parseInt(k, 10)) + .filter(k => this.checkedVideos[ k ] === true) + .map(k => parseInt(k, 10)) - const res = await this.confirmService.confirm(`Do you really want to delete ${toDeleteVideosIds.length} videos?`, 'Delete') + const res = await this.confirmService.confirm( + this.i18n('Do you really want to delete {{deleteLength}} videos?', { deleteLength: toDeleteVideosIds.length }), + this.i18n('Delete') + ) if (res === false) return const observables: Observable[] = [] for (const videoId of toDeleteVideosIds) { - const o = this.videoService - .removeVideo(videoId) + const o = this.videoService.removeVideo(videoId) .pipe(tap(() => this.spliceVideosById(videoId))) observables.push(o) } - observableFrom(observables).pipe( - concatAll()) + observableFrom(observables) + .pipe(concatAll()) .subscribe( res => { - this.notificationsService.success('Success', `${toDeleteVideosIds.length} videos deleted.`) + this.notificationsService.success( + this.i18n('Success'), + this.i18n('{{deleteLength}} videos deleted.', { deleteLength: toDeleteVideosIds.length }) + ) + this.abortSelectionMode() this.reloadVideos() }, - err => this.notificationsService.error('Error', err.message) + err => this.notificationsService.error(this.i18n('Error'), err.message) ) } async deleteVideo (video: Video) { - const res = await this.confirmService.confirm(`Do you really want to delete ${video.name}?`, 'Delete') + const res = await this.confirmService.confirm( + this.i18n('Do you really want to delete {{videoName}}?', { videoName: video.name }), + this.i18n('Delete') + ) if (res === false) return this.videoService.removeVideo(video.id) - .subscribe( - status => { - this.notificationsService.success('Success', `Video ${video.name} deleted.`) - this.reloadVideos() - }, + .subscribe( + status => { + this.notificationsService.success( + this.i18n('Success'), + this.i18n('Video {{videoName}} deleted.', { videoName: video.name }) + ) + this.reloadVideos() + }, + + error => this.notificationsService.error(this.i18n('Error'), error.message) + ) + } - error => this.notificationsService.error('Error', error.message) - ) + getStateLabel (video: Video) { + if (video.state.id === VideoState.PUBLISHED) return this.i18n('Published') + + if (video.state.id === VideoState.TO_TRANSCODE && video.waitTranscoding === true) return this.i18n('Waiting transcoding') + if (video.state.id === VideoState.TO_TRANSCODE) return this.i18n('To transcode') + + return this.i18n('Unknown state') } protected buildVideoHeight () { @@ -124,7 +146,7 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni private spliceVideosById (id: number) { for (const key of Object.keys(this.loadedPages)) { - const videos = this.loadedPages[key] + const videos = this.loadedPages[ key ] const index = videos.findIndex(v => v.id === id) if (index !== -1) { -- cgit v1.2.3