]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/video/video-details.model.ts
Rename downloadingEnabled property to downloadEnabled
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / video / video-details.model.ts
CommitLineData
22a16e36 1import { UserRight, VideoConstant, VideoDetails as VideoDetailsServerModel, VideoFile, VideoState } from '../../../../../shared'
47564bbe
C
2import { AuthUser } from '../../core'
3import { Video } from '../../shared/video/video.model'
ad9e39fb 4import { Account } from '@app/shared/account/account.model'
22a16e36 5import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
404b54e1
C
6
7export class VideoDetails extends Video implements VideoDetailsServerModel {
09700934 8 descriptionPath: string
2422c46b 9 support: string
09700934 10 channel: VideoChannel
404b54e1 11 tags: string[]
404b54e1 12 files: VideoFile[]
b1fa3eba 13 account: Account
09700934 14 commentsEnabled: boolean
7f2cfe3a 15 downloadEnabled: boolean
09700934 16
2186386c
C
17 waitTranscoding: boolean
18 state: VideoConstant<VideoState>
19
6a9e1d42
C
20 likesPercent: number
21 dislikesPercent: number
404b54e1 22
7ce44a74
C
23 constructor (hash: VideoDetailsServerModel, translations = {}) {
24 super(hash, translations)
404b54e1 25
2de96f4d 26 this.descriptionPath = hash.descriptionPath
404b54e1 27 this.files = hash.files
22a16e36 28 this.channel = new VideoChannel(hash.channel)
ad9e39fb 29 this.account = new Account(hash.account)
d48ff09d 30 this.tags = hash.tags
07fa4c97 31 this.support = hash.support
47564bbe 32 this.commentsEnabled = hash.commentsEnabled
7f2cfe3a 33 this.downloadEnabled = hash.downloadEnabled
6a9e1d42 34
20b40b19 35 this.buildLikeAndDislikePercents()
404b54e1
C
36 }
37
954605a8 38 isRemovableBy (user: AuthUser) {
09700934 39 return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.REMOVE_ANY_VIDEO))
404b54e1
C
40 }
41
954605a8 42 isBlackistableBy (user: AuthUser) {
191764f3
C
43 return this.blacklisted !== true && user && user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) === true
44 }
45
46 isUnblacklistableBy (user: AuthUser) {
47 return this.blacklisted === true && user && user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) === true
404b54e1
C
48 }
49
954605a8 50 isUpdatableBy (user: AuthUser) {
09700934 51 return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.UPDATE_ANY_VIDEO))
404b54e1 52 }
20b40b19
C
53
54 buildLikeAndDislikePercents () {
55 this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100
56 this.dislikesPercent = (this.dislikes / (this.likes + this.dislikes)) * 100
57 }
404b54e1 58}