]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/users/user-edit/user-edit.ts
Cleanup reset user password by admin
[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
b426edd4 11 userId: number
954605a8 12
6a84aafd 13 protected abstract serverService: ServerService
3827c3b3 14 protected abstract configService: ConfigService
8094a898
C
15 abstract isCreation (): boolean
16 abstract getFormButtonTitle (): string
6a84aafd
C
17
18 isTranscodingInformationDisplayed () {
19 const formVideoQuota = parseInt(this.form.value['videoQuota'], 10)
20
21 return this.serverService.getConfig().transcoding.enabledResolutions.length !== 0 &&
22 formVideoQuota > 0
23 }
24
25 computeQuotaWithTranscoding () {
09209296
C
26 const transcodingConfig = this.serverService.getConfig().transcoding
27
28 const resolutions = transcodingConfig.enabledResolutions
6a84aafd
C
29 const higherResolution = VideoResolution.H_1080P
30 let multiplier = 0
31
32 for (const resolution of resolutions) {
33 multiplier += resolution / higherResolution
34 }
35
09209296
C
36 if (transcodingConfig.hls.enabled) multiplier *= 2
37
6a84aafd
C
38 return multiplier * parseInt(this.form.value['videoQuota'], 10)
39 }
3827c3b3 40
b426edd4
C
41 resetPassword () {
42 return
43 }
44
3827c3b3
C
45 protected buildQuotaOptions () {
46 // These are used by a HTML select, so convert key into strings
47 this.videoQuotaOptions = this.configService
48 .videoQuotaOptions.map(q => ({ value: q.value.toString(), label: q.label }))
49
50 this.videoQuotaDailyOptions = this.configService
51 .videoQuotaDailyOptions.map(q => ({ value: q.value.toString(), label: q.label }))
52 }
8094a898 53}