1 import { Component, Input, OnInit } from '@angular/core'
2 import { ServerService } from '@app/core'
3 import { HTMLServerConfig, VideoResolution } from '@shared/models/index'
6 selector: 'my-user-real-quota-info',
7 templateUrl: './user-real-quota-info.component.html',
8 styleUrls: [ './user-real-quota-info.component.scss' ]
10 export class UserRealQuotaInfoComponent implements OnInit {
11 @Input() videoQuota: number | string
13 private serverConfig: HTMLServerConfig
15 constructor (private server: ServerService) { }
18 this.serverConfig = this.server.getHTMLConfig()
21 isTranscodingInformationDisplayed () {
22 return this.serverConfig.transcoding.enabledResolutions.length !== 0 && this.getQuotaAsNumber() > 0
25 computeQuotaWithTranscoding () {
26 const transcodingConfig = this.serverConfig.transcoding
28 const resolutions = transcodingConfig.enabledResolutions
29 const higherResolution = VideoResolution.H_4K
32 for (const resolution of resolutions) {
33 multiplier += resolution / higherResolution
36 if (transcodingConfig.hls.enabled) multiplier *= 2
38 return multiplier * this.getQuotaAsNumber()
41 private getQuotaAsNumber () {
42 return parseInt(this.videoQuota + '', 10)