]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/users/user-list/user-list.component.ts
Refactor rest table search filter
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / users / user-list / user-list.component.ts
index 86812f73d1b48126682129f42b13e113fb77038d..9f92358a05d9bf0d58eff0e52415479ba472837c 100644 (file)
@@ -35,14 +35,14 @@ export class UserListComponent extends RestTable implements OnInit {
   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()
   }
 
@@ -68,14 +68,7 @@ export class UserListComponent extends RestTable implements OnInit {
         .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 = [
       [
@@ -170,26 +163,6 @@ 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()
   }