import { Component, OnInit, ViewChild } from '@angular/core'
import { ActivatedRoute, Params, Router } from '@angular/router'
import { AuthService, ConfirmService, Notifier, RestPagination, RestTable, ServerService, UserService } from '@app/core'
-import { Actor, DropdownAction } from '@app/shared/shared-main'
+import { Account, DropdownAction } from '@app/shared/shared-main'
import { UserBanModalComponent } from '@app/shared/shared-moderation'
import { ServerConfig, User, UserRole } from '@shared/models'
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()
}
.subscribe(config => this.serverConfig = config)
this.initialize()
-
- this.route.queryParams
- .subscribe(params => {
- this.search = params.search || ''
-
- this.setTableFilter(this.search)
- this.loadData()
- })
+ this.listenToSearchChange()
this.bulkUserActions = [
[
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()
- }
-
async unbanUsers (users: User[]) {
const res = await this.confirmService.confirm($localize`Do you really want to unban ${users.length} users?`, $localize`Unban`)
if (res === false) return