5 VideoDetails as VideoDetailsServerModel,
8 } from '../../../../../shared'
9 import { AuthUser } from '../../core'
10 import { Video } from '../../shared/video/video.model'
11 import { Account } from '@app/shared/account/account.model'
13 export class VideoDetails extends Video implements VideoDetailsServerModel {
14 descriptionPath: string
20 commentsEnabled: boolean
22 waitTranscoding: boolean
23 state: VideoConstant<VideoState>
26 dislikesPercent: number
28 constructor (hash: VideoDetailsServerModel, translations = {}) {
29 super(hash, translations)
31 this.descriptionPath = hash.descriptionPath
32 this.files = hash.files
33 this.channel = hash.channel
34 this.account = new Account(hash.account)
36 this.support = hash.support
37 this.commentsEnabled = hash.commentsEnabled
39 this.buildLikeAndDislikePercents()
42 isRemovableBy (user: AuthUser) {
43 return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.REMOVE_ANY_VIDEO))
46 isBlackistableBy (user: AuthUser) {
47 return user && user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) === true && this.isLocal === false
50 isUpdatableBy (user: AuthUser) {
51 return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.UPDATE_ANY_VIDEO))
54 buildLikeAndDislikePercents () {
55 this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100
56 this.dislikesPercent = (this.dislikes / (this.likes + this.dislikes)) * 100