diff options
author | Chocobozzz <me@florianbigard.com> | 2018-10-08 15:51:38 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-08 15:55:32 +0200 |
commit | 24b9417cec5cc785a57b2fe169a1ae88b88801a4 (patch) | |
tree | 42adf8fb4355c96fe2585ebd6312563e8182d682 /client/src/app/shared | |
parent | 791645e620fb98c6e7c32271d91d91ff7e41b892 (diff) | |
download | PeerTube-24b9417cec5cc785a57b2fe169a1ae88b88801a4.tar.gz PeerTube-24b9417cec5cc785a57b2fe169a1ae88b88801a4.tar.zst PeerTube-24b9417cec5cc785a57b2fe169a1ae88b88801a4.zip |
Add users search filter
Diffstat (limited to 'client/src/app/shared')
4 files changed, 31 insertions, 3 deletions
diff --git a/client/src/app/shared/moderation/user-moderation-dropdown.component.html b/client/src/app/shared/moderation/user-moderation-dropdown.component.html index 2c477ab23..01db7cd4a 100644 --- a/client/src/app/shared/moderation/user-moderation-dropdown.component.html +++ b/client/src/app/shared/moderation/user-moderation-dropdown.component.html | |||
@@ -1,5 +1,5 @@ | |||
1 | <ng-container *ngIf="user && userActions.length !== 0"> | 1 | <ng-container *ngIf="user && userActions.length !== 0"> |
2 | <my-user-ban-modal #userBanModal (userBanned)="onUserBanned()"></my-user-ban-modal> | 2 | <my-user-ban-modal #userBanModal (userBanned)="onUserBanned()"></my-user-ban-modal> |
3 | 3 | ||
4 | <my-action-dropdown [actions]="userActions" [entry]="user" [buttonSize]="buttonSize"></my-action-dropdown> | 4 | <my-action-dropdown [actions]="userActions" [entry]="user" [buttonSize]="buttonSize" [placement]="placement"></my-action-dropdown> |
5 | </ng-container> \ No newline at end of file | 5 | </ng-container> \ No newline at end of file |
diff --git a/client/src/app/shared/moderation/user-moderation-dropdown.component.ts b/client/src/app/shared/moderation/user-moderation-dropdown.component.ts index 174e9f024..105c99d8b 100644 --- a/client/src/app/shared/moderation/user-moderation-dropdown.component.ts +++ b/client/src/app/shared/moderation/user-moderation-dropdown.component.ts | |||
@@ -17,6 +17,7 @@ export class UserModerationDropdownComponent implements OnInit { | |||
17 | 17 | ||
18 | @Input() user: User | 18 | @Input() user: User |
19 | @Input() buttonSize: 'normal' | 'small' = 'normal' | 19 | @Input() buttonSize: 'normal' | 'small' = 'normal' |
20 | @Input() placement = 'left' | ||
20 | 21 | ||
21 | @Output() userChanged = new EventEmitter() | 22 | @Output() userChanged = new EventEmitter() |
22 | @Output() userDeleted = new EventEmitter() | 23 | @Output() userDeleted = new EventEmitter() |
diff --git a/client/src/app/shared/rest/rest-table.ts b/client/src/app/shared/rest/rest-table.ts index fe1a91d2d..26748f245 100644 --- a/client/src/app/shared/rest/rest-table.ts +++ b/client/src/app/shared/rest/rest-table.ts | |||
@@ -1,8 +1,9 @@ | |||
1 | import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' | 1 | import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' |
2 | import { LazyLoadEvent } from 'primeng/components/common/lazyloadevent' | 2 | import { LazyLoadEvent } from 'primeng/components/common/lazyloadevent' |
3 | import { SortMeta } from 'primeng/components/common/sortmeta' | 3 | import { SortMeta } from 'primeng/components/common/sortmeta' |
4 | |||
5 | import { RestPagination } from './rest-pagination' | 4 | import { RestPagination } from './rest-pagination' |
5 | import { Subject } from 'rxjs' | ||
6 | import { debounceTime, distinctUntilChanged } from 'rxjs/operators' | ||
6 | 7 | ||
7 | export abstract class RestTable { | 8 | export abstract class RestTable { |
8 | 9 | ||
@@ -11,10 +12,17 @@ export abstract class RestTable { | |||
11 | abstract sort: SortMeta | 12 | abstract sort: SortMeta |
12 | abstract pagination: RestPagination | 13 | abstract pagination: RestPagination |
13 | 14 | ||
15 | protected search: string | ||
16 | private searchStream: Subject<string> | ||
14 | private sortLocalStorageKey = 'rest-table-sort-' + this.constructor.name | 17 | private sortLocalStorageKey = 'rest-table-sort-' + this.constructor.name |
15 | 18 | ||
16 | protected abstract loadData (): void | 19 | protected abstract loadData (): void |
17 | 20 | ||
21 | initialize () { | ||
22 | this.loadSort() | ||
23 | this.initSearch() | ||
24 | } | ||
25 | |||
18 | loadSort () { | 26 | loadSort () { |
19 | const result = peertubeLocalStorage.getItem(this.sortLocalStorageKey) | 27 | const result = peertubeLocalStorage.getItem(this.sortLocalStorageKey) |
20 | 28 | ||
@@ -46,4 +54,21 @@ export abstract class RestTable { | |||
46 | peertubeLocalStorage.setItem(this.sortLocalStorageKey, JSON.stringify(this.sort)) | 54 | peertubeLocalStorage.setItem(this.sortLocalStorageKey, JSON.stringify(this.sort)) |
47 | } | 55 | } |
48 | 56 | ||
57 | initSearch () { | ||
58 | this.searchStream = new Subject() | ||
59 | |||
60 | this.searchStream | ||
61 | .pipe( | ||
62 | debounceTime(400), | ||
63 | distinctUntilChanged() | ||
64 | ) | ||
65 | .subscribe(search => { | ||
66 | this.search = search | ||
67 | this.loadData() | ||
68 | }) | ||
69 | } | ||
70 | |||
71 | onSearch (search: string) { | ||
72 | this.searchStream.next(search) | ||
73 | } | ||
49 | } | 74 | } |
diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts index 0eb3870b0..27a81f0a2 100644 --- a/client/src/app/shared/users/user.service.ts +++ b/client/src/app/shared/users/user.service.ts | |||
@@ -158,10 +158,12 @@ export class UserService { | |||
158 | .pipe(catchError(err => this.restExtractor.handleError(err))) | 158 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
159 | } | 159 | } |
160 | 160 | ||
161 | getUsers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<User>> { | 161 | getUsers (pagination: RestPagination, sort: SortMeta, search?: string): Observable<ResultList<User>> { |
162 | let params = new HttpParams() | 162 | let params = new HttpParams() |
163 | params = this.restService.addRestGetParams(params, pagination, sort) | 163 | params = this.restService.addRestGetParams(params, pagination, sort) |
164 | 164 | ||
165 | if (search) params = params.append('search', search) | ||
166 | |||
165 | return this.authHttp.get<ResultList<User>>(UserService.BASE_USERS_URL, { params }) | 167 | return this.authHttp.get<ResultList<User>>(UserService.BASE_USERS_URL, { params }) |
166 | .pipe( | 168 | .pipe( |
167 | map(res => this.restExtractor.convertResultListDateToHuman(res)), | 169 | map(res => this.restExtractor.convertResultListDateToHuman(res)), |