1 import { ServerService } from '../../../core'
2 import { FormReactive } from '../../../shared'
3 import { USER_ROLE_LABELS, VideoResolution } from '../../../../../../shared'
5 export abstract class UserEdit extends FormReactive {
7 { value: -1, label: 'Unlimited' },
8 { value: 0, label: '0' },
9 { value: 100 * 1024 * 1024, label: '100MB' },
10 { value: 500 * 1024 * 1024, label: '500MB' },
11 { value: 1024 * 1024 * 1024, label: '1GB' },
12 { value: 5 * 1024 * 1024 * 1024, label: '5GB' },
13 { value: 20 * 1024 * 1024 * 1024, label: '20GB' },
14 { value: 50 * 1024 * 1024 * 1024, label: '50GB' }
17 roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key, label: USER_ROLE_LABELS[key] }))
19 protected abstract serverService: ServerService
20 abstract isCreation (): boolean
21 abstract getFormButtonTitle (): string
23 isTranscodingInformationDisplayed () {
24 const formVideoQuota = parseInt(this.form.value['videoQuota'], 10)
26 return this.serverService.getConfig().transcoding.enabledResolutions.length !== 0 &&
30 computeQuotaWithTranscoding () {
31 const resolutions = this.serverService.getConfig().transcoding.enabledResolutions
32 const higherResolution = VideoResolution.H_1080P
35 for (const resolution of resolutions) {
36 multiplier += resolution / higherResolution
39 return multiplier * parseInt(this.form.value['videoQuota'], 10)