From 87a0cac618c8ed4a09408273d0f5a468530e8062 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 24 May 2022 15:05:39 +0200 Subject: Improve admin users list table * Fix last login sort with null values * Remember last selected columns * Display last login date by default --- .../users/user-list/user-list.component.html | 2 +- .../users/user-list/user-list.component.ts | 44 +++++++++++++++++----- client/src/app/core/rest/rest-table.ts | 8 ++-- 3 files changed, 40 insertions(+), 14 deletions(-) (limited to 'client/src') diff --git a/client/src/app/+admin/overview/users/user-list/user-list.component.html b/client/src/app/+admin/overview/users/user-list/user-list.component.html index 30d10e3cf..62eeef8fe 100644 --- a/client/src/app/+admin/overview/users/user-list/user-list.component.html +++ b/client/src/app/+admin/overview/users/user-list/user-list.component.html @@ -5,7 +5,7 @@ c.id) + this.loadSelectedColumns() + } + + loadSelectedColumns () { + const result = this.peertubeLocalStorage.getItem(UserListComponent.LOCAL_STORAGE_SELECTED_COLUMNS_KEY) + + if (result) { + try { + this.selectedColumns = JSON.parse(result) + return + } catch (err) { + console.error('Cannot load selected columns.', err) + } + } + + // Default behaviour + this.selectedColumns = [ 'username', 'role', 'email', 'quota', 'createdAt', 'lastLoginDate' ] + return + } - this.columns.push({ id: 'quotaDaily', label: $localize`Daily quota` }) - this.columns.push({ id: 'pluginAuth', label: $localize`Auth plugin` }) - this.columns.push({ id: 'lastLoginDate', label: $localize`Last login` }) + saveSelectedColumns () { + this.peertubeLocalStorage.setItem(UserListComponent.LOCAL_STORAGE_SELECTED_COLUMNS_KEY, JSON.stringify(this.selectedColumns)) } getIdentifier () { diff --git a/client/src/app/core/rest/rest-table.ts b/client/src/app/core/rest/rest-table.ts index d8b039187..7b765f7fc 100644 --- a/client/src/app/core/rest/rest-table.ts +++ b/client/src/app/core/rest/rest-table.ts @@ -39,6 +39,10 @@ export abstract class RestTable { } } + saveSort () { + peertubeLocalStorage.setItem(this.getSortLocalStorageKey(), JSON.stringify(this.sort)) + } + loadLazy (event: LazyLoadEvent) { logger('Load lazy %o.', event) @@ -60,10 +64,6 @@ export abstract class RestTable { this.saveSort() } - saveSort () { - peertubeLocalStorage.setItem(this.getSortLocalStorageKey(), JSON.stringify(this.sort)) - } - onSearch (search: string) { this.search = search this.reloadData() -- cgit v1.2.3