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