aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/video/video-details.model.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-03-19 11:04:40 +0100
committerChocobozzz <me@florianbigard.com>2018-03-19 11:04:40 +0100
commit09700934b90e2ac7b1b9ed1694d9d4d52735e2e1 (patch)
tree29ea9512fa34676a7194e9cb37d912b38266c9cc /client/src/app/shared/video/video-details.model.ts
parentae5a3dd6642c8d5abc87b874496026dc9ed37d2d (diff)
downloadPeerTube-09700934b90e2ac7b1b9ed1694d9d4d52735e2e1.tar.gz
PeerTube-09700934b90e2ac7b1b9ed1694d9d4d52735e2e1.tar.zst
PeerTube-09700934b90e2ac7b1b9ed1694d9d4d52735e2e1.zip
BEARKING CHANGE: Update videos API response
before beta
Diffstat (limited to 'client/src/app/shared/video/video-details.model.ts')
-rw-r--r--client/src/app/shared/video/video-details.model.ts52
1 files changed, 14 insertions, 38 deletions
diff --git a/client/src/app/shared/video/video-details.model.ts b/client/src/app/shared/video/video-details.model.ts
index 1882a8165..9fc326beb 100644
--- a/client/src/app/shared/video/video-details.model.ts
+++ b/client/src/app/shared/video/video-details.model.ts
@@ -1,57 +1,33 @@
1import { 1import {
2 UserRight, VideoChannel, VideoDetails as VideoDetailsServerModel, VideoFile, VideoPrivacy, 2 UserRight,
3 VideoChannel,
4 VideoDetails as VideoDetailsServerModel,
5 VideoFile,
6 VideoPrivacy,
3 VideoResolution 7 VideoResolution
4} from '../../../../../shared' 8} from '../../../../../shared'
5import { Account } from '../../../../../shared/models/actors' 9import { Account } from '../../../../../shared/models/actors'
10import { VideoConstant } from '../../../../../shared/models/videos/video.model'
6import { AuthUser } from '../../core' 11import { AuthUser } from '../../core'
7import { Video } from '../../shared/video/video.model' 12import { Video } from '../../shared/video/video.model'
8 13
9export class VideoDetails extends Video implements VideoDetailsServerModel { 14export class VideoDetails extends Video implements VideoDetailsServerModel {
10 accountName: string 15 privacy: VideoConstant<VideoPrivacy>
11 by: string 16 descriptionPath: string
12 createdAt: Date
13 updatedAt: Date
14 categoryLabel: string
15 category: number
16 licenceLabel: string
17 licence: number
18 languageLabel: string
19 language: number
20 description: string
21 support: string 17 support: string
22 duration: number 18 channel: VideoChannel
23 durationLabel: string
24 id: number
25 uuid: string
26 isLocal: boolean
27 name: string
28 serverHost: string
29 tags: string[] 19 tags: string[]
30 thumbnailPath: string
31 thumbnailUrl: string
32 previewPath: string
33 previewUrl: string
34 embedPath: string
35 embedUrl: string
36 views: number
37 likes: number
38 dislikes: number
39 nsfw: boolean
40 descriptionPath: string
41 files: VideoFile[] 20 files: VideoFile[]
42 channel: VideoChannel
43 privacy: VideoPrivacy
44 privacyLabel: string
45 account: Account 21 account: Account
22 commentsEnabled: boolean
23
46 likesPercent: number 24 likesPercent: number
47 dislikesPercent: number 25 dislikesPercent: number
48 commentsEnabled: boolean
49 26
50 constructor (hash: VideoDetailsServerModel) { 27 constructor (hash: VideoDetailsServerModel) {
51 super(hash) 28 super(hash)
52 29
53 this.privacy = hash.privacy 30 this.privacy = hash.privacy
54 this.privacyLabel = hash.privacyLabel
55 this.descriptionPath = hash.descriptionPath 31 this.descriptionPath = hash.descriptionPath
56 this.files = hash.files 32 this.files = hash.files
57 this.channel = hash.channel 33 this.channel = hash.channel
@@ -72,14 +48,14 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
72 48
73 // If the download speed is too bad, return the lowest resolution we have 49 // If the download speed is too bad, return the lowest resolution we have
74 if (betterResolutionFile === undefined) { 50 if (betterResolutionFile === undefined) {
75 betterResolutionFile = this.files.find(f => f.resolution === VideoResolution.H_240P) 51 betterResolutionFile = this.files.find(f => f.resolution.id === VideoResolution.H_240P)
76 } 52 }
77 53
78 return betterResolutionFile.magnetUri 54 return betterResolutionFile.magnetUri
79 } 55 }
80 56
81 isRemovableBy (user: AuthUser) { 57 isRemovableBy (user: AuthUser) {
82 return user && this.isLocal === true && (this.accountName === user.username || user.hasRight(UserRight.REMOVE_ANY_VIDEO)) 58 return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.REMOVE_ANY_VIDEO))
83 } 59 }
84 60
85 isBlackistableBy (user: AuthUser) { 61 isBlackistableBy (user: AuthUser) {
@@ -87,7 +63,7 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
87 } 63 }
88 64
89 isUpdatableBy (user: AuthUser) { 65 isUpdatableBy (user: AuthUser) {
90 return user && this.isLocal === true && (this.accountName === user.username || user.hasRight(UserRight.UPDATE_ANY_VIDEO)) 66 return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.UPDATE_ANY_VIDEO))
91 } 67 }
92 68
93 buildLikeAndDislikePercents () { 69 buildLikeAndDislikePercents () {