From 2760b454a761f6af3138b2fb5f34340772ab0d1e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 27 Oct 2021 14:37:04 +0200 Subject: Deprecate filter video query Introduce include and isLocal instead --- .../overview/videos/video-list.component.html | 13 +++++++-- .../overview/videos/video-list.component.scss | 2 ++ .../+admin/overview/videos/video-list.component.ts | 32 ++++++++++++++++++-- .../shared/information/video-alert.component.html | 2 +- .../videos-list-common-page.component.ts | 2 +- .../shared-custom-markup/custom-markup.service.ts | 3 +- .../videos-list-markup.component.ts | 6 ++-- .../app/shared/shared-main/video/video.model.ts | 11 +++++-- .../app/shared/shared-main/video/video.service.ts | 34 +++++++++++----------- .../shared-moderation/video-block.component.ts | 2 +- .../video-actions-dropdown.component.ts | 2 +- .../shared-video-miniature/video-filters.model.ts | 22 +++++++------- .../video-miniature.component.html | 2 +- 13 files changed, 88 insertions(+), 45 deletions(-) (limited to 'client/src/app') diff --git a/client/src/app/+admin/overview/videos/video-list.component.html b/client/src/app/+admin/overview/videos/video-list.component.html index 1f1e9cc6e..6250c00fb 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.html +++ b/client/src/app/+admin/overview/videos/video-list.component.html @@ -63,10 +63,17 @@ - - {{ video.privacy.label }} + + {{ video.privacy.label }} + NSFW - NSFW + + Not published yet + + Account muted + Server muted + + Blocked diff --git a/client/src/app/+admin/overview/videos/video-list.component.scss b/client/src/app/+admin/overview/videos/video-list.component.scss index fcdb457f2..250a917e4 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.scss +++ b/client/src/app/+admin/overview/videos/video-list.component.scss @@ -7,4 +7,6 @@ my-embed { .badge { @include table-badge; + + margin-right: 5px; } diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts index a445bc209..dd9225e6a 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.ts +++ b/client/src/app/+admin/overview/videos/video-list.component.ts @@ -3,7 +3,7 @@ import { Component, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { AuthService, ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' -import { UserRight } from '@shared/models' +import { UserRight, VideoPrivacy, VideoState } from '@shared/models' import { AdvancedInputFilter } from '@app/shared/shared-forms' import { VideoActionsDisplayType } from '@app/shared/shared-video-miniature' @@ -28,8 +28,12 @@ export class VideoListComponent extends RestTable implements OnInit { title: $localize`Advanced filters`, children: [ { - queryParams: { search: 'local:true' }, - label: $localize`Only local videos` + queryParams: { search: 'isLocal:false' }, + label: $localize`Remote videos` + }, + { + queryParams: { search: 'isLocal:true' }, + label: $localize`Local videos` } ] } @@ -88,6 +92,28 @@ export class VideoListComponent extends RestTable implements OnInit { this.reloadData() } + getPrivacyBadgeClass (privacy: VideoPrivacy) { + if (privacy === VideoPrivacy.PUBLIC) return 'badge-blue' + + return 'badge-yellow' + } + + isUnpublished (state: VideoState) { + return state !== VideoState.PUBLISHED + } + + isAccountBlocked (video: Video) { + return video.blockedOwner + } + + isServerBlocked (video: Video) { + return video.blockedServer + } + + isVideoBlocked (video: Video) { + return video.blacklisted + } + protected reloadData () { this.selectedVideos = [] diff --git a/client/src/app/+videos/+video-watch/shared/information/video-alert.component.html b/client/src/app/+videos/+video-watch/shared/information/video-alert.component.html index e2dd44bf7..33b5a47a0 100644 --- a/client/src/app/+videos/+video-watch/shared/information/video-alert.component.html +++ b/client/src/app/+videos/+video-watch/shared/information/video-alert.component.html @@ -24,5 +24,5 @@
This video is blocked.
- {{ video.blockedReason }} + {{ video.blacklistedReason }}
diff --git a/client/src/app/+videos/video-list/videos-list-common-page.component.ts b/client/src/app/+videos/video-list/videos-list-common-page.component.ts index ba64d4fec..d03b09610 100644 --- a/client/src/app/+videos/video-list/videos-list-common-page.component.ts +++ b/client/src/app/+videos/video-list/videos-list-common-page.component.ts @@ -85,7 +85,7 @@ export class VideosListCommonPageComponent implements OnInit, OnDestroy, Disable getSyndicationItems (filters: VideoFilters) { const result = filters.toVideosAPIObject() - return this.videoService.getVideoFeedUrls(result.sort, result.filter) + return this.videoService.getVideoFeedUrls(result.sort, result.isLocal) } onFiltersChanged (filters: VideoFilters) { 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 { ContainerMarkupData, EmbedMarkupData, PlaylistMiniatureMarkupData, - VideoFilter, VideoMiniatureMarkupData, VideosListMarkupData } from '@shared/models' @@ -193,7 +192,7 @@ export class CustomMarkupService { isLive: this.buildBoolean(data.isLive), - filter: this.buildBoolean(data.onlyLocal) ? 'local' as VideoFilter : undefined + isLocal: this.buildBoolean(data.onlyLocal) ? true : undefined } 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 @@ import { finalize } from 'rxjs/operators' import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { AuthService, Notifier } from '@app/core' -import { VideoFilter, VideoSortField } from '@shared/models' +import { VideoSortField } from '@shared/models' import { Video, VideoService } from '../../shared-main' import { MiniatureDisplayOptions } from '../../shared-video-miniature' import { CustomMarkupComponent } from './shared' @@ -21,7 +21,7 @@ export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit @Input() languageOneOf: string[] @Input() count: number @Input() onlyDisplayTitle: boolean - @Input() filter: VideoFilter + @Input() isLocal: boolean @Input() isLive: boolean @Input() maxRows: number @Input() channelHandle: string @@ -86,7 +86,7 @@ export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit }, categoryOneOf: this.categoryOneOf, languageOneOf: this.languageOneOf, - filter: this.filter, + isLocal: this.isLocal, isLive: this.isLive, sort: this.sort as VideoSortField, 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 { waitTranscoding?: boolean state?: VideoConstant scheduledUpdate?: VideoScheduleUpdate + blacklisted?: boolean - blockedReason?: string + blacklistedReason?: string + + blockedOwner?: boolean + blockedServer?: boolean account: { id: number @@ -163,7 +167,10 @@ export class Video implements VideoServerModel { if (this.state) this.state.label = peertubeTranslate(this.state.label, translations) this.blacklisted = hash.blacklisted - this.blockedReason = hash.blacklistedReason + this.blacklistedReason = hash.blacklistedReason + + this.blockedOwner = hash.blockedOwner + this.blockedServer = hash.blockedServer this.userHistory = hash.userHistory 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 { VideoConstant, VideoDetails as VideoDetailsServerModel, VideoFileMetadata, - VideoFilter, + VideoInclude, VideoPrivacy, VideoSortField, VideoUpdate @@ -34,11 +34,13 @@ import { Video } from './video.model' export type CommonVideoParams = { videoPagination?: ComponentPaginationLight sort: VideoSortField | SortMeta - filter?: VideoFilter + include?: VideoInclude + isLocal?: boolean categoryOneOf?: number[] languageOneOf?: string[] isLive?: boolean skipCount?: boolean + // FIXME: remove? nsfwPolicy?: NSFWPolicyType nsfw?: BooleanBothQuery @@ -202,12 +204,14 @@ export class VideoService { } getAdminVideos ( - parameters: Omit & { pagination: RestPagination, search?: string } + parameters: CommonVideoParams & { pagination: RestPagination, search?: string } ): Observable> { const { pagination, search } = parameters + const include = VideoInclude.BLACKLISTED | VideoInclude.BLOCKED_OWNER | VideoInclude.HIDDEN_PRIVACY | VideoInclude.NOT_PUBLISHED_STATE + let params = new HttpParams() - params = this.buildCommonVideosParams({ params, ...parameters }) + params = this.buildCommonVideosParams({ params, include, ...parameters }) params = params.set('start', pagination.start.toString()) .set('count', pagination.count.toString()) @@ -216,8 +220,6 @@ export class VideoService { params = this.buildAdminParamsFromSearch(search, params) } - if (!params.has('filter')) params = params.set('filter', 'all') - return this.authHttp .get>(VideoService.BASE_VIDEO_URL, { params }) .pipe( @@ -266,10 +268,10 @@ export class VideoService { return feeds } - getVideoFeedUrls (sort: VideoSortField, filter?: VideoFilter, categoryOneOf?: number[]) { + getVideoFeedUrls (sort: VideoSortField, isLocal: boolean, categoryOneOf?: number[]) { let params = this.restService.addRestGetParams(new HttpParams(), undefined, sort) - if (filter) params = params.set('filter', filter) + if (isLocal) params = params.set('isLocal', isLocal) if (categoryOneOf) { for (const c of categoryOneOf) { @@ -425,7 +427,8 @@ export class VideoService { params, videoPagination, sort, - filter, + isLocal, + include, categoryOneOf, languageOneOf, skipCount, @@ -440,9 +443,10 @@ export class VideoService { let newParams = this.restService.addRestGetParams(params, pagination, sort) - if (filter) newParams = newParams.set('filter', filter) if (skipCount) newParams = newParams.set('skipCount', skipCount + '') + if (isLocal) newParams = newParams.set('isLocal', isLocal) + if (include) newParams = newParams.set('include', include) if (isLive) newParams = newParams.set('isLive', isLive) if (nsfw) newParams = newParams.set('nsfw', nsfw) if (nsfwPolicy) newParams = newParams.set('nsfw', this.nsfwPolicyToParam(nsfwPolicy)) @@ -454,13 +458,9 @@ export class VideoService { private buildAdminParamsFromSearch (search: string, params: HttpParams) { const filters = this.restService.parseQueryStringFilter(search, { - filter: { - prefix: 'local:', - handler: v => { - if (v === 'true') return 'all-local' - - return 'all' - } + isLocal: { + prefix: 'isLocal:', + isBoolean: true } }) 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 { this.hide() this.video.blacklisted = true - this.video.blockedReason = reason + this.video.blacklistedReason = reason this.videoBlocked.emit() }, 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 { this.notifier.success($localize`Video ${this.video.name} unblocked.`) this.video.blacklisted = false - this.video.blockedReason = null + this.video.blacklistedReason = null this.videoUnblocked.emit() }, 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 @@ import { intoArray, toBoolean } from '@app/helpers' import { AttributesOnly } from '@shared/core-utils' -import { BooleanBothQuery, NSFWPolicyType, VideoFilter, VideoSortField } from '@shared/models' +import { BooleanBothQuery, NSFWPolicyType, VideoInclude, VideoSortField } from '@shared/models' type VideoFiltersKeys = { [ id in keyof AttributesOnly ]: any @@ -196,14 +196,15 @@ export class VideoFilters { } toVideosAPIObject () { - let filter: VideoFilter - - if (this.scope === 'local' && this.allVideos) { - filter = 'all-local' - } else if (this.scope === 'federated' && this.allVideos) { - filter = 'all' - } else if (this.scope === 'local') { - filter = 'local' + let isLocal: boolean + let include: VideoInclude + + if (this.scope === 'local') { + isLocal = true + } + + if (this.allVideos) { + include = VideoInclude.NOT_PUBLISHED_STATE | VideoInclude.HIDDEN_PRIVACY } let isLive: boolean @@ -216,7 +217,8 @@ export class VideoFilters { languageOneOf: this.languageOneOf, categoryOneOf: this.categoryOneOf, search: this.search, - filter, + isLocal, + include, isLive } } 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 @@
Blocked - {{ video.blockedReason }} + {{ video.blacklistedReason }}
-- cgit v1.2.3