47c63d976e295195fc8cd1f85afa26992fa4511b
[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
4 export class VideoEdit {
5   category: number
6   licence: number
7   language: number
8   description: string
9   name: string
10   tags: string[]
11   nsfw: boolean
12   channel: number
13   privacy: VideoPrivacy
14   uuid?: string
15   id?: number
16
17   constructor (videoDetails?: VideoDetails) {
18     if (videoDetails) {
19       this.id = videoDetails.id
20       this.uuid = videoDetails.uuid
21       this.category = videoDetails.category
22       this.licence = videoDetails.licence
23       this.language = videoDetails.language
24       this.description = videoDetails.description
25       this.name = videoDetails.name
26       this.tags = videoDetails.tags
27       this.nsfw = videoDetails.nsfw
28       this.channel = videoDetails.channel.id
29       this.privacy = videoDetails.privacy
30     }
31   }
32
33   patch (values: Object) {
34     Object.keys(values).forEach((key) => {
35       this[key] = values[key]
36     })
37   }
38
39   toJSON () {
40     return {
41       category: this.category,
42       licence: this.licence,
43       language: this.language,
44       description: this.description,
45       name: this.name,
46       tags: this.tags,
47       nsfw: this.nsfw,
48       channelId: this.channel,
49       privacy: this.privacy
50     }
51   }
52 }