aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
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
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')
-rw-r--r--client/src/app/shared/video/video-details.model.ts52
-rw-r--r--client/src/app/shared/video/video-edit.model.ts8
-rw-r--r--client/src/app/shared/video/video.model.ts13
-rw-r--r--client/src/app/videos/+video-edit/video-update.component.ts2
-rw-r--r--client/src/app/videos/+video-watch/modal/video-download.component.html4
-rw-r--r--client/src/app/videos/+video-watch/modal/video-download.component.ts10
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.html8
-rw-r--r--client/src/assets/player/peertube-videojs-plugin.ts21
8 files changed, 45 insertions, 73 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 () {
diff --git a/client/src/app/shared/video/video-edit.model.ts b/client/src/app/shared/video/video-edit.model.ts
index a8bbb63eb..c1a70d1b3 100644
--- a/client/src/app/shared/video/video-edit.model.ts
+++ b/client/src/app/shared/video/video-edit.model.ts
@@ -24,16 +24,16 @@ export class VideoEdit {
24 if (videoDetails) { 24 if (videoDetails) {
25 this.id = videoDetails.id 25 this.id = videoDetails.id
26 this.uuid = videoDetails.uuid 26 this.uuid = videoDetails.uuid
27 this.category = videoDetails.category 27 this.category = videoDetails.category.id
28 this.licence = videoDetails.licence 28 this.licence = videoDetails.licence.id
29 this.language = videoDetails.language 29 this.language = videoDetails.language.id
30 this.description = videoDetails.description 30 this.description = videoDetails.description
31 this.name = videoDetails.name 31 this.name = videoDetails.name
32 this.tags = videoDetails.tags 32 this.tags = videoDetails.tags
33 this.nsfw = videoDetails.nsfw 33 this.nsfw = videoDetails.nsfw
34 this.commentsEnabled = videoDetails.commentsEnabled 34 this.commentsEnabled = videoDetails.commentsEnabled
35 this.channel = videoDetails.channel.id 35 this.channel = videoDetails.channel.id
36 this.privacy = videoDetails.privacy 36 this.privacy = videoDetails.privacy.id
37 this.support = videoDetails.support 37 this.support = videoDetails.support
38 this.thumbnailUrl = videoDetails.thumbnailUrl 38 this.thumbnailUrl = videoDetails.thumbnailUrl
39 this.previewUrl = videoDetails.previewUrl 39 this.previewUrl = videoDetails.previewUrl
diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts
index 50ca9eb99..7b68933a1 100644
--- a/client/src/app/shared/video/video.model.ts
+++ b/client/src/app/shared/video/video.model.ts
@@ -2,18 +2,16 @@ import { Account } from '@app/shared/account/account.model'
2import { User } from '../' 2import { User } from '../'
3import { Video as VideoServerModel } from '../../../../../shared' 3import { Video as VideoServerModel } from '../../../../../shared'
4import { Avatar } from '../../../../../shared/models/avatars/avatar.model' 4import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
5import { VideoConstant } from '../../../../../shared/models/videos/video.model'
5import { getAbsoluteAPIUrl } from '../misc/utils' 6import { getAbsoluteAPIUrl } from '../misc/utils'
6 7
7export class Video implements VideoServerModel { 8export class Video implements VideoServerModel {
8 by: string 9 by: string
9 createdAt: Date 10 createdAt: Date
10 updatedAt: Date 11 updatedAt: Date
11 categoryLabel: string 12 category: VideoConstant<number>
12 category: number 13 licence: VideoConstant<number>
13 licenceLabel: string 14 language: VideoConstant<number>
14 licence: number
15 languageLabel: string
16 language: number
17 description: string 15 description: string
18 duration: number 16 duration: number
19 durationLabel: string 17 durationLabel: string
@@ -58,11 +56,8 @@ export class Video implements VideoServerModel {
58 const absoluteAPIUrl = getAbsoluteAPIUrl() 56 const absoluteAPIUrl = getAbsoluteAPIUrl()
59 57
60 this.createdAt = new Date(hash.createdAt.toString()) 58 this.createdAt = new Date(hash.createdAt.toString())
61 this.categoryLabel = hash.categoryLabel
62 this.category = hash.category 59 this.category = hash.category
63 this.licenceLabel = hash.licenceLabel
64 this.licence = hash.licence 60 this.licence = hash.licence
65 this.languageLabel = hash.languageLabel
66 this.language = hash.language 61 this.language = hash.language
67 this.description = hash.description 62 this.description = hash.description
68 this.duration = hash.duration 63 this.duration = hash.duration
diff --git a/client/src/app/videos/+video-edit/video-update.component.ts b/client/src/app/videos/+video-edit/video-update.component.ts
index 2fc09278c..6cd204f72 100644
--- a/client/src/app/videos/+video-edit/video-update.component.ts
+++ b/client/src/app/videos/+video-edit/video-update.component.ts
@@ -72,7 +72,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
72 ] 72 ]
73 73
74 // We cannot set private a video that was not private 74 // We cannot set private a video that was not private
75 if (video.privacy !== VideoPrivacy.PRIVATE) { 75 if (video.privacy.id !== VideoPrivacy.PRIVATE) {
76 const newVideoPrivacies = [] 76 const newVideoPrivacies = []
77 for (const p of this.videoPrivacies) { 77 for (const p of this.videoPrivacies) {
78 if (p.id !== VideoPrivacy.PRIVATE) newVideoPrivacies.push(p) 78 if (p.id !== VideoPrivacy.PRIVATE) newVideoPrivacies.push(p)
diff --git a/client/src/app/videos/+video-watch/modal/video-download.component.html b/client/src/app/videos/+video-watch/modal/video-download.component.html
index f8f17a471..617892b11 100644
--- a/client/src/app/videos/+video-watch/modal/video-download.component.html
+++ b/client/src/app/videos/+video-watch/modal/video-download.component.html
@@ -9,8 +9,8 @@
9 9
10 <div class="modal-body"> 10 <div class="modal-body">
11 <div class="peertube-select-container"> 11 <div class="peertube-select-container">
12 <select [(ngModel)]="resolution"> 12 <select [(ngModel)]="resolutionId">
13 <option *ngFor="let file of video.files" [value]="file.resolution">{{ file.resolutionLabel }}</option> 13 <option *ngFor="let file of video.files" [value]="file.resolution.id">{{ file.resolution.label }}</option>
14 </select> 14 </select>
15 </div> 15 </div>
16 16
diff --git a/client/src/app/videos/+video-watch/modal/video-download.component.ts b/client/src/app/videos/+video-watch/modal/video-download.component.ts
index 3b409e2e6..b06a7eef1 100644
--- a/client/src/app/videos/+video-watch/modal/video-download.component.ts
+++ b/client/src/app/videos/+video-watch/modal/video-download.component.ts
@@ -13,14 +13,14 @@ export class VideoDownloadComponent implements OnInit {
13 @ViewChild('modal') modal: ModalDirective 13 @ViewChild('modal') modal: ModalDirective
14 14
15 downloadType: 'direct' | 'torrent' = 'torrent' 15 downloadType: 'direct' | 'torrent' = 'torrent'
16 resolution: number | string = -1 16 resolutionId: number | string = -1
17 17
18 constructor () { 18 constructor () {
19 // empty 19 // empty
20 } 20 }
21 21
22 ngOnInit () { 22 ngOnInit () {
23 this.resolution = this.video.files[0].resolution 23 this.resolutionId = this.video.files[0].resolution.id
24 } 24 }
25 25
26 show () { 26 show () {
@@ -33,11 +33,11 @@ export class VideoDownloadComponent implements OnInit {
33 33
34 download () { 34 download () {
35 // HTML select send us a string, so convert it to a number 35 // HTML select send us a string, so convert it to a number
36 this.resolution = parseInt(this.resolution.toString(), 10) 36 this.resolutionId = parseInt(this.resolutionId.toString(), 10)
37 37
38 const file = this.video.files.find(f => f.resolution === this.resolution) 38 const file = this.video.files.find(f => f.resolution.id === this.resolutionId)
39 if (!file) { 39 if (!file) {
40 console.error('Could not find file with resolution %d.', this.resolution) 40 console.error('Could not find file with resolution %d.', this.resolutionId)
41 return 41 return
42 } 42 }
43 43
diff --git a/client/src/app/videos/+video-watch/video-watch.component.html b/client/src/app/videos/+video-watch/video-watch.component.html
index 82f148e9b..6a7da0614 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.html
+++ b/client/src/app/videos/+video-watch/video-watch.component.html
@@ -122,7 +122,7 @@
122 Privacy 122 Privacy
123 </span> 123 </span>
124 <span class="video-attribute-value"> 124 <span class="video-attribute-value">
125 {{ video.privacyLabel }} 125 {{ video.privacy.label }}
126 </span> 126 </span>
127 </div> 127 </div>
128 128
@@ -131,7 +131,7 @@
131 Category 131 Category
132 </span> 132 </span>
133 <span class="video-attribute-value"> 133 <span class="video-attribute-value">
134 {{ video.categoryLabel }} 134 {{ video.category.label }}
135 </span> 135 </span>
136 </div> 136 </div>
137 137
@@ -140,7 +140,7 @@
140 Licence 140 Licence
141 </span> 141 </span>
142 <span class="video-attribute-value"> 142 <span class="video-attribute-value">
143 {{ video.licenceLabel }} 143 {{ video.licence.label }}
144 </span> 144 </span>
145 </div> 145 </div>
146 146
@@ -149,7 +149,7 @@
149 Language 149 Language
150 </span> 150 </span>
151 <span class="video-attribute-value"> 151 <span class="video-attribute-value">
152 {{ video.languageLabel }} 152 {{ video.language.label }}
153 </span> 153 </span>
154 </div> 154 </div>
155 155
diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts
index a96f6d1a1..c99363fb5 100644
--- a/client/src/assets/player/peertube-videojs-plugin.ts
+++ b/client/src/assets/player/peertube-videojs-plugin.ts
@@ -2,6 +2,7 @@
2 2
3import * as videojs from 'video.js' 3import * as videojs from 'video.js'
4import * as WebTorrent from 'webtorrent' 4import * as WebTorrent from 'webtorrent'
5import { VideoConstant, VideoResolution } from '../../../../shared/models/videos'
5import { VideoFile } from '../../../../shared/models/videos/video.model' 6import { VideoFile } from '../../../../shared/models/videos/video.model'
6import { renderVideo } from './video-renderer' 7import { renderVideo } from './video-renderer'
7 8
@@ -52,8 +53,8 @@ class ResolutionMenuItem extends MenuItem {
52 options.selectable = true 53 options.selectable = true
53 super(player, options) 54 super(player, options)
54 55
55 const currentResolution = this.player_.peertube().getCurrentResolution() 56 const currentResolutionId = this.player_.peertube().getCurrentResolutionId()
56 this.selected(this.options_.id === currentResolution) 57 this.selected(this.options_.id === currentResolutionId)
57 } 58 }
58 59
59 handleClick (event) { 60 handleClick (event) {
@@ -89,10 +90,10 @@ class ResolutionMenuButton extends MenuButton {
89 menuItems.push(new ResolutionMenuItem( 90 menuItems.push(new ResolutionMenuItem(
90 this.player_, 91 this.player_,
91 { 92 {
92 id: videoFile.resolution, 93 id: videoFile.resolution.id,
93 label: videoFile.resolutionLabel, 94 label: videoFile.resolution.label,
94 src: videoFile.magnetUri, 95 src: videoFile.magnetUri,
95 selected: videoFile.resolution === this.currentSelection 96 selected: videoFile.resolution.id === this.currentSelectionId
96 }) 97 })
97 ) 98 )
98 } 99 }
@@ -269,12 +270,12 @@ class PeerTubePlugin extends Plugin {
269 this.flushVideoFile(this.currentVideoFile, false) 270 this.flushVideoFile(this.currentVideoFile, false)
270 } 271 }
271 272
272 getCurrentResolution () { 273 getCurrentResolutionId () {
273 return this.currentVideoFile ? this.currentVideoFile.resolution : -1 274 return this.currentVideoFile ? this.currentVideoFile.resolution.id : -1
274 } 275 }
275 276
276 getCurrentResolutionLabel () { 277 getCurrentResolutionLabel () {
277 return this.currentVideoFile ? this.currentVideoFile.resolutionLabel : '' 278 return this.currentVideoFile ? this.currentVideoFile.resolution.label : ''
278 } 279 }
279 280
280 updateVideoFile (videoFile?: VideoFile, done?: () => void) { 281 updateVideoFile (videoFile?: VideoFile, done?: () => void) {
@@ -339,7 +340,7 @@ class PeerTubePlugin extends Plugin {
339 this.trigger('videoFileUpdate') 340 this.trigger('videoFileUpdate')
340 } 341 }
341 342
342 updateResolution (resolution) { 343 updateResolution (resolutionId: number) {
343 // Remember player state 344 // Remember player state
344 const currentTime = this.player.currentTime() 345 const currentTime = this.player.currentTime()
345 const isPaused = this.player.paused() 346 const isPaused = this.player.paused()
@@ -352,7 +353,7 @@ class PeerTubePlugin extends Plugin {
352 this.player.bigPlayButton.hide() 353 this.player.bigPlayButton.hide()
353 } 354 }
354 355
355 const newVideoFile = this.videoFiles.find(f => f.resolution === resolution) 356 const newVideoFile = this.videoFiles.find(f => f.resolution.id === resolutionId)
356 this.updateVideoFile(newVideoFile, () => { 357 this.updateVideoFile(newVideoFile, () => {
357 this.player.currentTime(currentTime) 358 this.player.currentTime(currentTime)
358 this.player.handleTechSeeked_() 359 this.player.handleTechSeeked_()