diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-10-19 17:33:32 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-10-19 17:35:41 +0200 |
commit | 6a84aafd23c2f887f837cc4826cf7c8c07d1c60f (patch) | |
tree | cccff65aad1ff4eb53d40c604441db5d99e425b6 /client/src/app/+admin/users/user-edit/user-edit.ts | |
parent | a10d56bafc31602dfee9b1c52bbf26ab9aca366a (diff) | |
download | PeerTube-6a84aafd23c2f887f837cc4826cf7c8c07d1c60f.tar.gz PeerTube-6a84aafd23c2f887f837cc4826cf7c8c07d1c60f.tar.zst PeerTube-6a84aafd23c2f887f837cc4826cf7c8c07d1c60f.zip |
Take in account transcoding for video quota
Diffstat (limited to 'client/src/app/+admin/users/user-edit/user-edit.ts')
-rw-r--r-- | client/src/app/+admin/users/user-edit/user-edit.ts | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/client/src/app/+admin/users/user-edit/user-edit.ts b/client/src/app/+admin/users/user-edit/user-edit.ts index 657c0f1c0..76497c9b6 100644 --- a/client/src/app/+admin/users/user-edit/user-edit.ts +++ b/client/src/app/+admin/users/user-edit/user-edit.ts | |||
@@ -1,17 +1,39 @@ | |||
1 | import { ServerService } from '../../../core' | ||
1 | import { FormReactive } from '../../../shared' | 2 | import { FormReactive } from '../../../shared' |
3 | import { VideoResolution } from '../../../../../../shared/models/videos/video-resolution.enum' | ||
2 | 4 | ||
3 | export abstract class UserEdit extends FormReactive { | 5 | export abstract class UserEdit extends FormReactive { |
4 | videoQuotaOptions = [ | 6 | videoQuotaOptions = [ |
5 | { value: -1, label: 'Unlimited' }, | 7 | { value: -1, label: 'Unlimited' }, |
6 | { value: 0, label: '0'}, | 8 | { value: 0, label: '0'}, |
7 | { value: 100 * 1024 * 1024, label: '100MB' }, | 9 | { value: 100 * 1024 * 1024, label: '100MB' }, |
8 | { value: 5 * 1024 * 1024, label: '500MB' }, | 10 | { value: 500 * 1024 * 1024, label: '500MB' }, |
9 | { value: 1024 * 1024 * 1024, label: '1GB' }, | 11 | { value: 1024 * 1024 * 1024, label: '1GB' }, |
10 | { value: 5 * 1024 * 1024 * 1024, label: '5GB' }, | 12 | { value: 5 * 1024 * 1024 * 1024, label: '5GB' }, |
11 | { value: 20 * 1024 * 1024 * 1024, label: '20GB' }, | 13 | { value: 20 * 1024 * 1024 * 1024, label: '20GB' }, |
12 | { value: 50 * 1024 * 1024 * 1024, label: '50GB' } | 14 | { value: 50 * 1024 * 1024 * 1024, label: '50GB' } |
13 | ] | 15 | ] |
14 | 16 | ||
17 | protected abstract serverService: ServerService | ||
15 | abstract isCreation (): boolean | 18 | abstract isCreation (): boolean |
16 | abstract getFormButtonTitle (): string | 19 | abstract getFormButtonTitle (): string |
20 | |||
21 | isTranscodingInformationDisplayed () { | ||
22 | const formVideoQuota = parseInt(this.form.value['videoQuota'], 10) | ||
23 | |||
24 | return this.serverService.getConfig().transcoding.enabledResolutions.length !== 0 && | ||
25 | formVideoQuota > 0 | ||
26 | } | ||
27 | |||
28 | computeQuotaWithTranscoding () { | ||
29 | const resolutions = this.serverService.getConfig().transcoding.enabledResolutions | ||
30 | const higherResolution = VideoResolution.H_1080P | ||
31 | let multiplier = 0 | ||
32 | |||
33 | for (const resolution of resolutions) { | ||
34 | multiplier += resolution / higherResolution | ||
35 | } | ||
36 | |||
37 | return multiplier * parseInt(this.form.value['videoQuota'], 10) | ||
38 | } | ||
17 | } | 39 | } |