diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-23 14:36:16 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-23 14:36:16 +0100 |
commit | ab998f7b6dffbe461d830d3696cb46491ad6afb0 (patch) | |
tree | f819e4049ca62b5389fd31ebfcbcb6ffbe0eaf0b /client/src/app/shared | |
parent | 621d99f53f47a11919ec243e05273ecf5907b444 (diff) | |
download | PeerTube-ab998f7b6dffbe461d830d3696cb46491ad6afb0.tar.gz PeerTube-ab998f7b6dffbe461d830d3696cb46491ad6afb0.tar.zst PeerTube-ab998f7b6dffbe461d830d3696cb46491ad6afb0.zip |
Improve admin tables
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/misc/delete-button.component.html | 2 | ||||
-rw-r--r-- | client/src/app/shared/misc/delete-button.component.ts | 3 | ||||
-rw-r--r-- | client/src/app/shared/rest/rest-table.ts | 20 |
3 files changed, 23 insertions, 2 deletions
diff --git a/client/src/app/shared/misc/delete-button.component.html b/client/src/app/shared/misc/delete-button.component.html index 3db483882..d49de294a 100644 --- a/client/src/app/shared/misc/delete-button.component.html +++ b/client/src/app/shared/misc/delete-button.component.html | |||
@@ -1,4 +1,4 @@ | |||
1 | <span class="action-button action-button-delete" > | 1 | <span class="action-button action-button-delete" > |
2 | <span class="icon icon-delete-grey"></span> | 2 | <span class="icon icon-delete-grey"></span> |
3 | Delete | 3 | {{ label }} |
4 | </span> | 4 | </span> |
diff --git a/client/src/app/shared/misc/delete-button.component.ts b/client/src/app/shared/misc/delete-button.component.ts index e04039f69..2ffd98212 100644 --- a/client/src/app/shared/misc/delete-button.component.ts +++ b/client/src/app/shared/misc/delete-button.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Component } from '@angular/core' | 1 | import { Component, Input } from '@angular/core' |
2 | 2 | ||
3 | @Component({ | 3 | @Component({ |
4 | selector: 'my-delete-button', | 4 | selector: 'my-delete-button', |
@@ -7,4 +7,5 @@ import { Component } from '@angular/core' | |||
7 | }) | 7 | }) |
8 | 8 | ||
9 | export class DeleteButtonComponent { | 9 | export class DeleteButtonComponent { |
10 | @Input() label = 'Delete' | ||
10 | } | 11 | } |
diff --git a/client/src/app/shared/rest/rest-table.ts b/client/src/app/shared/rest/rest-table.ts index d04d91c68..165fc4e45 100644 --- a/client/src/app/shared/rest/rest-table.ts +++ b/client/src/app/shared/rest/rest-table.ts | |||
@@ -4,13 +4,28 @@ import { SortMeta } from 'primeng/components/common/sortmeta' | |||
4 | import { RestPagination } from './rest-pagination' | 4 | import { RestPagination } from './rest-pagination' |
5 | 5 | ||
6 | export abstract class RestTable { | 6 | export abstract class RestTable { |
7 | |||
7 | abstract totalRecords: number | 8 | abstract totalRecords: number |
8 | abstract rowsPerPage: number | 9 | abstract rowsPerPage: number |
9 | abstract sort: SortMeta | 10 | abstract sort: SortMeta |
10 | abstract pagination: RestPagination | 11 | abstract pagination: RestPagination |
11 | 12 | ||
13 | private sortLocalStorageKey = 'rest-table-sort-' + this.constructor.name | ||
14 | |||
12 | protected abstract loadData (): void | 15 | protected abstract loadData (): void |
13 | 16 | ||
17 | loadSort () { | ||
18 | const result = localStorage.getItem(this.sortLocalStorageKey) | ||
19 | |||
20 | if (result) { | ||
21 | try { | ||
22 | this.sort = JSON.parse(result) | ||
23 | } catch (err) { | ||
24 | console.error('Cannot load sort of local storage key ' + this.sortLocalStorageKey, err) | ||
25 | } | ||
26 | } | ||
27 | } | ||
28 | |||
14 | loadLazy (event: LazyLoadEvent) { | 29 | loadLazy (event: LazyLoadEvent) { |
15 | this.sort = { | 30 | this.sort = { |
16 | order: event.sortOrder, | 31 | order: event.sortOrder, |
@@ -23,6 +38,11 @@ export abstract class RestTable { | |||
23 | } | 38 | } |
24 | 39 | ||
25 | this.loadData() | 40 | this.loadData() |
41 | this.saveSort() | ||
42 | } | ||
43 | |||
44 | saveSort () { | ||
45 | localStorage.setItem(this.sortLocalStorageKey, JSON.stringify(this.sort)) | ||
26 | } | 46 | } |
27 | 47 | ||
28 | } | 48 | } |