1 import { Subject } from 'rxjs'
2 import { Component, Input, OnInit } from '@angular/core'
3 import { User, UserService } from '@app/core'
4 import { BytesPipe } from '../angular'
7 selector: 'my-user-quota',
8 templateUrl: './user-quota.component.html',
9 styleUrls: ['./user-quota.component.scss']
12 export class UserQuotaComponent implements OnInit {
13 @Input() user: User = null
14 @Input() userInformationLoaded: Subject<any>
17 userVideoQuotaUsed = 0
18 userVideoQuotaPercentage = 15
20 userVideoQuotaDaily = '0'
21 userVideoQuotaUsedDaily = 0
22 userVideoQuotaDailyPercentage = 15
24 constructor (private userService: UserService) { }
27 this.userInformationLoaded.subscribe(
29 if (this.user.videoQuota !== -1) {
30 this.userVideoQuota = new BytesPipe().transform(this.user.videoQuota, 0).toString()
32 this.userVideoQuota = $localize`Unlimited`
35 if (this.user.videoQuotaDaily !== -1) {
36 this.userVideoQuotaDaily = new BytesPipe().transform(this.user.videoQuotaDaily, 0).toString()
38 this.userVideoQuotaDaily = $localize`Unlimited`
43 this.userService.getMyVideoQuotaUsed()
45 this.userVideoQuotaUsed = data.videoQuotaUsed
46 this.userVideoQuotaPercentage = this.userVideoQuotaUsed * 100 / this.user.videoQuota
48 this.userVideoQuotaUsedDaily = data.videoQuotaUsedDaily
49 this.userVideoQuotaDailyPercentage = this.userVideoQuotaUsedDaily * 100 / this.user.videoQuotaDaily
54 return this.user.videoQuotaDaily !== -1
58 return `${new BytesPipe().transform(this.userVideoQuotaUsed, 0).toString()} / ${this.userVideoQuota}`
61 titleVideoQuotaDaily () {
62 return `${new BytesPipe().transform(this.userVideoQuotaUsedDaily, 0).toString()} / ${this.userVideoQuotaDaily}`