More modern avatar upload, quota represented with progress bars

This commit is contained in:
Rigel Kent 2020-03-13 01:29:11 +01:00
parent c547bbf96a
commit df8914c9a2
No known key found for this signature in database
GPG Key ID: 5E53E96A494E452F
8 changed files with 65 additions and 29 deletions

View File

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

View File

@ -13,3 +13,7 @@
.account-title { .account-title {
@include settings-big-title; @include settings-big-title;
} }
.progress {
width: 500px;
}

View File

@ -17,9 +17,11 @@ export class MyAccountSettingsComponent implements OnInit, AfterViewChecked {
userVideoQuota = '0' userVideoQuota = '0'
userVideoQuotaUsed = 0 userVideoQuotaUsed = 0
userVideoQuotaPercentage = 15
userVideoQuotaDaily = '0' userVideoQuotaDaily = '0'
userVideoQuotaUsedDaily = 0 userVideoQuotaUsedDaily = 0
userVideoQuotaDailyPercentage = 15
constructor ( constructor (
private viewportScroller: ViewportScroller, private viewportScroller: ViewportScroller,
@ -40,12 +42,14 @@ export class MyAccountSettingsComponent implements OnInit, AfterViewChecked {
() => { () => {
if (this.user.videoQuota !== -1) { if (this.user.videoQuota !== -1) {
this.userVideoQuota = new BytesPipe().transform(this.user.videoQuota, 0).toString() this.userVideoQuota = new BytesPipe().transform(this.user.videoQuota, 0).toString()
this.userVideoQuotaPercentage = this.user.videoQuota * 100 / this.userVideoQuotaUsed
} else { } else {
this.userVideoQuota = this.i18n('Unlimited') this.userVideoQuota = this.i18n('Unlimited')
} }
if (this.user.videoQuotaDaily !== -1) { if (this.user.videoQuotaDaily !== -1) {
this.userVideoQuotaDaily = new BytesPipe().transform(this.user.videoQuotaDaily, 0).toString() this.userVideoQuotaDaily = new BytesPipe().transform(this.user.videoQuotaDaily, 0).toString()
this.userVideoQuotaDailyPercentage = this.user.videoQuotaDaily * 100 / this.userVideoQuotaUsedDaily
} else { } else {
this.userVideoQuotaDaily = this.i18n('Unlimited') this.userVideoQuotaDaily = this.i18n('Unlimited')
} }

View File

@ -2,6 +2,13 @@
<div class="actor"> <div class="actor">
<img [src]="actor.avatarUrl" alt="Avatar" /> <img [src]="actor.avatarUrl" alt="Avatar" />
<div class="actor-img-edit-container">
<div class="actor-img-edit-button" [ngbTooltip]="'(extensions: '+ avatarExtensions +', max size: 100KB)'" placement="right" container="body">
<my-global-icon iconName="edit"></my-global-icon>
<input #avatarfileInput type="file" name="avatarfile" id="avatarfile" [accept]="avatarExtensions" (change)="onAvatarChange()"/>
</div>
</div>
<div class="actor-info"> <div class="actor-info">
<div class="actor-info-names"> <div class="actor-info-names">
<div class="actor-info-display-name">{{ actor.displayName }}</div> <div class="actor-info-display-name">{{ actor.displayName }}</div>
@ -10,10 +17,4 @@
<div i18n class="actor-info-followers">{{ actor.followersCount }} subscribers</div> <div i18n class="actor-info-followers">{{ actor.followersCount }} subscribers</div>
</div> </div>
</div> </div>
<div class="button-file">
<span i18n>Change the avatar</span>
<input #avatarfileInput type="file" name="avatarfile" id="avatarfile" [accept]="avatarExtensions" (change)="onAvatarChange()" />
</div>
<div i18n class="file-max-size">(extensions: {{ avatarExtensions }}, max size: {{ maxAvatarSize | bytes }})</div>
</ng-container> </ng-container>

View File

@ -5,12 +5,42 @@
display: flex; display: flex;
img { img {
@include avatar(50px); @include avatar(100px);
margin-right: 15px; margin-right: 15px;
} }
.actor-img-edit-container {
position: relative;
width: 0;
.actor-img-edit-button {
@include peertube-button-file(21px);
@include button-with-icon(19px);
margin-top: 10px;
margin-bottom: 5px;
border-radius: 50%;
top: 55px;
right: 45px;
cursor: pointer;
input {
width: 30px;
height: 30px;
}
my-global-icon {
right: 7px;
}
}
}
.actor-info { .actor-info {
justify-content: center;
display: inline-flex;
flex-direction: column;
.actor-info-names { .actor-info-names {
display: flex; display: flex;
align-items: center; align-items: center;
@ -35,21 +65,7 @@
.actor-info-followers { .actor-info-followers {
font-size: 15px; font-size: 15px;
padding-bottom: .5rem;
} }
} }
} }
.button-file {
@include peertube-button-file(160px);
margin-top: 10px;
margin-bottom: 5px;
}
.file-max-size {
display: inline-block;
font-size: 13px;
position: relative;
top: -10px;
}

View File

@ -68,7 +68,7 @@
</div> </div>
<!-- Hidden because we want to load the component --> <!-- Hidden because we want to load the component -->
<form [hidden]="!isUploadingVideo" novalidate [formGroup]="form"> <form [hidden]="!isUploadingVideo" novalidate [formGroup]="form" class="mb-3">
<my-video-edit <my-video-edit
[form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions" [form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions"
[validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels" [validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"

View File

@ -236,3 +236,10 @@ ngb-tooltip-window {
background-color: var(--secondaryColor); background-color: var(--secondaryColor);
} }
} }
.progress-bar {
background-color: var(--mainColor);
}
.progress-bar-secondary {
background-color: var(--secondaryColor);
}

View File

@ -26,7 +26,7 @@
@import '~bootstrap/scss/badge'; @import '~bootstrap/scss/badge';
//@import '~bootstrap/scss/jumbotron'; //@import '~bootstrap/scss/jumbotron';
@import '~bootstrap/scss/alert'; @import '~bootstrap/scss/alert';
//@import '~bootstrap/scss/progress'; @import '~bootstrap/scss/progress';
//@import '~bootstrap/scss/media'; //@import '~bootstrap/scss/media';
//@import '~bootstrap/scss/list-group'; //@import '~bootstrap/scss/list-group';
@import '~bootstrap/scss/close'; @import '~bootstrap/scss/close';