From 8e11a1b37cb1d226acfe494f8821e5eb6e874dd0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 8 Apr 2020 10:49:26 +0200 Subject: [PATCH] Fix sort in admin tables --- .../followers-list/followers-list.component.ts | 4 ++++ .../following-list/following-list.component.ts | 4 ++++ .../video-redundancies-list.component.ts | 4 ++++ .../instance-account-blocklist.component.ts | 4 ++++ .../instance-server-blocklist.component.ts | 4 ++++ .../video-abuse-list/video-abuse-list.component.ts | 4 ++++ .../video-blacklist-list.component.ts | 4 ++++ client/src/app/+admin/system/jobs/jobs.component.ts | 4 ++++ .../+admin/users/user-list/user-list.component.ts | 4 ++++ .../my-account-blocklist.component.ts | 4 ++++ .../my-account-server-blocklist.component.ts | 4 ++++ .../my-account-ownership.component.ts | 4 ++++ .../my-account-video-imports.component.ts | 7 +++++-- client/src/app/shared/rest/rest-table.ts | 13 +++++++++---- 14 files changed, 62 insertions(+), 6 deletions(-) diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.ts b/client/src/app/+admin/follows/followers-list/followers-list.component.ts index 707daef84..aff59a691 100644 --- a/client/src/app/+admin/follows/followers-list/followers-list.component.ts +++ b/client/src/app/+admin/follows/followers-list/followers-list.component.ts @@ -31,6 +31,10 @@ export class FollowersListComponent extends RestTable implements OnInit { this.initialize() } + getIdentifier () { + return 'FollowersListComponent' + } + acceptFollower (follow: ActorFollow) { follow.state = 'accepted' diff --git a/client/src/app/+admin/follows/following-list/following-list.component.ts b/client/src/app/+admin/follows/following-list/following-list.component.ts index 3d78c254f..dd7629ead 100644 --- a/client/src/app/+admin/follows/following-list/following-list.component.ts +++ b/client/src/app/+admin/follows/following-list/following-list.component.ts @@ -32,6 +32,10 @@ export class FollowingListComponent extends RestTable implements OnInit { this.initialize() } + getIdentifier () { + return 'FollowingListComponent' + } + async removeFollowing (follow: ActorFollow) { const res = await this.confirmService.confirm( this.i18n('Do you really want to unfollow {{host}}?', { host: follow.following.host }), diff --git a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts index 4b41d1d86..2edee99a3 100644 --- a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts +++ b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts @@ -44,6 +44,10 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit this.bytesPipe = new BytesPipe() } + getIdentifier () { + return 'VideoRedundanciesListComponent' + } + ngOnInit () { this.loadSelectLocalStorage() diff --git a/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.ts b/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.ts index 03e3379e6..a3910177f 100644 --- a/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.ts +++ b/client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.ts @@ -29,6 +29,10 @@ export class InstanceAccountBlocklistComponent extends RestTable implements OnIn this.initialize() } + getIdentifier () { + return 'InstanceAccountBlocklistComponent' + } + unblockAccount (accountBlock: AccountBlock) { const blockedAccount = accountBlock.blockedAccount diff --git a/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.ts b/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.ts index d92a4f195..5af6d8f76 100644 --- a/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.ts +++ b/client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.ts @@ -30,6 +30,10 @@ export class InstanceServerBlocklistComponent extends RestTable implements OnIni this.initialize() } + getIdentifier () { + return 'InstanceServerBlocklistComponent' + } + unblockServer (serverBlock: ServerBlock) { const host = serverBlock.blockedServer.host diff --git a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts index 51114e087..2d991aae9 100644 --- a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts +++ b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts @@ -62,6 +62,10 @@ export class VideoAbuseListComponent extends RestTable implements OnInit { this.initialize() } + getIdentifier () { + return 'VideoAbuseListComponent' + } + openModerationCommentModal (videoAbuse: VideoAbuse) { this.moderationCommentModal.openModal(videoAbuse) } diff --git a/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts b/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts index a215714b8..43b6863af 100644 --- a/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts +++ b/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts @@ -54,6 +54,10 @@ export class VideoBlacklistListComponent extends RestTable implements OnInit { ] } + getIdentifier () { + return 'VideoBlacklistListComponent' + } + getVideoUrl (videoBlacklist: VideoBlacklist) { return Video.buildClientUrl(videoBlacklist.video.uuid) } diff --git a/client/src/app/+admin/system/jobs/jobs.component.ts b/client/src/app/+admin/system/jobs/jobs.component.ts index bc40452cf..dc8343b52 100644 --- a/client/src/app/+admin/system/jobs/jobs.component.ts +++ b/client/src/app/+admin/system/jobs/jobs.component.ts @@ -57,6 +57,10 @@ export class JobsComponent extends RestTable implements OnInit { this.initialize() } + getIdentifier () { + return 'JobsComponent' + } + onJobStateOrTypeChanged () { this.pagination.start = 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 6e9a1feda..0de123e93 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 @@ -86,6 +86,10 @@ export class UserListComponent extends RestTable implements OnInit { ] } + getIdentifier () { + return 'UserListComponent' + } + openBanUserModal (users: User[]) { for (const user of users) { if (user.username === 'root') { diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts index 15b58e45c..d8e9fc514 100644 --- a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts +++ b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts @@ -29,6 +29,10 @@ export class MyAccountBlocklistComponent extends RestTable implements OnInit { this.initialize() } + getIdentifier () { + return 'MyAccountBlocklistComponent' + } + unblockAccount (accountBlock: AccountBlock) { const blockedAccount = accountBlock.blockedAccount diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts b/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts index e735d4ab7..9049dc69c 100644 --- a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts +++ b/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts @@ -30,6 +30,10 @@ export class MyAccountServerBlocklistComponent extends RestTable implements OnIn this.initialize() } + getIdentifier () { + return 'MyAccountServerBlocklistComponent' + } + unblockServer (serverBlock: ServerBlock) { const host = serverBlock.blockedServer.host diff --git a/client/src/app/+my-account/my-account-ownership/my-account-ownership.component.ts b/client/src/app/+my-account/my-account-ownership/my-account-ownership.component.ts index cd8065800..324641be1 100644 --- a/client/src/app/+my-account/my-account-ownership/my-account-ownership.component.ts +++ b/client/src/app/+my-account/my-account-ownership/my-account-ownership.component.ts @@ -31,6 +31,10 @@ export class MyAccountOwnershipComponent extends RestTable implements OnInit { this.initialize() } + getIdentifier () { + return 'MyAccountOwnershipComponent' + } + createByString (account: Account) { return Account.CREATE_BY_STRING(account.name, account.host) } diff --git a/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.ts b/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.ts index 74c42bb4f..9281f9789 100644 --- a/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.ts +++ b/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.ts @@ -20,8 +20,7 @@ export class MyAccountVideoImportsComponent extends RestTable implements OnInit constructor ( private notifier: Notifier, - private videoImportService: VideoImportService, - private i18n: I18n + private videoImportService: VideoImportService ) { super() } @@ -30,6 +29,10 @@ export class MyAccountVideoImportsComponent extends RestTable implements OnInit this.initialize() } + getIdentifier () { + return 'MyAccountVideoImportsComponent' + } + isVideoImportSuccess (videoImport: VideoImport) { return videoImport.state.id === VideoImportState.SUCCESS } diff --git a/client/src/app/shared/rest/rest-table.ts b/client/src/app/shared/rest/rest-table.ts index a33e99e25..63e0e1b97 100644 --- a/client/src/app/shared/rest/rest-table.ts +++ b/client/src/app/shared/rest/rest-table.ts @@ -13,7 +13,8 @@ export abstract class RestTable { protected search: string private searchStream: Subject - private sortLocalStorageKey = 'rest-table-sort-' + this.constructor.name + + abstract getIdentifier (): string initialize () { this.loadSort() @@ -21,13 +22,13 @@ export abstract class RestTable { } loadSort () { - const result = peertubeLocalStorage.getItem(this.sortLocalStorageKey) + const result = peertubeLocalStorage.getItem(this.getSortLocalStorageKey()) if (result) { try { this.sort = JSON.parse(result) } catch (err) { - console.error('Cannot load sort of local storage key ' + this.sortLocalStorageKey, err) + console.error('Cannot load sort of local storage key ' + this.getSortLocalStorageKey(), err) } } } @@ -48,7 +49,7 @@ export abstract class RestTable { } saveSort () { - peertubeLocalStorage.setItem(this.sortLocalStorageKey, JSON.stringify(this.sort)) + peertubeLocalStorage.setItem(this.getSortLocalStorageKey(), JSON.stringify(this.sort)) } initSearch () { @@ -71,4 +72,8 @@ export abstract class RestTable { } protected abstract loadData (): void + + private getSortLocalStorageKey () { + return 'rest-table-sort-' + this.getIdentifier() + } } -- 2.25.1