]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/users/user-edit/user-edit.ts
Merge branch 'feature/webtorrent-disabling' into develop
[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 {
bee0abff 7
3827c3b3
C
8 videoQuotaOptions: { value: string, label: string }[] = []
9 videoQuotaDailyOptions: { value: string, label: string }[] = []
d18d6478 10 roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
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 () {
25 const resolutions = this.serverService.getConfig().transcoding.enabledResolutions
26 const higherResolution = VideoResolution.H_1080P
27 let multiplier = 0
28
29 for (const resolution of resolutions) {
30 multiplier += resolution / higherResolution
31 }
32
33 return multiplier * parseInt(this.form.value['videoQuota'], 10)
34 }
3827c3b3
C
35
36 protected buildQuotaOptions () {
37 // These are used by a HTML select, so convert key into strings
38 this.videoQuotaOptions = this.configService
39 .videoQuotaOptions.map(q => ({ value: q.value.toString(), label: q.label }))
40
41 this.videoQuotaDailyOptions = this.configService
42 .videoQuotaDailyOptions.map(q => ({ value: q.value.toString(), label: q.label }))
43 }
8094a898 44}