X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fshared-abuse-list%2Fabuse-list-table.component.ts;h=07b9dddba01335b3958322bc7014b3de348959f7;hb=718873964490d1aa31b0e99852002165637e4b9e;hp=20be94d6e4e81a869cad50ebf257b55dd9c79384;hpb=5d666c0eb25a1b665caa46c4210c1dc2a6b5b333;p=github%2FChocobozzz%2FPeerTube.git 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 20be94d6e..07b9dddba 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 @@ -3,14 +3,15 @@ import truncate from 'lodash-es/truncate' import { SortMeta } from 'primeng/api' import { buildVideoLink, buildVideoOrPlaylistEmbed } from 'src/assets/player/utils' import { environment } from 'src/environments/environment' -import { AfterViewInit, Component, Input, OnInit, ViewChild } from '@angular/core' +import { Component, Input, OnInit, ViewChild } 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 } from '@app/core' import { Account, Actor, DropdownAction, Video, VideoService } from '@app/shared/shared-main' import { AbuseService, BlocklistService, VideoBlockService } from '@app/shared/shared-moderation' import { VideoCommentService } from '@app/shared/shared-video-comment' import { AbuseState, AdminAbuse } from '@shared/models' +import { AdvancedInputFilter } from '../shared-forms' import { AbuseMessageModalComponent } from './abuse-message-modal.component' import { ModerationCommentModalComponent } from './moderation-comment-modal.component' import { ProcessedAbuse } from './processed-abuse.model' @@ -22,9 +23,8 @@ const logger = debug('peertube:moderation:AbuseListTableComponent') templateUrl: './abuse-list-table.component.html', styleUrls: [ '../shared-moderation/moderation.scss', './abuse-list-table.component.scss' ] }) -export class AbuseListTableComponent extends RestTable implements OnInit, AfterViewInit { +export class AbuseListTableComponent extends RestTable implements OnInit { @Input() viewType: 'admin' | 'user' - @Input() baseRoute: string @ViewChild('abuseMessagesModal', { static: true }) abuseMessagesModal: AbuseMessageModalComponent @ViewChild('moderationCommentModal', { static: true }) moderationCommentModal: ModerationCommentModalComponent @@ -36,7 +36,32 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV abuseActions: DropdownAction[][] = [] + 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` + } + ] + constructor ( + protected route: ActivatedRoute, + protected router: Router, private notifier: Notifier, private abuseService: AbuseService, private blocklistService: BlocklistService, @@ -45,9 +70,7 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV private videoBlocklistService: VideoBlockService, private confirmService: ConfirmService, private markdownRenderer: MarkdownService, - private sanitizer: DomSanitizer, - private route: ActivatedRoute, - private router: Router + private sanitizer: DomSanitizer ) { super() } @@ -66,20 +89,6 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV ] this.initialize() - - this.route.queryParams - .subscribe(params => { - this.search = params.search || '' - - logger('On URL change (search: %s).', this.search) - - this.setTableFilter(this.search) - this.loadData() - }) - } - - ngAfterViewInit () { - if (this.search) this.setTableFilter(this.search) } isAdminView () { @@ -95,29 +104,9 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV } onModerationCommentUpdated () { - this.loadData() - } - - /* Table filter functions */ - onAbuseSearch (event: Event) { - this.onSearch(event) - this.setQueryParams((event.target as HTMLInputElement).value) - } - - setQueryParams (search: string) { - const queryParams: Params = {} - if (search) Object.assign(queryParams, { search }) - - this.router.navigate([ this.baseRoute ], { queryParams }) + this.reloadData() } - resetTableFilter () { - this.setTableFilter('') - this.setQueryParams('') - this.resetSearch() - } - /* END Table filter functions */ - isAbuseAccepted (abuse: AdminAbuse) { return abuse.state.id === AbuseState.ACCEPTED } @@ -135,25 +124,22 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV } getAccountUrl (abuse: ProcessedAbuse) { - return '/accounts/' + abuse.flaggedAccount.nameWithHost + return '/a/' + abuse.flaggedAccount.nameWithHost } getVideoEmbed (abuse: AdminAbuse) { return buildVideoOrPlaylistEmbed( buildVideoLink({ - baseUrl: `${environment.embedUrl}/videos/embed/${abuse.video.uuid}`, + baseUrl: `${environment.originServerUrl}/videos/embed/${abuse.video.uuid}`, title: false, warningTitle: false, - startTime: abuse.startAt, - stopTime: abuse.endAt - }) + startTime: abuse.video.startAt, + stopTime: abuse.video.endAt + }), + abuse.video.name ) } - switchToDefaultAvatar ($event: Event) { - ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL() - } - async removeAbuse (abuse: AdminAbuse) { const res = await this.confirmService.confirm($localize`Do you really want to delete this abuse report?`, $localize`Delete`) if (res === false) return @@ -161,7 +147,7 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV this.abuseService.removeAbuse(abuse).subscribe( () => { this.notifier.success($localize`Abuse deleted.`) - this.loadData() + this.reloadData() }, err => this.notifier.error(err.message) @@ -171,7 +157,7 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV updateAbuseState (abuse: AdminAbuse, state: AbuseState) { this.abuseService.updateAbuse(abuse, { state }) .subscribe( - () => this.loadData(), + () => this.reloadData(), err => this.notifier.error(err.message) ) @@ -198,7 +184,7 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV return Actor.IS_LOCAL(abuse.reporterAccount.host) } - protected loadData () { + protected reloadData () { logger('Loading data.') const options = {