From 8491293b02ed2ec53eb0fa128161ea0b08d3def9 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Thu, 2 Jul 2020 22:49:51 +0200 Subject: add blocked filter in users list to filter banned users fixes #2914 --- .../users/user-list/user-list.component.html | 29 +++++++++---- .../users/user-list/user-list.component.scss | 17 ++++++++ .../+admin/users/user-list/user-list.component.ts | 50 ++++++++++++++++++---- 3 files changed, 80 insertions(+), 16 deletions(-) (limited to 'client/src/app/+admin/users') diff --git a/client/src/app/+admin/users/user-list/user-list.component.html b/client/src/app/+admin/users/user-list/user-list.component.html index 27d4a5787..9580a3c8a 100644 --- a/client/src/app/+admin/users/user-list/user-list.component.html +++ b/client/src/app/+admin/users/user-list/user-list.component.html @@ -16,14 +16,27 @@ -
- - - Clear filters +
+
+
+
+ +
+ +
+ + Banned users +
+
+ + + Clear filters +
+ Create user @@ -70,7 +83,7 @@ alt="Avatar" >
- + {{ user.account.displayName }} diff --git a/client/src/app/+admin/users/user-list/user-list.component.scss b/client/src/app/+admin/users/user-list/user-list.component.scss index 697b2c11b..2b84dec75 100644 --- a/client/src/app/+admin/users/user-list/user-list.component.scss +++ b/client/src/app/+admin/users/user-list/user-list.component.scss @@ -17,6 +17,12 @@ tr.banned > td { font-weight: $font-semibold; } +.user-table-primary-text .glyphicon { + font-size: 80%; + color: gray; + margin-left: 0.1rem; +} + .caption { justify-content: space-between; @@ -33,3 +39,14 @@ p-tableCheckbox { .chip { @include chip; } + +.input-group { + @include peertube-input-group(300px); + input { + flex: 1; + } + + .dropdown-toggle::after { + margin-left: 0; + } +} 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 8f01c7d51..0b72b07c1 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 @@ -5,6 +5,7 @@ import { Actor, DropdownAction } from '@app/shared/shared-main' import { UserBanModalComponent } from '@app/shared/shared-moderation' import { I18n } from '@ngx-translate/i18n-polyfill' import { ServerConfig, User } from '@shared/models' +import { Params, Router, ActivatedRoute } from '@angular/router' @Component({ selector: 'my-user-list', @@ -30,6 +31,8 @@ export class UserListComponent extends RestTable implements OnInit { private serverService: ServerService, private userService: UserService, private auth: AuthService, + private route: ActivatedRoute, + private router: Router, private i18n: I18n ) { super() @@ -50,6 +53,14 @@ export class UserListComponent extends RestTable implements OnInit { this.initialize() + this.route.queryParams + .subscribe(params => { + this.search = params.search || '' + + this.setTableFilter(this.search) + this.loadData() + }) + this.bulkUserActions = [ [ { @@ -102,6 +113,26 @@ export class UserListComponent extends RestTable implements OnInit { this.loadData() } + /* Table filter functions */ + onUserSearch (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([ '/admin/users/list' ], { queryParams }) + } + + resetTableFilter () { + this.setTableFilter('') + this.setQueryParams('') + this.resetSearch() + } + /* END Table filter functions */ + switchToDefaultAvatar ($event: Event) { ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL() } @@ -165,14 +196,17 @@ export class UserListComponent extends RestTable implements OnInit { protected loadData () { this.selectedUsers = [] - this.userService.getUsers(this.pagination, this.sort, this.search) - .subscribe( - resultList => { - this.users = resultList.data - this.totalRecords = resultList.total - }, + this.userService.getUsers({ + pagination: this.pagination, + sort: this.sort, + search: this.search + }).subscribe( + resultList => { + this.users = resultList.data + this.totalRecords = resultList.total + }, - err => this.notifier.error(err.message) - ) + err => this.notifier.error(err.message) + ) } } -- cgit v1.2.3