aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/overview/users/user-edit/user-edit.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin/overview/users/user-edit/user-edit.ts')
-rw-r--r--client/src/app/+admin/overview/users/user-edit/user-edit.ts36
1 files changed, 15 insertions, 21 deletions
diff --git a/client/src/app/+admin/overview/users/user-edit/user-edit.ts b/client/src/app/+admin/overview/users/user-edit/user-edit.ts
index 395d07423..1edca7fbf 100644
--- a/client/src/app/+admin/overview/users/user-edit/user-edit.ts
+++ b/client/src/app/+admin/overview/users/user-edit/user-edit.ts
@@ -3,7 +3,7 @@ import { ConfigService } from '@app/+admin/config/shared/config.service'
3import { AuthService, ScreenService, ServerService, User } from '@app/core' 3import { AuthService, ScreenService, ServerService, User } from '@app/core'
4import { FormReactive } from '@app/shared/shared-forms' 4import { FormReactive } from '@app/shared/shared-forms'
5import { USER_ROLE_LABELS } from '@shared/core-utils/users' 5import { USER_ROLE_LABELS } from '@shared/core-utils/users'
6import { HTMLServerConfig, UserAdminFlag, UserRole, VideoResolution } from '@shared/models' 6import { HTMLServerConfig, UserAdminFlag, UserRole } from '@shared/models'
7import { SelectOptionsItem } from '../../../../../types/select-options-item.model' 7import { SelectOptionsItem } from '../../../../../types/select-options-item.model'
8 8
9@Directive() 9@Directive()
@@ -49,7 +49,7 @@ export abstract class UserEdit extends FormReactive implements OnInit {
49 buildRoles () { 49 buildRoles () {
50 const authUser = this.auth.getUser() 50 const authUser = this.auth.getUser()
51 51
52 if (authUser.role === UserRole.ADMINISTRATOR) { 52 if (authUser.role.id === UserRole.ADMINISTRATOR) {
53 this.roles = Object.keys(USER_ROLE_LABELS) 53 this.roles = Object.keys(USER_ROLE_LABELS)
54 .map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] })) 54 .map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
55 return 55 return
@@ -60,33 +60,27 @@ export abstract class UserEdit extends FormReactive implements OnInit {
60 ] 60 ]
61 } 61 }
62 62
63 isTranscodingInformationDisplayed () { 63 displayDangerZone () {
64 const formVideoQuota = parseInt(this.form.value['videoQuota'], 10) 64 if (this.isCreation()) return false
65 if (!this.user) return false
66 if (this.user.pluginAuth) return false
67 if (this.auth.getUser().id === this.user.id) return false
65 68
66 return this.serverConfig.transcoding.enabledResolutions.length !== 0 && 69 return true
67 formVideoQuota > 0
68 } 70 }
69 71
70 computeQuotaWithTranscoding () { 72 resetPassword () {
71 const transcodingConfig = this.serverConfig.transcoding 73 return
72
73 const resolutions = transcodingConfig.enabledResolutions
74 const higherResolution = VideoResolution.H_4K
75 let multiplier = 0
76
77 for (const resolution of resolutions) {
78 multiplier += resolution / higherResolution
79 }
80
81 if (transcodingConfig.hls.enabled) multiplier *= 2
82
83 return multiplier * parseInt(this.form.value['videoQuota'], 10)
84 } 74 }
85 75
86 resetPassword () { 76 disableTwoFactorAuth () {
87 return 77 return
88 } 78 }
89 79
80 getUserVideoQuota () {
81 return this.form.value['videoQuota']
82 }
83
90 protected buildAdminFlags (formValue: any) { 84 protected buildAdminFlags (formValue: any) {
91 return formValue.byPassAutoBlock ? UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST : UserAdminFlag.NONE 85 return formValue.byPassAutoBlock ? UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST : UserAdminFlag.NONE
92 } 86 }