1 import { ServerService } from '../../../core'
2 import { FormReactive } from '../../../shared'
3 import { USER_ROLE_LABELS, VideoResolution } from '../../../../../../shared'
4 import { ConfigService } from '@app/+admin/config/shared/config.service'
6 export abstract class UserEdit extends FormReactive {
7 videoQuotaOptions: { value: string, label: string }[] = []
8 videoQuotaDailyOptions: { value: string, label: string }[] = []
9 roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
12 protected abstract serverService: ServerService
13 protected abstract configService: ConfigService
14 abstract isCreation (): boolean
15 abstract getFormButtonTitle (): string
17 isTranscodingInformationDisplayed () {
18 const formVideoQuota = parseInt(this.form.value['videoQuota'], 10)
20 return this.serverService.getConfig().transcoding.enabledResolutions.length !== 0 &&
24 computeQuotaWithTranscoding () {
25 const resolutions = this.serverService.getConfig().transcoding.enabledResolutions
26 const higherResolution = VideoResolution.H_1080P
29 for (const resolution of resolutions) {
30 multiplier += resolution / higherResolution
33 return multiplier * parseInt(this.form.value['videoQuota'], 10)
36 protected buildQuotaOptions () {
37 // These are used by a HTML select, so convert key into strings
38 this.videoQuotaOptions = this.configService
39 .videoQuotaOptions.map(q => ({ value: q.value.toString(), label: q.label }))
41 this.videoQuotaDailyOptions = this.configService
42 .videoQuotaDailyOptions.map(q => ({ value: q.value.toString(), label: q.label }))