]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - 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
1import { UserRight, VideoConstant, VideoDetails as VideoDetailsServerModel, VideoFile, VideoState } from '../../../../../shared'
2import { AuthUser } from '../../core'
3import { Video } from '../../shared/video/video.model'
4import { Account } from '@app/shared/account/account.model'
5import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
6
7export class VideoDetails extends Video implements VideoDetailsServerModel {
8 descriptionPath: string
9 support: string
10 channel: VideoChannel
11 tags: string[]
12 files: VideoFile[]
13 account: Account
14 commentsEnabled: boolean
15 downloadEnabled: boolean
16
17 waitTranscoding: boolean
18 state: VideoConstant<VideoState>
19
20 likesPercent: number
21 dislikesPercent: number
22
23 constructor (hash: VideoDetailsServerModel, translations = {}) {
24 super(hash, translations)
25
26 this.descriptionPath = hash.descriptionPath
27 this.files = hash.files
28 this.channel = new VideoChannel(hash.channel)
29 this.account = new Account(hash.account)
30 this.tags = hash.tags
31 this.support = hash.support
32 this.commentsEnabled = hash.commentsEnabled
33 this.downloadEnabled = hash.downloadEnabled
34
35 this.buildLikeAndDislikePercents()
36 }
37
38 isRemovableBy (user: AuthUser) {
39 return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.REMOVE_ANY_VIDEO))
40 }
41
42 isBlackistableBy (user: AuthUser) {
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
48 }
49
50 isUpdatableBy (user: AuthUser) {
51 return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.UPDATE_ANY_VIDEO))
52 }
53
54 buildLikeAndDislikePercents () {
55 this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100
56 this.dislikesPercent = (this.dislikes / (this.likes + this.dislikes)) * 100
57 }
58}