1 import { UserRight, VideoConstant, VideoDetails as VideoDetailsServerModel, VideoFile, VideoState } from '../../../../../shared'
2 import { AuthUser } from '../../core'
3 import { Video } from '../../shared/video/video.model'
4 import { Account } from '@app/shared/account/account.model'
5 import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
7 export class VideoDetails extends Video implements VideoDetailsServerModel {
8 descriptionPath: string
14 commentsEnabled: boolean
15 downloadEnabled: boolean
17 waitTranscoding: boolean
18 state: VideoConstant<VideoState>
21 dislikesPercent: number
23 constructor (hash: VideoDetailsServerModel, translations = {}) {
24 super(hash, translations)
26 this.descriptionPath = hash.descriptionPath
27 this.files = hash.files
28 this.channel = new VideoChannel(hash.channel)
29 this.account = new Account(hash.account)
31 this.support = hash.support
32 this.commentsEnabled = hash.commentsEnabled
33 this.downloadEnabled = hash.downloadEnabled
35 this.buildLikeAndDislikePercents()
38 isRemovableBy (user: AuthUser) {
39 return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.REMOVE_ANY_VIDEO))
42 isBlackistableBy (user: AuthUser) {
43 return this.blacklisted !== true && user && user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) === true
46 isUnblacklistableBy (user: AuthUser) {
47 return this.blacklisted === true && user && user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) === true
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