Add concept of video state, and add ability to wait transcoding before
[oweals/peertube.git] / client / src / app / shared / video / video-edit.model.ts
1 import { VideoDetails } from './video-details.model'
2 import { VideoPrivacy } from '../../../../../shared/models/videos/video-privacy.enum'
3 import { VideoUpdate } from '../../../../../shared/models/videos'
4
5 export class VideoEdit implements VideoUpdate {
6   category: number
7   licence: number
8   language: string
9   description: string
10   name: string
11   tags: string[]
12   nsfw: boolean
13   commentsEnabled: boolean
14   waitTranscoding: boolean
15   channelId: number
16   privacy: VideoPrivacy
17   support: string
18   thumbnailfile?: any
19   previewfile?: any
20   thumbnailUrl: string
21   previewUrl: string
22   uuid?: string
23   id?: number
24
25   constructor (videoDetails?: VideoDetails) {
26     if (videoDetails) {
27       this.id = videoDetails.id
28       this.uuid = videoDetails.uuid
29       this.category = videoDetails.category.id
30       this.licence = videoDetails.licence.id
31       this.language = videoDetails.language.id
32       this.description = videoDetails.description
33       this.name = videoDetails.name
34       this.tags = videoDetails.tags
35       this.nsfw = videoDetails.nsfw
36       this.commentsEnabled = videoDetails.commentsEnabled
37       this.waitTranscoding = videoDetails.waitTranscoding
38       this.channelId = videoDetails.channel.id
39       this.privacy = videoDetails.privacy.id
40       this.support = videoDetails.support
41       this.thumbnailUrl = videoDetails.thumbnailUrl
42       this.previewUrl = videoDetails.previewUrl
43     }
44   }
45
46   patch (values: Object) {
47     Object.keys(values).forEach((key) => {
48       this[ key ] = values[ key ]
49     })
50   }
51
52   toJSON () {
53     return {
54       category: this.category,
55       licence: this.licence,
56       language: this.language,
57       description: this.description,
58       support: this.support,
59       name: this.name,
60       tags: this.tags,
61       nsfw: this.nsfw,
62       commentsEnabled: this.commentsEnabled,
63       waitTranscoding: this.waitTranscoding,
64       channelId: this.channelId,
65       privacy: this.privacy
66     }
67   }
68 }