diff options
Diffstat (limited to 'client/src/app/+admin/shared/user-real-quota-info.component.ts')
-rw-r--r-- | client/src/app/+admin/shared/user-real-quota-info.component.ts | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/client/src/app/+admin/shared/user-real-quota-info.component.ts b/client/src/app/+admin/shared/user-real-quota-info.component.ts new file mode 100644 index 000000000..069eeba12 --- /dev/null +++ b/client/src/app/+admin/shared/user-real-quota-info.component.ts | |||
@@ -0,0 +1,44 @@ | |||
1 | import { Component, Input, OnInit } from '@angular/core' | ||
2 | import { ServerService } from '@app/core' | ||
3 | import { HTMLServerConfig, VideoResolution } from '@shared/models/index' | ||
4 | |||
5 | @Component({ | ||
6 | selector: 'my-user-real-quota-info', | ||
7 | templateUrl: './user-real-quota-info.component.html', | ||
8 | styleUrls: [ './user-real-quota-info.component.scss' ] | ||
9 | }) | ||
10 | export class UserRealQuotaInfoComponent implements OnInit { | ||
11 | @Input() videoQuota: number | string | ||
12 | |||
13 | private serverConfig: HTMLServerConfig | ||
14 | |||
15 | constructor (private server: ServerService) { } | ||
16 | |||
17 | ngOnInit () { | ||
18 | this.serverConfig = this.server.getHTMLConfig() | ||
19 | } | ||
20 | |||
21 | isTranscodingInformationDisplayed () { | ||
22 | return this.serverConfig.transcoding.enabledResolutions.length !== 0 && this.getQuotaAsNumber() > 0 | ||
23 | } | ||
24 | |||
25 | computeQuotaWithTranscoding () { | ||
26 | const transcodingConfig = this.serverConfig.transcoding | ||
27 | |||
28 | const resolutions = transcodingConfig.enabledResolutions | ||
29 | const higherResolution = VideoResolution.H_4K | ||
30 | let multiplier = 0 | ||
31 | |||
32 | for (const resolution of resolutions) { | ||
33 | multiplier += resolution / higherResolution | ||
34 | } | ||
35 | |||
36 | if (transcodingConfig.hls.enabled) multiplier *= 2 | ||
37 | |||
38 | return multiplier * this.getQuotaAsNumber() | ||
39 | } | ||
40 | |||
41 | private getQuotaAsNumber () { | ||
42 | return parseInt(this.videoQuota + '', 10) | ||
43 | } | ||
44 | } | ||