]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/users/user-edit/user-edit.ts
add theming via css custom properties
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / users / user-edit / user-edit.ts
CommitLineData
6a84aafd 1import { ServerService } from '../../../core'
8094a898 2import { FormReactive } from '../../../shared'
954605a8 3import { USER_ROLE_LABELS, VideoResolution } from '../../../../../../shared'
bee0abff 4import { EditCustomConfigComponent } from '../../../+admin/config/edit-custom-config/'
8094a898
C
5
6export 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}