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'
9 export class UserRealQuotaInfoComponent implements OnInit {
10 @Input() videoQuota: number | string
12 private serverConfig: HTMLServerConfig
14 constructor (private server: ServerService) { }
17 this.serverConfig = this.server.getHTMLConfig()
20 isTranscodingInformationDisplayed () {
21 return this.serverConfig.transcoding.enabledResolutions.length !== 0 && this.getQuotaAsNumber() > 0
24 computeQuotaWithTranscoding () {
25 const transcodingConfig = this.serverConfig.transcoding
27 const resolutions = transcodingConfig.enabledResolutions
28 const higherResolution = VideoResolution.H_4K
31 for (const resolution of resolutions) {
32 multiplier += resolution / higherResolution
35 if (transcodingConfig.hls.enabled) multiplier *= 2
37 return multiplier * this.getQuotaAsNumber()
40 private getQuotaAsNumber () {
41 return parseInt(this.videoQuota + '', 10)