aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
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/shared
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/shared')
-rw-r--r--client/src/app/shared/video/video-details.model.ts12
-rw-r--r--client/src/app/shared/video/video-edit.model.ts8
-rw-r--r--client/src/app/shared/video/video.model.ts14
-rw-r--r--client/src/app/shared/video/video.service.ts39
4 files changed, 47 insertions, 26 deletions
diff --git a/client/src/app/shared/video/video-details.model.ts b/client/src/app/shared/video/video-details.model.ts
index 19c350ab3..e500ad6fc 100644
--- a/client/src/app/shared/video/video-details.model.ts
+++ b/client/src/app/shared/video/video-details.model.ts
@@ -1,4 +1,11 @@
1import { UserRight, VideoChannel, VideoDetails as VideoDetailsServerModel, VideoFile } from '../../../../../shared' 1import {
2 UserRight,
3 VideoChannel,
4 VideoConstant,
5 VideoDetails as VideoDetailsServerModel,
6 VideoFile,
7 VideoState
8} from '../../../../../shared'
2import { AuthUser } from '../../core' 9import { AuthUser } from '../../core'
3import { Video } from '../../shared/video/video.model' 10import { Video } from '../../shared/video/video.model'
4import { Account } from '@app/shared/account/account.model' 11import { Account } from '@app/shared/account/account.model'
@@ -12,6 +19,9 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
12 account: Account 19 account: Account
13 commentsEnabled: boolean 20 commentsEnabled: boolean
14 21
22 waitTranscoding: boolean
23 state: VideoConstant<VideoState>
24
15 likesPercent: number 25 likesPercent: number
16 dislikesPercent: number 26 dislikesPercent: number
17 27
diff --git a/client/src/app/shared/video/video-edit.model.ts b/client/src/app/shared/video/video-edit.model.ts
index ad2929db5..f045a3acd 100644
--- a/client/src/app/shared/video/video-edit.model.ts
+++ b/client/src/app/shared/video/video-edit.model.ts
@@ -1,7 +1,8 @@
1import { VideoDetails } from './video-details.model' 1import { VideoDetails } from './video-details.model'
2import { VideoPrivacy } from '../../../../../shared/models/videos/video-privacy.enum' 2import { VideoPrivacy } from '../../../../../shared/models/videos/video-privacy.enum'
3import { VideoUpdate } from '../../../../../shared/models/videos'
3 4
4export class VideoEdit { 5export class VideoEdit implements VideoUpdate {
5 category: number 6 category: number
6 licence: number 7 licence: number
7 language: string 8 language: string
@@ -10,6 +11,7 @@ export class VideoEdit {
10 tags: string[] 11 tags: string[]
11 nsfw: boolean 12 nsfw: boolean
12 commentsEnabled: boolean 13 commentsEnabled: boolean
14 waitTranscoding: boolean
13 channelId: number 15 channelId: number
14 privacy: VideoPrivacy 16 privacy: VideoPrivacy
15 support: string 17 support: string
@@ -32,6 +34,7 @@ export class VideoEdit {
32 this.tags = videoDetails.tags 34 this.tags = videoDetails.tags
33 this.nsfw = videoDetails.nsfw 35 this.nsfw = videoDetails.nsfw
34 this.commentsEnabled = videoDetails.commentsEnabled 36 this.commentsEnabled = videoDetails.commentsEnabled
37 this.waitTranscoding = videoDetails.waitTranscoding
35 this.channelId = videoDetails.channel.id 38 this.channelId = videoDetails.channel.id
36 this.privacy = videoDetails.privacy.id 39 this.privacy = videoDetails.privacy.id
37 this.support = videoDetails.support 40 this.support = videoDetails.support
@@ -42,7 +45,7 @@ export class VideoEdit {
42 45
43 patch (values: Object) { 46 patch (values: Object) {
44 Object.keys(values).forEach((key) => { 47 Object.keys(values).forEach((key) => {
45 this[key] = values[key] 48 this[ key ] = values[ key ]
46 }) 49 })
47 } 50 }
48 51
@@ -57,6 +60,7 @@ export class VideoEdit {
57 tags: this.tags, 60 tags: this.tags,
58 nsfw: this.nsfw, 61 nsfw: this.nsfw,
59 commentsEnabled: this.commentsEnabled, 62 commentsEnabled: this.commentsEnabled,
63 waitTranscoding: this.waitTranscoding,
60 channelId: this.channelId, 64 channelId: this.channelId,
61 privacy: this.privacy 65 privacy: this.privacy
62 } 66 }
diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts
index d37dc2c3e..48a4b4260 100644
--- a/client/src/app/shared/video/video.model.ts
+++ b/client/src/app/shared/video/video.model.ts
@@ -1,5 +1,5 @@
1import { User } from '../' 1import { User } from '../'
2import { Video as VideoServerModel, VideoPrivacy } from '../../../../../shared' 2import { Video as VideoServerModel, VideoPrivacy, VideoState } from '../../../../../shared'
3import { Avatar } from '../../../../../shared/models/avatars/avatar.model' 3import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
4import { VideoConstant } from '../../../../../shared/models/videos/video.model' 4import { VideoConstant } from '../../../../../shared/models/videos/video.model'
5import { getAbsoluteAPIUrl } from '../misc/utils' 5import { getAbsoluteAPIUrl } from '../misc/utils'
@@ -36,6 +36,9 @@ export class Video implements VideoServerModel {
36 dislikes: number 36 dislikes: number
37 nsfw: boolean 37 nsfw: boolean
38 38
39 waitTranscoding?: boolean
40 state?: VideoConstant<VideoState>
41
39 account: { 42 account: {
40 id: number 43 id: number
41 uuid: string 44 uuid: string
@@ -58,15 +61,14 @@ export class Video implements VideoServerModel {
58 61
59 private static createDurationString (duration: number) { 62 private static createDurationString (duration: number) {
60 const hours = Math.floor(duration / 3600) 63 const hours = Math.floor(duration / 3600)
61 const minutes = Math.floor(duration % 3600 / 60) 64 const minutes = Math.floor((duration % 3600) / 60)
62 const seconds = duration % 60 65 const seconds = duration % 60
63 66
64 const minutesPadding = minutes >= 10 ? '' : '0' 67 const minutesPadding = minutes >= 10 ? '' : '0'
65 const secondsPadding = seconds >= 10 ? '' : '0' 68 const secondsPadding = seconds >= 10 ? '' : '0'
66 const displayedHours = hours > 0 ? hours.toString() + ':' : '' 69 const displayedHours = hours > 0 ? hours.toString() + ':' : ''
67 70
68 return displayedHours + minutesPadding + 71 return displayedHours + minutesPadding + minutes.toString() + ':' + secondsPadding + seconds.toString()
69 minutes.toString() + ':' + secondsPadding + seconds.toString()
70 } 72 }
71 73
72 constructor (hash: VideoServerModel, translations = {}) { 74 constructor (hash: VideoServerModel, translations = {}) {
@@ -78,6 +80,8 @@ export class Video implements VideoServerModel {
78 this.licence = hash.licence 80 this.licence = hash.licence
79 this.language = hash.language 81 this.language = hash.language
80 this.privacy = hash.privacy 82 this.privacy = hash.privacy
83 this.waitTranscoding = hash.waitTranscoding
84 this.state = hash.state
81 this.description = hash.description 85 this.description = hash.description
82 this.duration = hash.duration 86 this.duration = hash.duration
83 this.durationLabel = Video.createDurationString(hash.duration) 87 this.durationLabel = Video.createDurationString(hash.duration)
@@ -104,6 +108,8 @@ export class Video implements VideoServerModel {
104 this.licence.label = peertubeTranslate(this.licence.label, translations) 108 this.licence.label = peertubeTranslate(this.licence.label, translations)
105 this.language.label = peertubeTranslate(this.language.label, translations) 109 this.language.label = peertubeTranslate(this.language.label, translations)
106 this.privacy.label = peertubeTranslate(this.privacy.label, translations) 110 this.privacy.label = peertubeTranslate(this.privacy.label, translations)
111
112 if (this.state) this.state.label = peertubeTranslate(this.state.label, translations)
107 } 113 }
108 114
109 isVideoNSFWForUser (user: User, serverConfig: ServerConfig) { 115 isVideoNSFWForUser (user: User, serverConfig: ServerConfig) {
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts
index 58cb52efc..d63915ad2 100644
--- a/client/src/app/shared/video/video.service.ts
+++ b/client/src/app/shared/video/video.service.ts
@@ -80,6 +80,7 @@ export class VideoService {
80 privacy: video.privacy, 80 privacy: video.privacy,
81 tags: video.tags, 81 tags: video.tags,
82 nsfw: video.nsfw, 82 nsfw: video.nsfw,
83 waitTranscoding: video.waitTranscoding,
83 commentsEnabled: video.commentsEnabled, 84 commentsEnabled: video.commentsEnabled,
84 thumbnailfile: video.thumbnailfile, 85 thumbnailfile: video.thumbnailfile,
85 previewfile: video.previewfile 86 previewfile: video.previewfile
@@ -98,11 +99,11 @@ export class VideoService {
98 const req = new HttpRequest('POST', VideoService.BASE_VIDEO_URL + 'upload', video, { reportProgress: true }) 99 const req = new HttpRequest('POST', VideoService.BASE_VIDEO_URL + 'upload', video, { reportProgress: true })
99 100
100 return this.authHttp 101 return this.authHttp
101 .request<{ video: { id: number, uuid: string} }>(req) 102 .request<{ video: { id: number, uuid: string } }>(req)
102 .pipe(catchError(this.restExtractor.handleError)) 103 .pipe(catchError(this.restExtractor.handleError))
103 } 104 }
104 105
105 getMyVideos (videoPagination: ComponentPagination, sort: VideoSortField): Observable<{ videos: Video[], totalVideos: number}> { 106 getMyVideos (videoPagination: ComponentPagination, sort: VideoSortField): Observable<{ videos: Video[], totalVideos: number }> {
106 const pagination = this.restService.componentPaginationToRestPagination(videoPagination) 107 const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
107 108
108 let params = new HttpParams() 109 let params = new HttpParams()
@@ -120,7 +121,7 @@ export class VideoService {
120 account: Account, 121 account: Account,
121 videoPagination: ComponentPagination, 122 videoPagination: ComponentPagination,
122 sort: VideoSortField 123 sort: VideoSortField
123 ): Observable<{ videos: Video[], totalVideos: number}> { 124 ): Observable<{ videos: Video[], totalVideos: number }> {
124 const pagination = this.restService.componentPaginationToRestPagination(videoPagination) 125 const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
125 126
126 let params = new HttpParams() 127 let params = new HttpParams()
@@ -138,7 +139,7 @@ export class VideoService {
138 videoChannel: VideoChannel, 139 videoChannel: VideoChannel,
139 videoPagination: ComponentPagination, 140 videoPagination: ComponentPagination,
140 sort: VideoSortField 141 sort: VideoSortField
141 ): Observable<{ videos: Video[], totalVideos: number}> { 142 ): Observable<{ videos: Video[], totalVideos: number }> {
142 const pagination = this.restService.componentPaginationToRestPagination(videoPagination) 143 const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
143 144
144 let params = new HttpParams() 145 let params = new HttpParams()
@@ -156,7 +157,7 @@ export class VideoService {
156 videoPagination: ComponentPagination, 157 videoPagination: ComponentPagination,
157 sort: VideoSortField, 158 sort: VideoSortField,
158 filter?: VideoFilter 159 filter?: VideoFilter
159 ): Observable<{ videos: Video[], totalVideos: number}> { 160 ): Observable<{ videos: Video[], totalVideos: number }> {
160 const pagination = this.restService.componentPaginationToRestPagination(videoPagination) 161 const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
161 162
162 let params = new HttpParams() 163 let params = new HttpParams()
@@ -225,7 +226,7 @@ export class VideoService {
225 search: string, 226 search: string,
226 videoPagination: ComponentPagination, 227 videoPagination: ComponentPagination,
227 sort: VideoSortField 228 sort: VideoSortField
228 ): Observable<{ videos: Video[], totalVideos: number}> { 229 ): Observable<{ videos: Video[], totalVideos: number }> {
229 const url = VideoService.BASE_VIDEO_URL + 'search' 230 const url = VideoService.BASE_VIDEO_URL + 'search'
230 231
231 const pagination = this.restService.componentPaginationToRestPagination(videoPagination) 232 const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
@@ -295,18 +296,18 @@ export class VideoService {
295 296
296 private extractVideos (result: ResultList<VideoServerModel>) { 297 private extractVideos (result: ResultList<VideoServerModel>) {
297 return this.serverService.localeObservable 298 return this.serverService.localeObservable
298 .pipe( 299 .pipe(
299 map(translations => { 300 map(translations => {
300 const videosJson = result.data 301 const videosJson = result.data
301 const totalVideos = result.total 302 const totalVideos = result.total
302 const videos: Video[] = [] 303 const videos: Video[] = []
303 304
304 for (const videoJson of videosJson) { 305 for (const videoJson of videosJson) {
305 videos.push(new Video(videoJson, translations)) 306 videos.push(new Video(videoJson, translations))
306 } 307 }
307 308
308 return { videos, totalVideos } 309 return { videos, totalVideos }
309 }) 310 })
310 ) 311 )
311 } 312 }
312} 313}