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/'
5 import { ConfigService } from '@app/+admin/config/shared/config.service'
7 export abstract class UserEdit extends FormReactive {
9 videoQuotaOptions: { value: string, label: string }[] = []
10 videoQuotaDailyOptions: { value: string, label: string }[] = []
11 roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
13 protected abstract serverService: ServerService
14 protected abstract configService: ConfigService
15 abstract isCreation (): boolean
16 abstract getFormButtonTitle (): string
18 isTranscodingInformationDisplayed () {
19 const formVideoQuota = parseInt(this.form.value['videoQuota'], 10)
21 return this.serverService.getConfig().transcoding.enabledResolutions.length !== 0 &&
25 computeQuotaWithTranscoding () {
26 const resolutions = this.serverService.getConfig().transcoding.enabledResolutions
27 const higherResolution = VideoResolution.H_1080P
30 for (const resolution of resolutions) {
31 multiplier += resolution / higherResolution
34 return multiplier * parseInt(this.form.value['videoQuota'], 10)
37 protected buildQuotaOptions () {
38 // These are used by a HTML select, so convert key into strings
39 this.videoQuotaOptions = this.configService
40 .videoQuotaOptions.map(q => ({ value: q.value.toString(), label: q.label }))
42 this.videoQuotaDailyOptions = this.configService
43 .videoQuotaDailyOptions.map(q => ({ value: q.value.toString(), label: q.label }))