X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Badmin%2Fmoderation%2Fvideo-block-list%2Fvideo-block-list.component.ts;h=4fe5ec441d0770c2098de60c5b4a8b3af5a1712d;hb=15a7eafb892441957ba7dd6fcbf556086fe5b2b3;hp=82818547cd9e5badd9adf8d0aa7410bc3471390f;hpb=5ed46c1bce29affbe101f126d58657ab484bffe7;p=github%2FChocobozzz%2FPeerTube.git 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 82818547c..4fe5ec441 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 @@ -1,13 +1,15 @@ import { SortMeta } from 'primeng/api' import { switchMap } from 'rxjs/operators' -import { buildVideoLink, buildVideoOrPlaylistEmbed } from 'src/assets/player/utils' +import { buildVideoOrPlaylistEmbed } from 'src/assets/player/utils' import { environment } from 'src/environments/environment' -import { AfterViewInit, Component, OnInit } from '@angular/core' +import { Component, OnInit } from '@angular/core' import { DomSanitizer } from '@angular/platform-browser' -import { ActivatedRoute, Params, Router } from '@angular/router' +import { ActivatedRoute, Router } from '@angular/router' import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable, ServerService } from '@app/core' +import { AdvancedInputFilter } from '@app/shared/shared-forms' import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' import { VideoBlockService } from '@app/shared/shared-moderation' +import { buildVideoEmbedLink, decorateVideoLink } from '@shared/core-utils' import { VideoBlacklist, VideoBlacklistType } from '@shared/models' @Component({ @@ -15,7 +17,7 @@ import { VideoBlacklist, VideoBlacklistType } from '@shared/models' templateUrl: './video-block-list.component.html', styleUrls: [ '../../../shared/shared-moderation/moderation.scss', './video-block-list.component.scss' ] }) -export class VideoBlockListComponent extends RestTable implements OnInit, AfterViewInit { +export class VideoBlockListComponent extends RestTable implements OnInit { blocklist: (VideoBlacklist & { reasonHtml?: string, embedHtml?: string })[] = [] totalRecords = 0 sort: SortMeta = { field: 'createdAt', order: -1 } @@ -24,6 +26,17 @@ export class VideoBlockListComponent extends RestTable implements OnInit, AfterV videoBlocklistActions: DropdownAction[][] = [] + inputFilters: AdvancedInputFilter[] = [ + { + queryParams: { 'search': 'type:auto' }, + label: $localize`Automatic blocks` + }, + { + queryParams: { 'search': 'type:manual' }, + label: $localize`Manual blocks` + } + ] + constructor ( protected route: ActivatedRoute, protected router: Router, @@ -52,7 +65,7 @@ export class VideoBlockListComponent extends RestTable implements OnInit, AfterV ).subscribe( () => { this.notifier.success($localize`Video ${videoBlock.video.name} switched to manual block.`) - this.loadData() + this.reloadData() }, err => this.notifier.error(err.message) @@ -95,53 +108,22 @@ export class VideoBlockListComponent extends RestTable implements OnInit, AfterV } ngOnInit () { - this.serverService.getConfig() - .subscribe(config => { - // don't filter if auto-blacklist is not enabled as this will be the only list - if (config.autoBlacklist.videos.ofUsers.enabled) { - this.blocklistTypeFilter = VideoBlacklistType.MANUAL - } - }) - - this.initialize() - this.listenToSearchChange() - } - - ngAfterViewInit () { - if (this.search) this.setTableFilter(this.search) - } + const serverConfig = this.serverService.getHTMLConfig() - /* Table filter functions */ - onBlockSearch (event: Event) { - this.onSearch(event) - this.setQueryParams((event.target as HTMLInputElement).value) - } + // Don't filter if auto-blacklist is not enabled as this will be the only list + if (serverConfig.autoBlacklist.videos.ofUsers.enabled) { + this.blocklistTypeFilter = VideoBlacklistType.MANUAL + } - setQueryParams (search: string) { - const queryParams: Params = {} - if (search) Object.assign(queryParams, { search }) - this.router.navigate([ '/admin/moderation/video-blocks/list' ], { queryParams }) - } - - resetTableFilter () { - this.setTableFilter('') - this.setQueryParams('') - this.resetSearch() + this.initialize() } - /* END Table filter functions */ getIdentifier () { return 'VideoBlockListComponent' } getVideoUrl (videoBlock: VideoBlacklist) { - return Video.buildClientUrl(videoBlock.video.uuid) - } - - booleanToText (value: boolean) { - if (value === true) return $localize`yes` - - return $localize`no` + return Video.buildWatchUrl(videoBlock.video) } toHtml (text: string) { @@ -157,7 +139,7 @@ export class VideoBlockListComponent extends RestTable implements OnInit, AfterV this.videoBlocklistService.unblockVideo(entry.video.id).subscribe( () => { this.notifier.success($localize`Video ${entry.video.name} unblocked.`) - this.loadData() + this.reloadData() }, err => this.notifier.error(err.message) @@ -166,15 +148,17 @@ export class VideoBlockListComponent extends RestTable implements OnInit, AfterV getVideoEmbed (entry: VideoBlacklist) { return buildVideoOrPlaylistEmbed( - buildVideoLink({ - baseUrl: `${environment.embedUrl}/videos/embed/${entry.video.uuid}`, + decorateVideoLink({ + url: buildVideoEmbedLink(entry.video, environment.originServerUrl), + title: false, warningTitle: false - }) + }), + entry.video.name ) } - protected loadData () { + protected reloadData () { this.videoBlocklistService.listBlocks({ pagination: this.pagination, sort: this.sort,