From 978c87e7f58b6673fe60f04f1767bc9e02ea4936 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 20 Oct 2021 09:05:43 +0200 Subject: Add channel filters for my videos/followers --- .../video-block-list/video-block-list.component.ts | 17 +++++--- .../video-comment-list.component.ts | 17 +++++--- .../+admin/users/user-list/user-list.component.ts | 9 ++++- .../my-follows/my-followers.component.ts | 11 +++++- .../+my-library/my-videos/my-videos.component.ts | 46 ++++++++++++++++++---- .../abuse-list-table.component.ts | 41 ++++++++++--------- .../advanced-input-filter.component.html | 10 +++-- .../advanced-input-filter.component.ts | 8 +++- .../app/shared/shared-main/video/video.service.ts | 20 +++++++++- 9 files changed, 130 insertions(+), 49 deletions(-) (limited to 'client') diff --git a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts index 3edcb1c63..7baf34ca2 100644 --- a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts +++ b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts @@ -28,12 +28,17 @@ export class VideoBlockListComponent extends RestTable implements OnInit { inputFilters: AdvancedInputFilter[] = [ { - queryParams: { search: 'type:auto' }, - label: $localize`Automatic blocks` - }, - { - queryParams: { search: 'type:manual' }, - label: $localize`Manual blocks` + title: $localize`Advanced filters`, + children: [ + { + queryParams: { search: 'type:auto' }, + label: $localize`Automatic blocks` + }, + { + queryParams: { search: 'type:manual' }, + label: $localize`Manual blocks` + } + ] } ] diff --git a/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts b/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts index c09ce7293..a60b228af 100644 --- a/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts +++ b/client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts @@ -44,12 +44,17 @@ export class VideoCommentListComponent extends RestTable implements OnInit { inputFilters: AdvancedInputFilter[] = [ { - queryParams: { search: 'local:true' }, - label: $localize`Local comments` - }, - { - queryParams: { search: 'local:false' }, - label: $localize`Remote comments` + title: $localize`Advanced filters`, + children: [ + { + queryParams: { search: 'local:true' }, + label: $localize`Local comments` + }, + { + queryParams: { search: 'local:false' }, + label: $localize`Remote comments` + } + ] } ] diff --git a/client/src/app/+admin/users/user-list/user-list.component.ts b/client/src/app/+admin/users/user-list/user-list.component.ts index 1030759df..548e6e80f 100644 --- a/client/src/app/+admin/users/user-list/user-list.component.ts +++ b/client/src/app/+admin/users/user-list/user-list.component.ts @@ -36,8 +36,13 @@ export class UserListComponent extends RestTable implements OnInit { inputFilters: AdvancedInputFilter[] = [ { - queryParams: { search: 'banned:true' }, - label: $localize`Banned users` + title: $localize`Advanced filters`, + children: [ + { + queryParams: { search: 'banned:true' }, + label: $localize`Banned users` + } + ] } ] diff --git a/client/src/app/+my-library/my-follows/my-followers.component.ts b/client/src/app/+my-library/my-follows/my-followers.component.ts index 413d524df..4a72b983f 100644 --- a/client/src/app/+my-library/my-follows/my-followers.component.ts +++ b/client/src/app/+my-library/my-follows/my-followers.component.ts @@ -37,12 +37,19 @@ export class MyFollowersComponent implements OnInit { } this.auth.userInformationLoaded.subscribe(() => { - this.inputFilters = this.auth.getUser().videoChannels.map(c => { + const channelFilters = this.auth.getUser().videoChannels.map(c => { return { queryParams: { search: 'channel:' + c.name }, - label: $localize`Followers of ${c.name}` + label: c.name } }) + + this.inputFilters = [ + { + title: $localize`Channel filters`, + children: channelFilters + } + ] }) } diff --git a/client/src/app/+my-library/my-videos/my-videos.component.ts b/client/src/app/+my-library/my-videos/my-videos.component.ts index b1f3baf80..a117d0915 100644 --- a/client/src/app/+my-library/my-videos/my-videos.component.ts +++ b/client/src/app/+my-library/my-videos/my-videos.component.ts @@ -9,7 +9,7 @@ import { AdvancedInputFilter } from '@app/shared/shared-forms' import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' import { LiveStreamInformationComponent } from '@app/shared/shared-video-live' import { MiniatureDisplayOptions, SelectionType, VideosSelectionComponent } from '@app/shared/shared-video-miniature' -import { VideoSortField } from '@shared/models' +import { VideoChannel, VideoSortField } from '@shared/models' import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.component' @Component({ @@ -47,16 +47,12 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook { user: User - inputFilters: AdvancedInputFilter[] = [ - { - queryParams: { search: 'isLive:true' }, - label: $localize`Only live videos` - } - ] + inputFilters: AdvancedInputFilter[] disabled = false private search: string + private userChannels: VideoChannel[] = [] constructor ( protected router: Router, @@ -79,6 +75,35 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook { if (this.route.snapshot.queryParams['search']) { this.search = this.route.snapshot.queryParams['search'] } + + this.authService.userInformationLoaded.subscribe(() => { + this.user = this.authService.getUser() + this.userChannels = this.user.videoChannels + + const channelFilters = this.userChannels.map(c => { + return { + queryParams: { search: 'channel:' + c.name }, + label: c.name + } + }) + + this.inputFilters = [ + { + title: $localize`Advanced filters`, + children: [ + { + queryParams: { search: 'isLive:true' }, + label: $localize`Only live videos` + } + ] + }, + + { + title: $localize`Channel filters`, + children: channelFilters + } + ] + }) } onSearch (search: string) { @@ -105,7 +130,12 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook { getVideosObservable (page: number) { const newPagination = immutableAssign(this.pagination, { currentPage: page }) - return this.videoService.getMyVideos(newPagination, this.sort, this.search) + return this.videoService.getMyVideos({ + videoPagination: newPagination, + sort: this.sort, + userChannels: this.userChannels, + search: this.search + }) .pipe( tap(res => this.pagination.totalItems = res.total) ) diff --git a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts index 33e9fd8de..297993e39 100644 --- a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts +++ b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts @@ -39,24 +39,29 @@ export class AbuseListTableComponent extends RestTable implements OnInit { inputFilters: AdvancedInputFilter[] = [ { - queryParams: { search: 'state:pending' }, - label: $localize`Unsolved reports` - }, - { - queryParams: { search: 'state:accepted' }, - label: $localize`Accepted reports` - }, - { - queryParams: { search: 'state:rejected' }, - label: $localize`Refused reports` - }, - { - queryParams: { search: 'videoIs:blacklisted' }, - label: $localize`Reports with blocked videos` - }, - { - queryParams: { search: 'videoIs:deleted' }, - label: $localize`Reports with deleted videos` + title: $localize`Advanced filters`, + children: [ + { + queryParams: { search: 'state:pending' }, + label: $localize`Unsolved reports` + }, + { + queryParams: { search: 'state:accepted' }, + label: $localize`Accepted reports` + }, + { + queryParams: { search: 'state:rejected' }, + label: $localize`Refused reports` + }, + { + queryParams: { search: 'videoIs:blacklisted' }, + label: $localize`Reports with blocked videos` + }, + { + queryParams: { search: 'videoIs:deleted' }, + label: $localize`Reports with deleted videos` + } + ] } ] diff --git a/client/src/app/shared/shared-forms/advanced-input-filter.component.html b/client/src/app/shared/shared-forms/advanced-input-filter.component.html index 10d1296cf..c662b9bb6 100644 --- a/client/src/app/shared/shared-forms/advanced-input-filter.component.html +++ b/client/src/app/shared/shared-forms/advanced-input-filter.component.html @@ -5,11 +5,13 @@
- + + - - {{ filter.label }} - + + {{ filter.label }} + +
diff --git a/client/src/app/shared/shared-forms/advanced-input-filter.component.ts b/client/src/app/shared/shared-forms/advanced-input-filter.component.ts index 8315662b4..a12dddf7a 100644 --- a/client/src/app/shared/shared-forms/advanced-input-filter.component.ts +++ b/client/src/app/shared/shared-forms/advanced-input-filter.component.ts @@ -5,8 +5,12 @@ import { AfterViewInit, Component, EventEmitter, Input, OnInit, Output } from '@ import { ActivatedRoute, Params, Router } from '@angular/router' export type AdvancedInputFilter = { - label: string - queryParams: Params + title: string + + children: { + label: string + queryParams: Params + }[] } const logger = debug('peertube:AdvancedInputFilterComponent') 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 2f43f1b9d..7935569e7 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts @@ -13,6 +13,7 @@ import { UserVideoRateType, UserVideoRateUpdate, Video as VideoServerModel, + VideoChannel as VideoChannelServerModel, VideoConstant, VideoDetails as VideoDetailsServerModel, VideoFileMetadata, @@ -122,7 +123,14 @@ export class VideoService { .pipe(catchError(err => this.restExtractor.handleError(err))) } - getMyVideos (videoPagination: ComponentPaginationLight, sort: VideoSortField, search?: string): Observable> { + getMyVideos (options: { + videoPagination: ComponentPaginationLight + sort: VideoSortField + userChannels?: VideoChannelServerModel[] + search?: string + }): Observable> { + const { videoPagination, sort, userChannels = [], search } = options + const pagination = this.restService.componentToRestPagination(videoPagination) let params = new HttpParams() @@ -133,6 +141,16 @@ export class VideoService { isLive: { prefix: 'isLive:', isBoolean: true + }, + channelId: { + prefix: 'channel:', + handler: (name: string) => { + const channel = userChannels.find(c => c.name === name) + + if (channel) return channel.id + + return undefined + } } }) -- cgit v1.2.3