1 import { Subject } from 'rxjs'
2 import { Component, Input, OnInit } from '@angular/core'
3 import { User, UserService } from '@app/core'
4 import { I18n } from '@ngx-translate/i18n-polyfill'
5 import { BytesPipe } from '../angular'
8 selector: 'my-user-quota',
9 templateUrl: './user-quota.component.html',
10 styleUrls: ['./user-quota.component.scss']
13 export class UserQuotaComponent implements OnInit {
14 @Input() user: User = null
15 @Input() userInformationLoaded: Subject<any>
18 userVideoQuotaUsed = 0
19 userVideoQuotaPercentage = 15
21 userVideoQuotaDaily = '0'
22 userVideoQuotaUsedDaily = 0
23 userVideoQuotaDailyPercentage = 15
26 private userService: UserService,
31 this.userInformationLoaded.subscribe(
33 if (this.user.videoQuota !== -1) {
34 this.userVideoQuota = new BytesPipe().transform(this.user.videoQuota, 0).toString()
36 this.userVideoQuota = this.i18n('Unlimited')
39 if (this.user.videoQuotaDaily !== -1) {
40 this.userVideoQuotaDaily = new BytesPipe().transform(this.user.videoQuotaDaily, 0).toString()
42 this.userVideoQuotaDaily = this.i18n('Unlimited')
47 this.userService.getMyVideoQuotaUsed()
49 this.userVideoQuotaUsed = data.videoQuotaUsed
50 this.userVideoQuotaPercentage = this.userVideoQuotaUsed * 100 / this.user.videoQuota
52 this.userVideoQuotaUsedDaily = data.videoQuotaUsedDaily
53 this.userVideoQuotaDailyPercentage = this.userVideoQuotaUsedDaily * 100 / this.user.videoQuotaDaily
58 return this.user.videoQuotaDaily !== -1
62 return `${new BytesPipe().transform(this.userVideoQuotaUsed, 0).toString()} / ${this.userVideoQuota}`
65 titleVideoQuotaDaily () {
66 return `${new BytesPipe().transform(this.userVideoQuotaUsedDaily, 0).toString()} / ${this.userVideoQuotaDaily}`