diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-04-19 23:41:05 +0200 |
---|---|---|
committer | Rigel Kent <par@rigelk.eu> | 2020-05-01 16:41:02 +0200 |
commit | 36004aa7b0de5cb69a452090770221b192a78eb8 (patch) | |
tree | e47af3699c686244891659fa2a86b8f3554de197 | |
parent | 042daa7072c0168b876db2badfc838dba7ac2284 (diff) | |
download | PeerTube-36004aa7b0de5cb69a452090770221b192a78eb8.tar.gz PeerTube-36004aa7b0de5cb69a452090770221b192a78eb8.tar.zst PeerTube-36004aa7b0de5cb69a452090770221b192a78eb8.zip |
Support search param in URL for video abuses
3 files changed, 27 insertions, 10 deletions
diff --git a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html index c15e98942..9e084cb73 100644 --- a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html +++ b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html | |||
@@ -1,5 +1,5 @@ | |||
1 | <p-table | 1 | <p-table |
2 | [value]="videoAbuses" [lazy]="true" [paginator]="true" [totalRecords]="totalRecords" [rows]="rowsPerPage" [rowsPerPageOptions]="rowsPerPageOptions" | 2 | [value]="videoAbuses" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [rowsPerPageOptions]="rowsPerPageOptions" |
3 | [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" dataKey="id" [resizableColumns]="true" | 3 | [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" dataKey="id" [resizableColumns]="true" |
4 | [showCurrentPageReport]="true" i18n-currentPageReportTemplate | 4 | [showCurrentPageReport]="true" i18n-currentPageReportTemplate |
5 | currentPageReportTemplate="Showing {{'{first}'}} to {{'{last}'}} of {{'{totalRecords}'}} reports" | 5 | currentPageReportTemplate="Showing {{'{first}'}} to {{'{last}'}} of {{'{totalRecords}'}} reports" |
@@ -123,7 +123,7 @@ | |||
123 | <span class="text-muted">{{ createByString(videoAbuse.reporterAccount) }}</span> | 123 | <span class="text-muted">{{ createByString(videoAbuse.reporterAccount) }}</span> |
124 | </div> | 124 | </div> |
125 | </div> | 125 | </div> |
126 | <a routerLink="/admin/moderation/video-abuses/list" class="ml-auto text-muted video-details-links" i18n> | 126 | <a [routerLink]="[ '/admin/moderation/video-abuses/list' ]" [queryParams]="{ 'search': videoAbuse.reporterAccount.displayName }" class="ml-auto text-muted video-details-links" i18n> |
127 | {videoAbuse.countReportsForReporter, plural, =1 {1 report} other {{{ videoAbuse.countReportsForReporter }} reports}}<span class="ml-1 glyphicon glyphicon-flag"></span> | 127 | {videoAbuse.countReportsForReporter, plural, =1 {1 report} other {{{ videoAbuse.countReportsForReporter }} reports}}<span class="ml-1 glyphicon glyphicon-flag"></span> |
128 | </a> | 128 | </a> |
129 | </span> | 129 | </span> |
@@ -142,7 +142,7 @@ | |||
142 | <span class="text-muted">{{ videoAbuse.video.channel.ownerAccount ? createByString(videoAbuse.video.channel.ownerAccount) : '' }}</span> | 142 | <span class="text-muted">{{ videoAbuse.video.channel.ownerAccount ? createByString(videoAbuse.video.channel.ownerAccount) : '' }}</span> |
143 | </div> | 143 | </div> |
144 | </div> | 144 | </div> |
145 | <a routerLink="/admin/moderation/video-abuses/list" class="ml-auto text-muted video-details-links" *ngIf="!videoAbuse.video.deleted" i18n> | 145 | <a [routerLink]="[ '/admin/moderation/video-abuses/list' ]" [queryParams]="{ 'search': videoAbuse.video.channel.ownerAccount.displayName }" class="ml-auto text-muted video-details-links" *ngIf="!videoAbuse.video.deleted" i18n> |
146 | {videoAbuse.countReportsForReportee, plural, =1 {1 report} other {{{ videoAbuse.countReportsForReportee }} reports}}<span class="ml-1 glyphicon glyphicon-flag"></span> | 146 | {videoAbuse.countReportsForReportee, plural, =1 {1 report} other {{{ videoAbuse.countReportsForReportee }} reports}}<span class="ml-1 glyphicon glyphicon-flag"></span> |
147 | </a> | 147 | </a> |
148 | </span> | 148 | </span> |
diff --git a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts index 0c727ae90..2ece5dcc1 100644 --- a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts +++ b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Component, OnInit, ViewChild } from '@angular/core' | 1 | import { Component, OnInit, ViewChild, AfterViewInit } from '@angular/core' |
2 | import { Account } from '@app/shared/account/account.model' | 2 | import { Account } from '@app/shared/account/account.model' |
3 | import { Notifier } from '@app/core' | 3 | import { Notifier } from '@app/core' |
4 | import { SortMeta } from 'primeng/api' | 4 | import { SortMeta } from 'primeng/api' |
@@ -17,14 +17,14 @@ import { DomSanitizer } from '@angular/platform-browser' | |||
17 | import { BlocklistService } from '@app/shared/blocklist' | 17 | import { BlocklistService } from '@app/shared/blocklist' |
18 | import { VideoService } from '@app/shared/video/video.service' | 18 | import { VideoService } from '@app/shared/video/video.service' |
19 | import { ActivatedRoute } from '@angular/router' | 19 | import { ActivatedRoute } from '@angular/router' |
20 | import { first } from 'rxjs/operators' | 20 | import { filter } from 'rxjs/operators' |
21 | 21 | ||
22 | @Component({ | 22 | @Component({ |
23 | selector: 'my-video-abuse-list', | 23 | selector: 'my-video-abuse-list', |
24 | templateUrl: './video-abuse-list.component.html', | 24 | templateUrl: './video-abuse-list.component.html', |
25 | styleUrls: [ '../moderation.component.scss', './video-abuse-list.component.scss' ] | 25 | styleUrls: [ '../moderation.component.scss', './video-abuse-list.component.scss' ] |
26 | }) | 26 | }) |
27 | export class VideoAbuseListComponent extends RestTable implements OnInit { | 27 | export class VideoAbuseListComponent extends RestTable implements OnInit, AfterViewInit { |
28 | @ViewChild('moderationCommentModal', { static: true }) moderationCommentModal: ModerationCommentModalComponent | 28 | @ViewChild('moderationCommentModal', { static: true }) moderationCommentModal: ModerationCommentModalComponent |
29 | 29 | ||
30 | videoAbuses: (VideoAbuse & { moderationCommentHtml?: string, reasonHtml?: string })[] = [] | 30 | videoAbuses: (VideoAbuse & { moderationCommentHtml?: string, reasonHtml?: string })[] = [] |
@@ -190,8 +190,16 @@ export class VideoAbuseListComponent extends RestTable implements OnInit { | |||
190 | this.initialize() | 190 | this.initialize() |
191 | 191 | ||
192 | this.route.queryParams | 192 | this.route.queryParams |
193 | .pipe(first(params => params.search !== undefined && params.search !== null)) | 193 | .pipe(filter(params => params.search !== undefined && params.search !== null)) |
194 | .subscribe(params => this.search = params.search) | 194 | .subscribe(params => { |
195 | this.search = params.search | ||
196 | this.setTableFilter(params.search) | ||
197 | this.loadData() | ||
198 | }) | ||
199 | } | ||
200 | |||
201 | ngAfterViewInit () { | ||
202 | this.setTableFilter(this.search) | ||
195 | } | 203 | } |
196 | 204 | ||
197 | getIdentifier () { | 205 | getIdentifier () { |
@@ -210,6 +218,11 @@ export class VideoAbuseListComponent extends RestTable implements OnInit { | |||
210 | return Account.CREATE_BY_STRING(account.name, account.host) | 218 | return Account.CREATE_BY_STRING(account.name, account.host) |
211 | } | 219 | } |
212 | 220 | ||
221 | setTableFilter (filter: string) { | ||
222 | const filterInput = document.getElementById('table-filter') as HTMLInputElement | ||
223 | if (filterInput) filterInput.value = filter | ||
224 | } | ||
225 | |||
213 | isVideoAbuseAccepted (videoAbuse: VideoAbuse) { | 226 | isVideoAbuseAccepted (videoAbuse: VideoAbuse) { |
214 | return videoAbuse.state.id === VideoAbuseState.ACCEPTED | 227 | return videoAbuse.state.id === VideoAbuseState.ACCEPTED |
215 | } | 228 | } |
diff --git a/client/src/app/header/search-typeahead.component.ts b/client/src/app/header/search-typeahead.component.ts index d0350368d..2bf1072f4 100644 --- a/client/src/app/header/search-typeahead.component.ts +++ b/client/src/app/header/search-typeahead.component.ts | |||
@@ -36,7 +36,7 @@ export class SearchTypeaheadComponent implements OnInit, OnDestroy { | |||
36 | 36 | ||
37 | ngOnInit () { | 37 | ngOnInit () { |
38 | this.route.queryParams | 38 | this.route.queryParams |
39 | .pipe(first(params => params.search !== undefined && params.search !== null)) | 39 | .pipe(first(params => this.isOnSearch() && params.search !== undefined && params.search !== null)) |
40 | .subscribe(params => this.search = params.search) | 40 | .subscribe(params => this.search = params.search) |
41 | this.serverService.getConfig() | 41 | this.serverService.getConfig() |
42 | .subscribe(config => this.serverConfig = config) | 42 | .subscribe(config => this.serverConfig = config) |
@@ -146,11 +146,15 @@ export class SearchTypeaheadComponent implements OnInit, OnDestroy { | |||
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | isOnSearch () { | ||
150 | return window.location.pathname === '/search' | ||
151 | } | ||
152 | |||
149 | doSearch () { | 153 | doSearch () { |
150 | this.newSearch = false | 154 | this.newSearch = false |
151 | const queryParams: Params = {} | 155 | const queryParams: Params = {} |
152 | 156 | ||
153 | if (window.location.pathname === '/search' && this.route.snapshot.queryParams) { | 157 | if (this.isOnSearch() && this.route.snapshot.queryParams) { |
154 | Object.assign(queryParams, this.route.snapshot.queryParams) | 158 | Object.assign(queryParams, this.route.snapshot.queryParams) |
155 | } | 159 | } |
156 | 160 | ||