1 import { ServerService } from '../../../core'
2 import { FormReactive } from '../../../shared'
3 import { USER_ROLE_LABELS, VideoResolution } from '../../../../../../shared'
4 import { EditCustomConfigComponent } from '../../../+admin/config/edit-custom-config/'
6 export abstract class UserEdit extends FormReactive {
8 // These are used by a HTML select, so convert key into strings
9 videoQuotaOptions = EditCustomConfigComponent.videoQuotaOptions
10 .map(q => ({ value: q.value.toString(), label: q.label }))
11 videoQuotaDailyOptions = EditCustomConfigComponent.videoQuotaDailyOptions
12 .map(q => ({ value: q.value.toString(), label: q.label }))
14 roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
16 protected abstract serverService: ServerService
17 abstract isCreation (): boolean
18 abstract getFormButtonTitle (): string
20 isTranscodingInformationDisplayed () {
21 const formVideoQuota = parseInt(this.form.value['videoQuota'], 10)
23 return this.serverService.getConfig().transcoding.enabledResolutions.length !== 0 &&
27 computeQuotaWithTranscoding () {
28 const resolutions = this.serverService.getConfig().transcoding.enabledResolutions
29 const higherResolution = VideoResolution.H_1080P
32 for (const resolution of resolutions) {
33 multiplier += resolution / higherResolution
36 return multiplier * parseInt(this.form.value['videoQuota'], 10)