]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/users/user-edit/user-edit.ts
cleanup and remove paramSubs
[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'
3827c3b3 4import { ConfigService } from '@app/+admin/config/shared/config.service'
8094a898
C
5
6export abstract class UserEdit extends FormReactive {
3827c3b3
C
7 videoQuotaOptions: { value: string, label: string }[] = []
8 videoQuotaDailyOptions: { value: string, label: string }[] = []
c199c427 9 roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
2fbe7f19 10 username: string
954605a8 11
6a84aafd 12 protected abstract serverService: ServerService
3827c3b3 13 protected abstract configService: ConfigService
8094a898
C
14 abstract isCreation (): boolean
15 abstract getFormButtonTitle (): string
6a84aafd
C
16
17 isTranscodingInformationDisplayed () {
18 const formVideoQuota = parseInt(this.form.value['videoQuota'], 10)
19
20 return this.serverService.getConfig().transcoding.enabledResolutions.length !== 0 &&
21 formVideoQuota > 0
22 }
23
24 computeQuotaWithTranscoding () {
09209296
C
25 const transcodingConfig = this.serverService.getConfig().transcoding
26
27 const resolutions = transcodingConfig.enabledResolutions
6a84aafd
C
28 const higherResolution = VideoResolution.H_1080P
29 let multiplier = 0
30
31 for (const resolution of resolutions) {
32 multiplier += resolution / higherResolution
33 }
34
09209296
C
35 if (transcodingConfig.hls.enabled) multiplier *= 2
36
6a84aafd
C
37 return multiplier * parseInt(this.form.value['videoQuota'], 10)
38 }
3827c3b3
C
39
40 protected buildQuotaOptions () {
41 // These are used by a HTML select, so convert key into strings
42 this.videoQuotaOptions = this.configService
43 .videoQuotaOptions.map(q => ({ value: q.value.toString(), label: q.label }))
44
45 this.videoQuotaDailyOptions = this.configService
46 .videoQuotaDailyOptions.map(q => ({ value: q.value.toString(), label: q.label }))
47 }
8094a898 48}