]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/video/video-details.model.ts
Add concept of video state, and add ability to wait transcoding before
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / video / video-details.model.ts
CommitLineData
2186386c
C
1import {
2 UserRight,
3 VideoChannel,
4 VideoConstant,
5 VideoDetails as VideoDetailsServerModel,
6 VideoFile,
7 VideoState
8} from '../../../../../shared'
47564bbe
C
9import { AuthUser } from '../../core'
10import { Video } from '../../shared/video/video.model'
ad9e39fb 11import { Account } from '@app/shared/account/account.model'
404b54e1
C
12
13export class VideoDetails extends Video implements VideoDetailsServerModel {
09700934 14 descriptionPath: string
2422c46b 15 support: string
09700934 16 channel: VideoChannel
404b54e1 17 tags: string[]
404b54e1 18 files: VideoFile[]
b1fa3eba 19 account: Account
09700934
C
20 commentsEnabled: boolean
21
2186386c
C
22 waitTranscoding: boolean
23 state: VideoConstant<VideoState>
24
6a9e1d42
C
25 likesPercent: number
26 dislikesPercent: number
404b54e1 27
7ce44a74
C
28 constructor (hash: VideoDetailsServerModel, translations = {}) {
29 super(hash, translations)
404b54e1 30
2de96f4d 31 this.descriptionPath = hash.descriptionPath
404b54e1
C
32 this.files = hash.files
33 this.channel = hash.channel
ad9e39fb 34 this.account = new Account(hash.account)
d48ff09d 35 this.tags = hash.tags
07fa4c97 36 this.support = hash.support
47564bbe 37 this.commentsEnabled = hash.commentsEnabled
6a9e1d42 38
20b40b19 39 this.buildLikeAndDislikePercents()
404b54e1
C
40 }
41
954605a8 42 isRemovableBy (user: AuthUser) {
09700934 43 return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.REMOVE_ANY_VIDEO))
404b54e1
C
44 }
45
954605a8
C
46 isBlackistableBy (user: AuthUser) {
47 return user && user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) === true && this.isLocal === false
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}