Clearer video quota label in user settings

This commit is contained in:
Chocobozzz 2019-12-04 13:19:55 +01:00
parent c883db6d03
commit 66fd15160e
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 28 additions and 2 deletions

View File

@ -1,7 +1,15 @@
<my-actor-avatar-info [actor]="user.account" (avatarChange)="onAvatarChange($event)"></my-actor-avatar-info>
<div class="user-quota">
<span i18n class="user-quota-label">Video quota:</span> {{ userVideoQuotaUsed | bytes: 0 }} / {{ userVideoQuota }}
<div>
<span i18n class="user-quota-label">Total video quota:</span>
<ng-container i18n>{{ userVideoQuotaUsed | bytes: 0 }} used</ng-container> / {{ userVideoQuota }}
</div>
<div *ngIf="hasDailyQuota()">
<span i18n class="user-quota-label">Daily video quota:</span>
<ng-container>{{ userVideoQuotaUsedDaily | bytes: 0 }} used</ng-container> / {{ userVideoQuotaDaily }}
</div>
</div>
<div i18n class="account-title">Profile</div>

View File

@ -6,6 +6,7 @@
margin-top: 20px;
.user-quota-label {
margin-right: 5px;
font-weight: $font-semibold;
}
}

View File

@ -13,9 +13,13 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
})
export class MyAccountSettingsComponent implements OnInit {
user: User = null
userVideoQuota = '0'
userVideoQuotaUsed = 0
userVideoQuotaDaily = '0'
userVideoQuotaUsedDaily = 0
constructor (
private userService: UserService,
private authService: AuthService,
@ -37,11 +41,20 @@ export class MyAccountSettingsComponent implements OnInit {
} else {
this.userVideoQuota = this.i18n('Unlimited')
}
if (this.user.videoQuotaDaily !== -1) {
this.userVideoQuotaDaily = new BytesPipe().transform(this.user.videoQuotaDaily, 0).toString()
} else {
this.userVideoQuotaDaily = this.i18n('Unlimited')
}
}
)
this.userService.getMyVideoQuotaUsed()
.subscribe(data => this.userVideoQuotaUsed = data.videoQuotaUsed)
.subscribe(data => {
this.userVideoQuotaUsed = data.videoQuotaUsed
this.userVideoQuotaUsedDaily = data.videoQuotaUsedDaily
})
}
onAvatarChange (formData: FormData) {
@ -56,4 +69,8 @@ export class MyAccountSettingsComponent implements OnInit {
err => this.notifier.error(err.message)
)
}
hasDailyQuota () {
return this.user.videoQuotaDaily !== -1
}
}