diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-07-15 11:17:03 +0200 |
---|---|---|
committer | Rigel Kent <par@rigelk.eu> | 2020-07-29 18:15:53 +0200 |
commit | bc99dfe54e093e69ba8fd06d36b36fbbda3f45de (patch) | |
tree | 2c13497b77928c2593310746e3ec33333e2b4d66 /client/src/app/+admin/users/user-list/user-list.component.ts | |
parent | 654a188f80fc1f089aa14837084664c908fe27d2 (diff) | |
download | PeerTube-bc99dfe54e093e69ba8fd06d36b36fbbda3f45de.tar.gz PeerTube-bc99dfe54e093e69ba8fd06d36b36fbbda3f45de.tar.zst PeerTube-bc99dfe54e093e69ba8fd06d36b36fbbda3f45de.zip |
variable columns for users list, more columns possible, badge display for statuses
Diffstat (limited to 'client/src/app/+admin/users/user-list/user-list.component.ts')
-rw-r--r-- | client/src/app/+admin/users/user-list/user-list.component.ts | 48 |
1 files changed, 47 insertions, 1 deletions
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 0b72b07c1..b2978212e 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 | |||
@@ -4,7 +4,7 @@ import { AuthService, ConfirmService, Notifier, RestPagination, RestTable, Serve | |||
4 | import { Actor, DropdownAction } from '@app/shared/shared-main' | 4 | import { Actor, DropdownAction } from '@app/shared/shared-main' |
5 | import { UserBanModalComponent } from '@app/shared/shared-moderation' | 5 | import { UserBanModalComponent } from '@app/shared/shared-moderation' |
6 | import { I18n } from '@ngx-translate/i18n-polyfill' | 6 | import { I18n } from '@ngx-translate/i18n-polyfill' |
7 | import { ServerConfig, User } from '@shared/models' | 7 | import { ServerConfig, User, UserRole } from '@shared/models' |
8 | import { Params, Router, ActivatedRoute } from '@angular/router' | 8 | import { Params, Router, ActivatedRoute } from '@angular/router' |
9 | 9 | ||
10 | @Component({ | 10 | @Component({ |
@@ -19,9 +19,12 @@ export class UserListComponent extends RestTable implements OnInit { | |||
19 | totalRecords = 0 | 19 | totalRecords = 0 |
20 | sort: SortMeta = { field: 'createdAt', order: 1 } | 20 | sort: SortMeta = { field: 'createdAt', order: 1 } |
21 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | 21 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } |
22 | highlightBannedUsers = false | ||
22 | 23 | ||
23 | selectedUsers: User[] = [] | 24 | selectedUsers: User[] = [] |
24 | bulkUserActions: DropdownAction<User[]>[][] = [] | 25 | bulkUserActions: DropdownAction<User[]>[][] = [] |
26 | columns: { key: string, label: string }[] | ||
27 | _selectedColumns: { key: string, label: string }[] | ||
25 | 28 | ||
26 | private serverConfig: ServerConfig | 29 | private serverConfig: ServerConfig |
27 | 30 | ||
@@ -46,6 +49,14 @@ export class UserListComponent extends RestTable implements OnInit { | |||
46 | return this.serverConfig.signup.requiresEmailVerification | 49 | return this.serverConfig.signup.requiresEmailVerification |
47 | } | 50 | } |
48 | 51 | ||
52 | get selectedColumns () { | ||
53 | return this._selectedColumns | ||
54 | } | ||
55 | |||
56 | set selectedColumns (val) { | ||
57 | this._selectedColumns = val | ||
58 | } | ||
59 | |||
49 | ngOnInit () { | 60 | ngOnInit () { |
50 | this.serverConfig = this.serverService.getTmpConfig() | 61 | this.serverConfig = this.serverService.getTmpConfig() |
51 | this.serverService.getConfig() | 62 | this.serverService.getConfig() |
@@ -92,12 +103,47 @@ export class UserListComponent extends RestTable implements OnInit { | |||
92 | } | 103 | } |
93 | ] | 104 | ] |
94 | ] | 105 | ] |
106 | |||
107 | this.columns = [ | ||
108 | { key: 'username', label: 'Username' }, | ||
109 | { key: 'email', label: 'Email' }, | ||
110 | { key: 'quota', label: 'Video quota' }, | ||
111 | { key: 'role', label: 'Role' }, | ||
112 | { key: 'createdAt', label: 'Created' } | ||
113 | ] | ||
114 | this.selectedColumns = [...this.columns] | ||
115 | this.columns.push({ key: 'quotaDaily', label: 'Daily quota' }) | ||
116 | this.columns.push({ key: 'pluginAuth', label: 'Auth plugin' }) | ||
117 | this.columns.push({ key: 'lastLoginDate', label: 'Last login' }) | ||
95 | } | 118 | } |
96 | 119 | ||
97 | getIdentifier () { | 120 | getIdentifier () { |
98 | return 'UserListComponent' | 121 | return 'UserListComponent' |
99 | } | 122 | } |
100 | 123 | ||
124 | getRoleClass (role: UserRole) { | ||
125 | switch (role) { | ||
126 | case UserRole.ADMINISTRATOR: | ||
127 | return 'badge-purple' | ||
128 | case UserRole.MODERATOR: | ||
129 | return 'badge-blue' | ||
130 | default: | ||
131 | return 'badge-yellow' | ||
132 | } | ||
133 | } | ||
134 | |||
135 | getColumn (key: string) { | ||
136 | return this.selectedColumns.find((col: any) => col.key === key) | ||
137 | } | ||
138 | |||
139 | getUserVideoQuotaPercentage (user: User & { rawVideoQuota: number, rawVideoQuotaUsed: number}) { | ||
140 | return user.rawVideoQuotaUsed * 100 / user.rawVideoQuota | ||
141 | } | ||
142 | |||
143 | getUserVideoQuotaDailyPercentage (user: User & { rawVideoQuotaDaily: number, rawVideoQuotaUsedDaily: number}) { | ||
144 | return user.rawVideoQuotaUsedDaily * 100 / user.rawVideoQuotaDaily | ||
145 | } | ||
146 | |||
101 | openBanUserModal (users: User[]) { | 147 | openBanUserModal (users: User[]) { |
102 | for (const user of users) { | 148 | for (const user of users) { |
103 | if (user.username === 'root') { | 149 | if (user.username === 'root') { |