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