aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-12 20:04:58 +0200
committerChocobozzz <me@florianbigard.com>2018-06-12 20:37:51 +0200
commit2186386cca113506791583cb07d6ccacba7af4e0 (patch)
tree3c214c0b5fbd64332624267fa6e51fd4a9cf6474 /client/src/app/+my-account/my-account-videos
parent6ccdf3a23ecec5ba2eeaf487fd1fafdc7606b4bf (diff)
downloadPeerTube-2186386cca113506791583cb07d6ccacba7af4e0.tar.gz
PeerTube-2186386cca113506791583cb07d6ccacba7af4e0.tar.zst
PeerTube-2186386cca113506791583cb07d6ccacba7af4e0.zip
Add concept of video state, and add ability to wait transcoding before
publishing a video
Diffstat (limited to 'client/src/app/+my-account/my-account-videos')
-rw-r--r--client/src/app/+my-account/my-account-videos/my-account-videos.component.html2
-rw-r--r--client/src/app/+my-account/my-account-videos/my-account-videos.component.ts60
2 files changed, 42 insertions, 20 deletions
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 @@
18 <div class="video-info"> 18 <div class="video-info">
19 <a class="video-info-name" [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name">{{ video.name }}</a> 19 <a class="video-info-name" [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name">{{ video.name }}</a>
20 <span i18n class="video-info-date-views">{{ video.createdAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span> 20 <span i18n class="video-info-date-views">{{ video.createdAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span>
21 <div class="video-info-private">{{ video.privacy.label }}</div> 21 <div class="video-info-private">{{ video.privacy.label }} - {{ getStateLabel(video) }}</div>
22 </div> 22 </div>
23 23
24 <!-- Display only once --> 24 <!-- Display only once -->
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'
12import { Video } from '../../shared/video/video.model' 12import { Video } from '../../shared/video/video.model'
13import { VideoService } from '../../shared/video/video.service' 13import { VideoService } from '../../shared/video/video.service'
14import { I18n } from '@ngx-translate/i18n-polyfill' 14import { I18n } from '@ngx-translate/i18n-polyfill'
15import { VideoState } from '../../../../../shared/models/videos'
15 16
16@Component({ 17@Component({
17 selector: 'my-account-videos', 18 selector: 'my-account-videos',
@@ -59,7 +60,7 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni
59 } 60 }
60 61
61 isInSelectionMode () { 62 isInSelectionMode () {
62 return Object.keys(this.checkedVideos).some(k => this.checkedVideos[k] === true) 63 return Object.keys(this.checkedVideos).some(k => this.checkedVideos[ k ] === true)
63 } 64 }
64 65
65 getVideosObservable (page: number) { 66 getVideosObservable (page: number) {
@@ -74,47 +75,68 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni
74 75
75 async deleteSelectedVideos () { 76 async deleteSelectedVideos () {
76 const toDeleteVideosIds = Object.keys(this.checkedVideos) 77 const toDeleteVideosIds = Object.keys(this.checkedVideos)
77 .filter(k => this.checkedVideos[k] === true) 78 .filter(k => this.checkedVideos[ k ] === true)
78 .map(k => parseInt(k, 10)) 79 .map(k => parseInt(k, 10))
79 80
80 const res = await this.confirmService.confirm(`Do you really want to delete ${toDeleteVideosIds.length} videos?`, 'Delete') 81 const res = await this.confirmService.confirm(
82 this.i18n('Do you really want to delete {{deleteLength}} videos?', { deleteLength: toDeleteVideosIds.length }),
83 this.i18n('Delete')
84 )
81 if (res === false) return 85 if (res === false) return
82 86
83 const observables: Observable<any>[] = [] 87 const observables: Observable<any>[] = []
84 for (const videoId of toDeleteVideosIds) { 88 for (const videoId of toDeleteVideosIds) {
85 const o = this.videoService 89 const o = this.videoService.removeVideo(videoId)
86 .removeVideo(videoId)
87 .pipe(tap(() => this.spliceVideosById(videoId))) 90 .pipe(tap(() => this.spliceVideosById(videoId)))
88 91
89 observables.push(o) 92 observables.push(o)
90 } 93 }
91 94
92 observableFrom(observables).pipe( 95 observableFrom(observables)
93 concatAll()) 96 .pipe(concatAll())
94 .subscribe( 97 .subscribe(
95 res => { 98 res => {
96 this.notificationsService.success('Success', `${toDeleteVideosIds.length} videos deleted.`) 99 this.notificationsService.success(
100 this.i18n('Success'),
101 this.i18n('{{deleteLength}} videos deleted.', { deleteLength: toDeleteVideosIds.length })
102 )
103
97 this.abortSelectionMode() 104 this.abortSelectionMode()
98 this.reloadVideos() 105 this.reloadVideos()
99 }, 106 },
100 107
101 err => this.notificationsService.error('Error', err.message) 108 err => this.notificationsService.error(this.i18n('Error'), err.message)
102 ) 109 )
103 } 110 }
104 111
105 async deleteVideo (video: Video) { 112 async deleteVideo (video: Video) {
106 const res = await this.confirmService.confirm(`Do you really want to delete ${video.name}?`, 'Delete') 113 const res = await this.confirmService.confirm(
114 this.i18n('Do you really want to delete {{videoName}}?', { videoName: video.name }),
115 this.i18n('Delete')
116 )
107 if (res === false) return 117 if (res === false) return
108 118
109 this.videoService.removeVideo(video.id) 119 this.videoService.removeVideo(video.id)
110 .subscribe( 120 .subscribe(
111 status => { 121 status => {
112 this.notificationsService.success('Success', `Video ${video.name} deleted.`) 122 this.notificationsService.success(
113 this.reloadVideos() 123 this.i18n('Success'),
114 }, 124 this.i18n('Video {{videoName}} deleted.', { videoName: video.name })
125 )
126 this.reloadVideos()
127 },
128
129 error => this.notificationsService.error(this.i18n('Error'), error.message)
130 )
131 }
115 132
116 error => this.notificationsService.error('Error', error.message) 133 getStateLabel (video: Video) {
117 ) 134 if (video.state.id === VideoState.PUBLISHED) return this.i18n('Published')
135
136 if (video.state.id === VideoState.TO_TRANSCODE && video.waitTranscoding === true) return this.i18n('Waiting transcoding')
137 if (video.state.id === VideoState.TO_TRANSCODE) return this.i18n('To transcode')
138
139 return this.i18n('Unknown state')
118 } 140 }
119 141
120 protected buildVideoHeight () { 142 protected buildVideoHeight () {
@@ -124,7 +146,7 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni
124 146
125 private spliceVideosById (id: number) { 147 private spliceVideosById (id: number) {
126 for (const key of Object.keys(this.loadedPages)) { 148 for (const key of Object.keys(this.loadedPages)) {
127 const videos = this.loadedPages[key] 149 const videos = this.loadedPages[ key ]
128 const index = videos.findIndex(v => v.id === id) 150 const index = videos.findIndex(v => v.id === id)
129 151
130 if (index !== -1) { 152 if (index !== -1) {