fix quota representation in profile settings

pull/2915/head
Rigel Kent 2020-06-28 01:17:48 +02:00
parent 0242861ece
commit 287124d110
No known key found for this signature in database
GPG Key ID: 5E53E96A494E452F
2 changed files with 5 additions and 4 deletions

View File

@ -10,14 +10,14 @@
<div class="user-quota mb-3">
<div>
<div class="progress" i18n-title title="Total video quota">
<div class="progress-bar" role="progressbar" [style]="{ width: userVideoQuotaPercentage + '%' }" [attr.aria-valuenow]="userVideoQuotaUsed" aria-valuemin="0" [attr.aria-valuemax]="userVideoQuota">{{ userVideoQuotaUsed | bytes: 0 }}</div>
<div class="progress-bar" role="progressbar" [style]="{ width: userVideoQuotaPercentage + '%' }" [attr.aria-valuenow]="userVideoQuotaUsed" aria-valuemin="0" [attr.aria-valuemax]="user.videoQuota">{{ userVideoQuotaUsed | bytes: 0 }}</div>
<span class="ml-auto mr-2">{{ userVideoQuota }}</span>
</div>
</div>
<div *ngIf="hasDailyQuota()" class="mt-3">
<div class="progress" i18n-title title="Daily video quota">
<div class="progress-bar secondary" role="progressbar" [style]="{ width: userVideoQuotaDailyPercentage + '%' }" [attr.aria-valuenow]="userVideoQuotaUsedDaily" aria-valuemin="0" [attr.aria-valuemax]="userVideoQuotaDaily">{{ userVideoQuotaUsedDaily | bytes: 0 }}</div>
<div class="progress-bar secondary" role="progressbar" [style]="{ width: userVideoQuotaDailyPercentage + '%' }" [attr.aria-valuenow]="userVideoQuotaUsedDaily" aria-valuemin="0" [attr.aria-valuemax]="user.videoQuotaDaily">{{ userVideoQuotaUsedDaily | bytes: 0 }}</div>
<span class="ml-auto mr-2">{{ userVideoQuotaDaily }}</span>
</div>
</div>

View File

@ -41,14 +41,12 @@ export class MyAccountSettingsComponent implements OnInit, AfterViewChecked {
() => {
if (this.user.videoQuota !== -1) {
this.userVideoQuota = new BytesPipe().transform(this.user.videoQuota, 0).toString()
this.userVideoQuotaPercentage = this.user.videoQuota * 100 / this.userVideoQuotaUsed
} else {
this.userVideoQuota = this.i18n('Unlimited')
}
if (this.user.videoQuotaDaily !== -1) {
this.userVideoQuotaDaily = new BytesPipe().transform(this.user.videoQuotaDaily, 0).toString()
this.userVideoQuotaDailyPercentage = this.user.videoQuotaDaily * 100 / this.userVideoQuotaUsedDaily
} else {
this.userVideoQuotaDaily = this.i18n('Unlimited')
}
@ -58,7 +56,10 @@ export class MyAccountSettingsComponent implements OnInit, AfterViewChecked {
this.userService.getMyVideoQuotaUsed()
.subscribe(data => {
this.userVideoQuotaUsed = data.videoQuotaUsed
this.userVideoQuotaPercentage = this.userVideoQuotaUsed * 100 / this.user.videoQuota
this.userVideoQuotaUsedDaily = data.videoQuotaUsedDaily
this.userVideoQuotaDailyPercentage = this.userVideoQuotaUsedDaily * 100 / this.user.videoQuotaDaily
})
}