Fix sort in admin tables
authorChocobozzz <me@florianbigard.com>
Wed, 8 Apr 2020 08:49:26 +0000 (10:49 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 8 Apr 2020 08:49:26 +0000 (10:49 +0200)
14 files changed:
client/src/app/+admin/follows/followers-list/followers-list.component.ts
client/src/app/+admin/follows/following-list/following-list.component.ts
client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts
client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.ts
client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.ts
client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts
client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts
client/src/app/+admin/system/jobs/jobs.component.ts
client/src/app/+admin/users/user-list/user-list.component.ts
client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts
client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts
client/src/app/+my-account/my-account-ownership/my-account-ownership.component.ts
client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.ts
client/src/app/shared/rest/rest-table.ts

index 707daef84d71d200ada60553bcd70dd0cbcb15ef..aff59a691ce552759e62a107c1849df9772b315b 100644 (file)
@@ -31,6 +31,10 @@ export class FollowersListComponent extends RestTable implements OnInit {
     this.initialize()
   }
 
+  getIdentifier () {
+    return 'FollowersListComponent'
+  }
+
   acceptFollower (follow: ActorFollow) {
     follow.state = 'accepted'
 
index 3d78c254f04d8c48fd5bad3d523f7e4ce2020fd1..dd7629ead2b6036a1f36eb453226a4c0534aeb77 100644 (file)
@@ -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 }),
index 4b41d1d864ecaff57a867a9e2328e8ca57aca19c..2edee99a3a3ee2d5d4520910bf30e0a202b19e65 100644 (file)
@@ -44,6 +44,10 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit
     this.bytesPipe = new BytesPipe()
   }
 
+  getIdentifier () {
+    return 'VideoRedundanciesListComponent'
+  }
+
   ngOnInit () {
     this.loadSelectLocalStorage()
 
index 03e3379e6d54873e7f89fa8ec5f04ae7c8349edb..a3910177f8f43cf440d07a0680f52025eb3bb48f 100644 (file)
@@ -29,6 +29,10 @@ export class InstanceAccountBlocklistComponent extends RestTable implements OnIn
     this.initialize()
   }
 
+  getIdentifier () {
+    return 'InstanceAccountBlocklistComponent'
+  }
+
   unblockAccount (accountBlock: AccountBlock) {
     const blockedAccount = accountBlock.blockedAccount
 
index d92a4f195ad563982265065459a93bdd966089de..5af6d8f76be8c8feb13b628724134ec1b95bab40 100644 (file)
@@ -30,6 +30,10 @@ export class InstanceServerBlocklistComponent extends RestTable implements OnIni
     this.initialize()
   }
 
+  getIdentifier () {
+    return 'InstanceServerBlocklistComponent'
+  }
+
   unblockServer (serverBlock: ServerBlock) {
     const host = serverBlock.blockedServer.host
 
index 51114e0876fa9fa27bda77986c27e2a95d621aa3..2d991aae93e2d3568cfd1df87dadac8e03662187 100644 (file)
@@ -62,6 +62,10 @@ export class VideoAbuseListComponent extends RestTable implements OnInit {
     this.initialize()
   }
 
+  getIdentifier () {
+    return 'VideoAbuseListComponent'
+  }
+
   openModerationCommentModal (videoAbuse: VideoAbuse) {
     this.moderationCommentModal.openModal(videoAbuse)
   }
index a215714b8f6f2bfb550c38323a108b406563620c..43b6863afe43be32ef381b1bd6aef086ae5e6029 100644 (file)
@@ -54,6 +54,10 @@ export class VideoBlacklistListComponent extends RestTable implements OnInit {
     ]
   }
 
+  getIdentifier () {
+    return 'VideoBlacklistListComponent'
+  }
+
   getVideoUrl (videoBlacklist: VideoBlacklist) {
     return Video.buildClientUrl(videoBlacklist.video.uuid)
   }
index bc40452cf8b231b0dcfa6c62d083b56f86f0879e..dc8343b52f8f3f7076b862f21c457fa62be58b46 100644 (file)
@@ -57,6 +57,10 @@ export class JobsComponent extends RestTable implements OnInit {
     this.initialize()
   }
 
+  getIdentifier () {
+    return 'JobsComponent'
+  }
+
   onJobStateOrTypeChanged () {
     this.pagination.start = 0
 
index 6e9a1fedacfeb7c1392b713bd85d6014e3db1ae8..0de123e93a7a4a153852d340b369f02090a6277d 100644 (file)
@@ -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') {
index 15b58e45cb55ab5e3655969793e42703f3285479..d8e9fc51485539f44d2ee0a3bf05751f1d2fe151 100644 (file)
@@ -29,6 +29,10 @@ export class MyAccountBlocklistComponent extends RestTable implements OnInit {
     this.initialize()
   }
 
+  getIdentifier () {
+    return 'MyAccountBlocklistComponent'
+  }
+
   unblockAccount (accountBlock: AccountBlock) {
     const blockedAccount = accountBlock.blockedAccount
 
index e735d4ab7c4890b2073c590fc8c1fdd6c6faf647..9049dc69c073d7391a16f4c231b02a42e0c8887a 100644 (file)
@@ -30,6 +30,10 @@ export class MyAccountServerBlocklistComponent extends RestTable implements OnIn
     this.initialize()
   }
 
+  getIdentifier () {
+    return 'MyAccountServerBlocklistComponent'
+  }
+
   unblockServer (serverBlock: ServerBlock) {
     const host = serverBlock.blockedServer.host
 
index cd8065800616e5f5ba4f9175cb72265be2694dc6..324641be16f864a0b213f90c25127d0ca51d100e 100644 (file)
@@ -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)
   }
index 74c42bb4f63c8ba577f6989feaf678733a48a48d..9281f978941671c8bf9e4470460541a2e48c9499 100644 (file)
@@ -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
   }
index a33e99e2518a22f7fff9d038cef09def59a96fab..63e0e1b976b08c1172903899df513bf204674f63 100644 (file)
@@ -13,7 +13,8 @@ export abstract class RestTable {
 
   protected search: string
   private searchStream: Subject<string>
-  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()
+  }
 }