import { SortMeta } from 'primeng/api'
import { Component, OnInit, ViewChild } from '@angular/core'
-import { ActivatedRoute, Params, Router } from '@angular/router'
+import { ActivatedRoute, Router } from '@angular/router'
import { AuthService, ConfirmService, Notifier, RestPagination, RestTable, ServerService, UserService } from '@app/core'
-import { Actor, DropdownAction } from '@app/shared/shared-main'
+import { AdvancedInputFilter } from '@app/shared/shared-forms'
+import { DropdownAction } from '@app/shared/shared-main'
import { UserBanModalComponent } from '@app/shared/shared-moderation'
import { ServerConfig, User, UserRole } from '@shared/models'
@ViewChild('userBanModal', { static: true }) userBanModal: UserBanModalComponent
users: User[] = []
+
totalRecords = 0
sort: SortMeta = { field: 'createdAt', order: 1 }
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
+
highlightBannedUsers = false
selectedUsers: User[] = []
bulkUserActions: DropdownAction<User[]>[][] = []
columns: { id: string, label: string }[]
+ inputFilters: AdvancedInputFilter[] = [
+ {
+ queryParams: { 'search': 'banned:true' },
+ label: $localize`Banned users`
+ }
+ ]
+
private _selectedColumns: string[]
private serverConfig: ServerConfig
constructor (
+ protected route: ActivatedRoute,
+ protected router: Router,
private notifier: Notifier,
private confirmService: ConfirmService,
private serverService: ServerService,
- private userService: UserService,
private auth: AuthService,
- private route: ActivatedRoute,
- private router: Router
- ) {
+ private userService: UserService
+ ) {
super()
}
this.initialize()
- this.route.queryParams
- .subscribe(params => {
- this.search = params.search || ''
-
- this.setTableFilter(this.search)
- this.loadData()
- })
-
this.bulkUserActions = [
[
{
}
onUserChanged () {
- 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()
+ this.reloadData()
}
async unbanUsers (users: User[]) {
.subscribe(
() => {
this.notifier.success($localize`${users.length} users unbanned.`)
- this.loadData()
+ this.reloadData()
},
err => this.notifier.error(err.message)
this.userService.removeUser(users).subscribe(
() => {
this.notifier.success($localize`${users.length} users deleted.`)
- this.loadData()
+ this.reloadData()
},
err => this.notifier.error(err.message)
this.userService.updateUsers(users, { emailVerified: true }).subscribe(
() => {
this.notifier.success($localize`${users.length} users email set as verified.`)
- this.loadData()
+ this.reloadData()
},
err => this.notifier.error(err.message)
return this.selectedUsers.length !== 0
}
- protected loadData () {
+ protected reloadData () {
this.selectedUsers = []
this.userService.getUsers({