PeerTube/client/src/app/+admin/users/user-edit/user-edit.ts

54 lines
1.9 KiB
TypeScript
Raw Normal View History

import { ServerService } from '../../../core'
2017-09-05 21:29:39 +02:00
import { FormReactive } from '../../../shared'
import { USER_ROLE_LABELS, VideoResolution } from '../../../../../../shared'
2018-09-26 14:46:54 +02:00
import { ConfigService } from '@app/+admin/config/shared/config.service'
2017-09-05 21:29:39 +02:00
export abstract class UserEdit extends FormReactive {
2018-09-26 14:46:54 +02:00
videoQuotaOptions: { value: string, label: string }[] = []
videoQuotaDailyOptions: { value: string, label: string }[] = []
2018-10-18 14:35:31 +02:00
roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
2018-11-15 09:24:56 +01:00
username: string
userId: number
protected abstract serverService: ServerService
2018-09-26 14:46:54 +02:00
protected abstract configService: ConfigService
2017-09-05 21:29:39 +02:00
abstract isCreation (): boolean
abstract getFormButtonTitle (): string
isTranscodingInformationDisplayed () {
const formVideoQuota = parseInt(this.form.value['videoQuota'], 10)
return this.serverService.getConfig().transcoding.enabledResolutions.length !== 0 &&
formVideoQuota > 0
}
computeQuotaWithTranscoding () {
2019-01-29 08:37:25 +01:00
const transcodingConfig = this.serverService.getConfig().transcoding
const resolutions = transcodingConfig.enabledResolutions
const higherResolution = VideoResolution.H_1080P
let multiplier = 0
for (const resolution of resolutions) {
multiplier += resolution / higherResolution
}
2019-01-29 08:37:25 +01:00
if (transcodingConfig.hls.enabled) multiplier *= 2
return multiplier * parseInt(this.form.value['videoQuota'], 10)
}
2018-09-26 14:46:54 +02:00
resetPassword () {
return
}
2018-09-26 14:46:54 +02:00
protected buildQuotaOptions () {
// These are used by a HTML select, so convert key into strings
this.videoQuotaOptions = this.configService
.videoQuotaOptions.map(q => ({ value: q.value.toString(), label: q.label }))
this.videoQuotaDailyOptions = this.configService
.videoQuotaDailyOptions.map(q => ({ value: q.value.toString(), label: q.label }))
}
2017-09-05 21:29:39 +02:00
}