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