]>
Commit | Line | Data |
---|---|---|
6a84aafd | 1 | import { ServerService } from '../../../core' |
8094a898 | 2 | import { FormReactive } from '../../../shared' |
954605a8 | 3 | import { USER_ROLE_LABELS, VideoResolution } from '../../../../../../shared' |
8094a898 C |
4 | |
5 | export abstract class UserEdit extends FormReactive { | |
6 | videoQuotaOptions = [ | |
7 | { value: -1, label: 'Unlimited' }, | |
7a8032bb | 8 | { value: 0, label: '0' }, |
8094a898 | 9 | { value: 100 * 1024 * 1024, label: '100MB' }, |
6a84aafd | 10 | { value: 500 * 1024 * 1024, label: '500MB' }, |
8094a898 C |
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' } | |
15 | ] | |
16 | ||
954605a8 C |
17 | roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key, label: USER_ROLE_LABELS[key] })) |
18 | ||
6a84aafd | 19 | protected abstract serverService: ServerService |
8094a898 C |
20 | abstract isCreation (): boolean |
21 | abstract getFormButtonTitle (): string | |
6a84aafd C |
22 | |
23 | isTranscodingInformationDisplayed () { | |
24 | const formVideoQuota = parseInt(this.form.value['videoQuota'], 10) | |
25 | ||
26 | return this.serverService.getConfig().transcoding.enabledResolutions.length !== 0 && | |
27 | formVideoQuota > 0 | |
28 | } | |
29 | ||
30 | computeQuotaWithTranscoding () { | |
31 | const resolutions = this.serverService.getConfig().transcoding.enabledResolutions | |
32 | const higherResolution = VideoResolution.H_1080P | |
33 | let multiplier = 0 | |
34 | ||
35 | for (const resolution of resolutions) { | |
36 | multiplier += resolution / higherResolution | |
37 | } | |
38 | ||
39 | return multiplier * parseInt(this.form.value['videoQuota'], 10) | |
40 | } | |
8094a898 | 41 | } |