+ this.serverConfig = this.serverService.getTmpConfig()
+ this.serverService.getConfig()
+ .subscribe(config => this.serverConfig = config)
+
+ this.initialize()
+
+ this.route.queryParams
+ .subscribe(params => {
+ this.search = params.search || ''
+
+ this.setTableFilter(this.search)
+ this.loadData()
+ })
+
+ this.bulkUserActions = [
+ [
+ {
+ label: $localize`Delete`,
+ description: $localize`Videos will be deleted, comments will be tombstoned.`,
+ handler: users => this.removeUsers(users),
+ isDisplayed: users => users.every(u => this.authUser.canManage(u))
+ },
+ {
+ label: $localize`Ban`,
+ description: $localize`User won't be able to login anymore, but videos and comments will be kept as is.`,
+ handler: users => this.openBanUserModal(users),
+ isDisplayed: users => users.every(u => this.authUser.canManage(u) && u.blocked === false)
+ },
+ {
+ label: $localize`Unban`,
+ handler: users => this.unbanUsers(users),
+ isDisplayed: users => users.every(u => this.authUser.canManage(u) && u.blocked === true)
+ }
+ ],
+ [
+ {
+ label: $localize`Set Email as Verified`,
+ handler: users => this.setEmailsAsVerified(users),
+ isDisplayed: users => {
+ return this.requiresEmailVerification &&
+ users.every(u => this.authUser.canManage(u) && !u.blocked && u.emailVerified === false)
+ }
+ }
+ ]
+ ]
+
+ this.columns = [
+ { id: 'username', label: 'Username' },
+ { id: 'email', label: 'Email' },
+ { id: 'quota', label: 'Video quota' },
+ { id: 'role', label: 'Role' },
+ { id: 'createdAt', label: 'Created' }
+ ]
+
+ this.selectedColumns = this.columns.map(c => c.id)
+
+ this.columns.push({ id: 'quotaDaily', label: 'Daily quota' })
+ this.columns.push({ id: 'pluginAuth', label: 'Auth plugin' })
+ this.columns.push({ id: 'lastLoginDate', label: 'Last login' })
+ }
+
+ getIdentifier () {
+ return 'UserListComponent'
+ }
+
+ getRoleClass (role: UserRole) {
+ switch (role) {
+ case UserRole.ADMINISTRATOR:
+ return 'badge-purple'
+ case UserRole.MODERATOR:
+ return 'badge-blue'
+ default:
+ return 'badge-yellow'
+ }
+ }
+
+ isSelected (id: string) {
+ return this.selectedColumns.find(c => c === id)
+ }
+
+ getColumn (id: string) {
+ return this.columns.find(c => c.id === id)
+ }
+
+ getUserVideoQuotaPercentage (user: UserForList) {
+ return user.rawVideoQuotaUsed * 100 / user.rawVideoQuota
+ }
+
+ getUserVideoQuotaDailyPercentage (user: UserForList) {
+ return user.rawVideoQuotaUsedDaily * 100 / user.rawVideoQuotaDaily