diff options
author | Chocobozzz <me@florianbigard.com> | 2021-10-27 14:37:04 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-10-29 11:48:21 +0200 |
commit | 2760b454a761f6af3138b2fb5f34340772ab0d1e (patch) | |
tree | 2b3a2d81478f8b432eb54cce4caa5a760c494627 /client/src/app/shared | |
parent | e4611b54910d8e7f2b4f8a97ee2d9cc8e1054127 (diff) | |
download | PeerTube-2760b454a761f6af3138b2fb5f34340772ab0d1e.tar.gz PeerTube-2760b454a761f6af3138b2fb5f34340772ab0d1e.tar.zst PeerTube-2760b454a761f6af3138b2fb5f34340772ab0d1e.zip |
Deprecate filter video query
Introduce include and isLocal instead
Diffstat (limited to 'client/src/app/shared')
8 files changed, 45 insertions, 37 deletions
diff --git a/client/src/app/shared/shared-custom-markup/custom-markup.service.ts b/client/src/app/shared/shared-custom-markup/custom-markup.service.ts index ab640d348..a959b336d 100644 --- a/client/src/app/shared/shared-custom-markup/custom-markup.service.ts +++ b/client/src/app/shared/shared-custom-markup/custom-markup.service.ts | |||
@@ -7,7 +7,6 @@ import { | |||
7 | ContainerMarkupData, | 7 | ContainerMarkupData, |
8 | EmbedMarkupData, | 8 | EmbedMarkupData, |
9 | PlaylistMiniatureMarkupData, | 9 | PlaylistMiniatureMarkupData, |
10 | VideoFilter, | ||
11 | VideoMiniatureMarkupData, | 10 | VideoMiniatureMarkupData, |
12 | VideosListMarkupData | 11 | VideosListMarkupData |
13 | } from '@shared/models' | 12 | } from '@shared/models' |
@@ -193,7 +192,7 @@ export class CustomMarkupService { | |||
193 | 192 | ||
194 | isLive: this.buildBoolean(data.isLive), | 193 | isLive: this.buildBoolean(data.isLive), |
195 | 194 | ||
196 | filter: this.buildBoolean(data.onlyLocal) ? 'local' as VideoFilter : undefined | 195 | isLocal: this.buildBoolean(data.onlyLocal) ? true : undefined |
197 | } | 196 | } |
198 | 197 | ||
199 | this.dynamicElementService.setModel(component, model) | 198 | this.dynamicElementService.setModel(component, model) |
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts index 856e43681..0e4d5fb12 100644 --- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { finalize } from 'rxjs/operators' | 1 | import { finalize } from 'rxjs/operators' |
2 | import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' | 2 | import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' |
3 | import { AuthService, Notifier } from '@app/core' | 3 | import { AuthService, Notifier } from '@app/core' |
4 | import { VideoFilter, VideoSortField } from '@shared/models' | 4 | import { VideoSortField } from '@shared/models' |
5 | import { Video, VideoService } from '../../shared-main' | 5 | import { Video, VideoService } from '../../shared-main' |
6 | import { MiniatureDisplayOptions } from '../../shared-video-miniature' | 6 | import { MiniatureDisplayOptions } from '../../shared-video-miniature' |
7 | import { CustomMarkupComponent } from './shared' | 7 | import { CustomMarkupComponent } from './shared' |
@@ -21,7 +21,7 @@ export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit | |||
21 | @Input() languageOneOf: string[] | 21 | @Input() languageOneOf: string[] |
22 | @Input() count: number | 22 | @Input() count: number |
23 | @Input() onlyDisplayTitle: boolean | 23 | @Input() onlyDisplayTitle: boolean |
24 | @Input() filter: VideoFilter | 24 | @Input() isLocal: boolean |
25 | @Input() isLive: boolean | 25 | @Input() isLive: boolean |
26 | @Input() maxRows: number | 26 | @Input() maxRows: number |
27 | @Input() channelHandle: string | 27 | @Input() channelHandle: string |
@@ -86,7 +86,7 @@ export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit | |||
86 | }, | 86 | }, |
87 | categoryOneOf: this.categoryOneOf, | 87 | categoryOneOf: this.categoryOneOf, |
88 | languageOneOf: this.languageOneOf, | 88 | languageOneOf: this.languageOneOf, |
89 | filter: this.filter, | 89 | isLocal: this.isLocal, |
90 | isLive: this.isLive, | 90 | isLive: this.isLive, |
91 | sort: this.sort as VideoSortField, | 91 | sort: this.sort as VideoSortField, |
92 | account: { nameWithHost: this.accountHandle }, | 92 | account: { nameWithHost: this.accountHandle }, |
diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts index 10caec014..699eac7f1 100644 --- a/client/src/app/shared/shared-main/video/video.model.ts +++ b/client/src/app/shared/shared-main/video/video.model.ts | |||
@@ -65,8 +65,12 @@ export class Video implements VideoServerModel { | |||
65 | waitTranscoding?: boolean | 65 | waitTranscoding?: boolean |
66 | state?: VideoConstant<VideoState> | 66 | state?: VideoConstant<VideoState> |
67 | scheduledUpdate?: VideoScheduleUpdate | 67 | scheduledUpdate?: VideoScheduleUpdate |
68 | |||
68 | blacklisted?: boolean | 69 | blacklisted?: boolean |
69 | blockedReason?: string | 70 | blacklistedReason?: string |
71 | |||
72 | blockedOwner?: boolean | ||
73 | blockedServer?: boolean | ||
70 | 74 | ||
71 | account: { | 75 | account: { |
72 | id: number | 76 | id: number |
@@ -163,7 +167,10 @@ export class Video implements VideoServerModel { | |||
163 | if (this.state) this.state.label = peertubeTranslate(this.state.label, translations) | 167 | if (this.state) this.state.label = peertubeTranslate(this.state.label, translations) |
164 | 168 | ||
165 | this.blacklisted = hash.blacklisted | 169 | this.blacklisted = hash.blacklisted |
166 | this.blockedReason = hash.blacklistedReason | 170 | this.blacklistedReason = hash.blacklistedReason |
171 | |||
172 | this.blockedOwner = hash.blockedOwner | ||
173 | this.blockedServer = hash.blockedServer | ||
167 | 174 | ||
168 | this.userHistory = hash.userHistory | 175 | this.userHistory = hash.userHistory |
169 | 176 | ||
diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts index 9e3aa1e6a..0a3a51b0c 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts | |||
@@ -18,7 +18,7 @@ import { | |||
18 | VideoConstant, | 18 | VideoConstant, |
19 | VideoDetails as VideoDetailsServerModel, | 19 | VideoDetails as VideoDetailsServerModel, |
20 | VideoFileMetadata, | 20 | VideoFileMetadata, |
21 | VideoFilter, | 21 | VideoInclude, |
22 | VideoPrivacy, | 22 | VideoPrivacy, |
23 | VideoSortField, | 23 | VideoSortField, |
24 | VideoUpdate | 24 | VideoUpdate |
@@ -34,11 +34,13 @@ import { Video } from './video.model' | |||
34 | export type CommonVideoParams = { | 34 | export type CommonVideoParams = { |
35 | videoPagination?: ComponentPaginationLight | 35 | videoPagination?: ComponentPaginationLight |
36 | sort: VideoSortField | SortMeta | 36 | sort: VideoSortField | SortMeta |
37 | filter?: VideoFilter | 37 | include?: VideoInclude |
38 | isLocal?: boolean | ||
38 | categoryOneOf?: number[] | 39 | categoryOneOf?: number[] |
39 | languageOneOf?: string[] | 40 | languageOneOf?: string[] |
40 | isLive?: boolean | 41 | isLive?: boolean |
41 | skipCount?: boolean | 42 | skipCount?: boolean |
43 | |||
42 | // FIXME: remove? | 44 | // FIXME: remove? |
43 | nsfwPolicy?: NSFWPolicyType | 45 | nsfwPolicy?: NSFWPolicyType |
44 | nsfw?: BooleanBothQuery | 46 | nsfw?: BooleanBothQuery |
@@ -202,12 +204,14 @@ export class VideoService { | |||
202 | } | 204 | } |
203 | 205 | ||
204 | getAdminVideos ( | 206 | getAdminVideos ( |
205 | parameters: Omit<CommonVideoParams, 'filter'> & { pagination: RestPagination, search?: string } | 207 | parameters: CommonVideoParams & { pagination: RestPagination, search?: string } |
206 | ): Observable<ResultList<Video>> { | 208 | ): Observable<ResultList<Video>> { |
207 | const { pagination, search } = parameters | 209 | const { pagination, search } = parameters |
208 | 210 | ||
211 | const include = VideoInclude.BLACKLISTED | VideoInclude.BLOCKED_OWNER | VideoInclude.HIDDEN_PRIVACY | VideoInclude.NOT_PUBLISHED_STATE | ||
212 | |||
209 | let params = new HttpParams() | 213 | let params = new HttpParams() |
210 | params = this.buildCommonVideosParams({ params, ...parameters }) | 214 | params = this.buildCommonVideosParams({ params, include, ...parameters }) |
211 | 215 | ||
212 | params = params.set('start', pagination.start.toString()) | 216 | params = params.set('start', pagination.start.toString()) |
213 | .set('count', pagination.count.toString()) | 217 | .set('count', pagination.count.toString()) |
@@ -216,8 +220,6 @@ export class VideoService { | |||
216 | params = this.buildAdminParamsFromSearch(search, params) | 220 | params = this.buildAdminParamsFromSearch(search, params) |
217 | } | 221 | } |
218 | 222 | ||
219 | if (!params.has('filter')) params = params.set('filter', 'all') | ||
220 | |||
221 | return this.authHttp | 223 | return this.authHttp |
222 | .get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params }) | 224 | .get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params }) |
223 | .pipe( | 225 | .pipe( |
@@ -266,10 +268,10 @@ export class VideoService { | |||
266 | return feeds | 268 | return feeds |
267 | } | 269 | } |
268 | 270 | ||
269 | getVideoFeedUrls (sort: VideoSortField, filter?: VideoFilter, categoryOneOf?: number[]) { | 271 | getVideoFeedUrls (sort: VideoSortField, isLocal: boolean, categoryOneOf?: number[]) { |
270 | let params = this.restService.addRestGetParams(new HttpParams(), undefined, sort) | 272 | let params = this.restService.addRestGetParams(new HttpParams(), undefined, sort) |
271 | 273 | ||
272 | if (filter) params = params.set('filter', filter) | 274 | if (isLocal) params = params.set('isLocal', isLocal) |
273 | 275 | ||
274 | if (categoryOneOf) { | 276 | if (categoryOneOf) { |
275 | for (const c of categoryOneOf) { | 277 | for (const c of categoryOneOf) { |
@@ -425,7 +427,8 @@ export class VideoService { | |||
425 | params, | 427 | params, |
426 | videoPagination, | 428 | videoPagination, |
427 | sort, | 429 | sort, |
428 | filter, | 430 | isLocal, |
431 | include, | ||
429 | categoryOneOf, | 432 | categoryOneOf, |
430 | languageOneOf, | 433 | languageOneOf, |
431 | skipCount, | 434 | skipCount, |
@@ -440,9 +443,10 @@ export class VideoService { | |||
440 | 443 | ||
441 | let newParams = this.restService.addRestGetParams(params, pagination, sort) | 444 | let newParams = this.restService.addRestGetParams(params, pagination, sort) |
442 | 445 | ||
443 | if (filter) newParams = newParams.set('filter', filter) | ||
444 | if (skipCount) newParams = newParams.set('skipCount', skipCount + '') | 446 | if (skipCount) newParams = newParams.set('skipCount', skipCount + '') |
445 | 447 | ||
448 | if (isLocal) newParams = newParams.set('isLocal', isLocal) | ||
449 | if (include) newParams = newParams.set('include', include) | ||
446 | if (isLive) newParams = newParams.set('isLive', isLive) | 450 | if (isLive) newParams = newParams.set('isLive', isLive) |
447 | if (nsfw) newParams = newParams.set('nsfw', nsfw) | 451 | if (nsfw) newParams = newParams.set('nsfw', nsfw) |
448 | if (nsfwPolicy) newParams = newParams.set('nsfw', this.nsfwPolicyToParam(nsfwPolicy)) | 452 | if (nsfwPolicy) newParams = newParams.set('nsfw', this.nsfwPolicyToParam(nsfwPolicy)) |
@@ -454,13 +458,9 @@ export class VideoService { | |||
454 | 458 | ||
455 | private buildAdminParamsFromSearch (search: string, params: HttpParams) { | 459 | private buildAdminParamsFromSearch (search: string, params: HttpParams) { |
456 | const filters = this.restService.parseQueryStringFilter(search, { | 460 | const filters = this.restService.parseQueryStringFilter(search, { |
457 | filter: { | 461 | isLocal: { |
458 | prefix: 'local:', | 462 | prefix: 'isLocal:', |
459 | handler: v => { | 463 | isBoolean: true |
460 | if (v === 'true') return 'all-local' | ||
461 | |||
462 | return 'all' | ||
463 | } | ||
464 | } | 464 | } |
465 | }) | 465 | }) |
466 | 466 | ||
diff --git a/client/src/app/shared/shared-moderation/video-block.component.ts b/client/src/app/shared/shared-moderation/video-block.component.ts index f6c29dcfa..a6180dd14 100644 --- a/client/src/app/shared/shared-moderation/video-block.component.ts +++ b/client/src/app/shared/shared-moderation/video-block.component.ts | |||
@@ -61,7 +61,7 @@ export class VideoBlockComponent extends FormReactive implements OnInit { | |||
61 | this.hide() | 61 | this.hide() |
62 | 62 | ||
63 | this.video.blacklisted = true | 63 | this.video.blacklisted = true |
64 | this.video.blockedReason = reason | 64 | this.video.blacklistedReason = reason |
65 | 65 | ||
66 | this.videoBlocked.emit() | 66 | this.videoBlocked.emit() |
67 | }, | 67 | }, |
diff --git a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts index 2ba091438..feac79d4e 100644 --- a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts +++ b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts | |||
@@ -188,7 +188,7 @@ export class VideoActionsDropdownComponent implements OnChanges { | |||
188 | this.notifier.success($localize`Video ${this.video.name} unblocked.`) | 188 | this.notifier.success($localize`Video ${this.video.name} unblocked.`) |
189 | 189 | ||
190 | this.video.blacklisted = false | 190 | this.video.blacklisted = false |
191 | this.video.blockedReason = null | 191 | this.video.blacklistedReason = null |
192 | 192 | ||
193 | this.videoUnblocked.emit() | 193 | this.videoUnblocked.emit() |
194 | }, | 194 | }, |
diff --git a/client/src/app/shared/shared-video-miniature/video-filters.model.ts b/client/src/app/shared/shared-video-miniature/video-filters.model.ts index 920dc826c..5ad7cf3f7 100644 --- a/client/src/app/shared/shared-video-miniature/video-filters.model.ts +++ b/client/src/app/shared/shared-video-miniature/video-filters.model.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { intoArray, toBoolean } from '@app/helpers' | 1 | import { intoArray, toBoolean } from '@app/helpers' |
2 | import { AttributesOnly } from '@shared/core-utils' | 2 | import { AttributesOnly } from '@shared/core-utils' |
3 | import { BooleanBothQuery, NSFWPolicyType, VideoFilter, VideoSortField } from '@shared/models' | 3 | import { BooleanBothQuery, NSFWPolicyType, VideoInclude, VideoSortField } from '@shared/models' |
4 | 4 | ||
5 | type VideoFiltersKeys = { | 5 | type VideoFiltersKeys = { |
6 | [ id in keyof AttributesOnly<VideoFilters> ]: any | 6 | [ id in keyof AttributesOnly<VideoFilters> ]: any |
@@ -196,14 +196,15 @@ export class VideoFilters { | |||
196 | } | 196 | } |
197 | 197 | ||
198 | toVideosAPIObject () { | 198 | toVideosAPIObject () { |
199 | let filter: VideoFilter | 199 | let isLocal: boolean |
200 | 200 | let include: VideoInclude | |
201 | if (this.scope === 'local' && this.allVideos) { | 201 | |
202 | filter = 'all-local' | 202 | if (this.scope === 'local') { |
203 | } else if (this.scope === 'federated' && this.allVideos) { | 203 | isLocal = true |
204 | filter = 'all' | 204 | } |
205 | } else if (this.scope === 'local') { | 205 | |
206 | filter = 'local' | 206 | if (this.allVideos) { |
207 | include = VideoInclude.NOT_PUBLISHED_STATE | VideoInclude.HIDDEN_PRIVACY | ||
207 | } | 208 | } |
208 | 209 | ||
209 | let isLive: boolean | 210 | let isLive: boolean |
@@ -216,7 +217,8 @@ export class VideoFilters { | |||
216 | languageOneOf: this.languageOneOf, | 217 | languageOneOf: this.languageOneOf, |
217 | categoryOneOf: this.categoryOneOf, | 218 | categoryOneOf: this.categoryOneOf, |
218 | search: this.search, | 219 | search: this.search, |
219 | filter, | 220 | isLocal, |
221 | include, | ||
220 | isLive | 222 | isLive |
221 | } | 223 | } |
222 | } | 224 | } |
diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.html b/client/src/app/shared/shared-video-miniature/video-miniature.component.html index b12495f90..30483831a 100644 --- a/client/src/app/shared/shared-video-miniature/video-miniature.component.html +++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.html | |||
@@ -55,7 +55,7 @@ | |||
55 | 55 | ||
56 | <div *ngIf="displayOptions.blacklistInfo && video.blacklisted" class="video-info-blocked"> | 56 | <div *ngIf="displayOptions.blacklistInfo && video.blacklisted" class="video-info-blocked"> |
57 | <span class="blocked-label" i18n>Blocked</span> | 57 | <span class="blocked-label" i18n>Blocked</span> |
58 | <span class="blocked-reason" *ngIf="video.blockedReason">{{ video.blockedReason }}</span> | 58 | <span class="blocked-reason" *ngIf="video.blacklistedReason">{{ video.blacklistedReason }}</span> |
59 | </div> | 59 | </div> |
60 | 60 | ||
61 | <div i18n *ngIf="displayOptions.nsfw && video.nsfw" class="video-info-nsfw"> | 61 | <div i18n *ngIf="displayOptions.nsfw && video.nsfw" class="video-info-nsfw"> |