]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+admin/shared/user-real-quota-info.component.ts
Remove empty sass files
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / shared / user-real-quota-info.component.ts
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 })
9 export class UserRealQuotaInfoComponent implements OnInit {
10 @Input() videoQuota: number | string
11
12 private serverConfig: HTMLServerConfig
13
14 constructor (private server: ServerService) { }
15
16 ngOnInit () {
17 this.serverConfig = this.server.getHTMLConfig()
18 }
19
20 isTranscodingInformationDisplayed () {
21 return this.serverConfig.transcoding.enabledResolutions.length !== 0 && this.getQuotaAsNumber() > 0
22 }
23
24 computeQuotaWithTranscoding () {
25 const transcodingConfig = this.serverConfig.transcoding
26
27 const resolutions = transcodingConfig.enabledResolutions
28 const higherResolution = VideoResolution.H_4K
29 let multiplier = 0
30
31 for (const resolution of resolutions) {
32 multiplier += resolution / higherResolution
33 }
34
35 if (transcodingConfig.hls.enabled) multiplier *= 2
36
37 return multiplier * this.getQuotaAsNumber()
38 }
39
40 private getQuotaAsNumber () {
41 return parseInt(this.videoQuota + '', 10)
42 }
43 }