diff options
author | Chocobozzz <me@florianbigard.com> | 2018-03-19 11:04:40 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-03-19 11:04:40 +0100 |
commit | 09700934b90e2ac7b1b9ed1694d9d4d52735e2e1 (patch) | |
tree | 29ea9512fa34676a7194e9cb37d912b38266c9cc /client/src/app | |
parent | ae5a3dd6642c8d5abc87b874496026dc9ed37d2d (diff) | |
download | PeerTube-09700934b90e2ac7b1b9ed1694d9d4d52735e2e1.tar.gz PeerTube-09700934b90e2ac7b1b9ed1694d9d4d52735e2e1.tar.zst PeerTube-09700934b90e2ac7b1b9ed1694d9d4d52735e2e1.zip |
BEARKING CHANGE: Update videos API response
before beta
Diffstat (limited to 'client/src/app')
7 files changed, 34 insertions, 63 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 @@ | |||
1 | import { | 1 | import { |
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' |
5 | import { Account } from '../../../../../shared/models/actors' | 9 | import { Account } from '../../../../../shared/models/actors' |
10 | import { VideoConstant } from '../../../../../shared/models/videos/video.model' | ||
6 | import { AuthUser } from '../../core' | 11 | import { AuthUser } from '../../core' |
7 | import { Video } from '../../shared/video/video.model' | 12 | import { Video } from '../../shared/video/video.model' |
8 | 13 | ||
9 | export class VideoDetails extends Video implements VideoDetailsServerModel { | 14 | export 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' | |||
2 | import { User } from '../' | 2 | import { User } from '../' |
3 | import { Video as VideoServerModel } from '../../../../../shared' | 3 | import { Video as VideoServerModel } from '../../../../../shared' |
4 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' | 4 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' |
5 | import { VideoConstant } from '../../../../../shared/models/videos/video.model' | ||
5 | import { getAbsoluteAPIUrl } from '../misc/utils' | 6 | import { getAbsoluteAPIUrl } from '../misc/utils' |
6 | 7 | ||
7 | export class Video implements VideoServerModel { | 8 | export 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 | ||