aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main
diff options
context:
space:
mode:
authorKim <1877318+kimsible@users.noreply.github.com>2020-07-24 08:53:25 +0200
committerGitHub <noreply@github.com>2020-07-24 08:53:25 +0200
commit2e7f262724dd64a209e0bad5930ba29bb4f801c3 (patch)
treeae722bf8df3331442a5f9eaa34eb5c12db21f6cf /client/src/app/shared/shared-main
parentb40a219338fed042072decea203838ca5e2b265f (diff)
downloadPeerTube-2e7f262724dd64a209e0bad5930ba29bb4f801c3.tar.gz
PeerTube-2e7f262724dd64a209e0bad5930ba29bb4f801c3.tar.zst
PeerTube-2e7f262724dd64a209e0bad5930ba29bb4f801c3.zip
Display user quota progress bars above upload form (#2981)
* Move user-quota to my-user-quota shared component * Add user-quota to upload form * Increase progress bar height and make it focusable * Correct syntax parenthesis * Add explicit title to user-quota bars + tooltip with quota values * Hide user-quota in second upload step * Customize focus styles on user-quota Co-authored-by: kimsible <kimsible@users.noreply.github.com>
Diffstat (limited to 'client/src/app/shared/shared-main')
-rw-r--r--client/src/app/shared/shared-main/shared-main.module.ts4
-rw-r--r--client/src/app/shared/shared-main/users/index.ts1
-rw-r--r--client/src/app/shared/shared-main/users/user-quota.component.html21
-rw-r--r--client/src/app/shared/shared-main/users/user-quota.component.scss31
-rw-r--r--client/src/app/shared/shared-main/users/user-quota.component.ts68
5 files changed, 124 insertions, 1 deletions
diff --git a/client/src/app/shared/shared-main/shared-main.module.ts b/client/src/app/shared/shared-main/shared-main.module.ts
index 732914e34..22a207e51 100644
--- a/client/src/app/shared/shared-main/shared-main.module.ts
+++ b/client/src/app/shared/shared-main/shared-main.module.ts
@@ -26,7 +26,7 @@ import { DateToggleComponent } from './date'
26import { FeedComponent } from './feeds' 26import { FeedComponent } from './feeds'
27import { LoaderComponent, SmallLoaderComponent } from './loaders' 27import { LoaderComponent, SmallLoaderComponent } from './loaders'
28import { HelpComponent, ListOverflowComponent, TopMenuDropdownComponent } from './misc' 28import { HelpComponent, ListOverflowComponent, TopMenuDropdownComponent } from './misc'
29import { UserHistoryService, UserNotificationsComponent, UserNotificationService } from './users' 29import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users'
30import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video' 30import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video'
31import { VideoCaptionService } from './video-caption' 31import { VideoCaptionService } from './video-caption'
32import { VideoChannelService } from './video-channel' 32import { VideoChannelService } from './video-channel'
@@ -83,6 +83,7 @@ import { AUTH_INTERCEPTOR_PROVIDER } from './auth'
83 ListOverflowComponent, 83 ListOverflowComponent,
84 TopMenuDropdownComponent, 84 TopMenuDropdownComponent,
85 85
86 UserQuotaComponent,
86 UserNotificationsComponent 87 UserNotificationsComponent
87 ], 88 ],
88 89
@@ -132,6 +133,7 @@ import { AUTH_INTERCEPTOR_PROVIDER } from './auth'
132 ListOverflowComponent, 133 ListOverflowComponent,
133 TopMenuDropdownComponent, 134 TopMenuDropdownComponent,
134 135
136 UserQuotaComponent,
135 UserNotificationsComponent 137 UserNotificationsComponent
136 ], 138 ],
137 139
diff --git a/client/src/app/shared/shared-main/users/index.ts b/client/src/app/shared/shared-main/users/index.ts
index 83401ab52..130082af6 100644
--- a/client/src/app/shared/shared-main/users/index.ts
+++ b/client/src/app/shared/shared-main/users/index.ts
@@ -2,3 +2,4 @@ export * from './user-history.service'
2export * from './user-notification.model' 2export * from './user-notification.model'
3export * from './user-notification.service' 3export * from './user-notification.service'
4export * from './user-notifications.component' 4export * from './user-notifications.component'
5export * from './user-quota.component'
diff --git a/client/src/app/shared/shared-main/users/user-quota.component.html b/client/src/app/shared/shared-main/users/user-quota.component.html
new file mode 100644
index 000000000..f9fb32133
--- /dev/null
+++ b/client/src/app/shared/shared-main/users/user-quota.component.html
@@ -0,0 +1,21 @@
1<div class="user-quota mb-3">
2 <div>
3 <strong class="user-quota-title" tabindex="0" i18n>Total video quota</strong>
4 <div class="progress" tabindex="0" [ngbTooltip]="titleVideoQuota()">
5 <div class="progress-bar" tabindex="0" role="progressbar" [style]="{ width: userVideoQuotaPercentage + '%' }"
6 [attr.aria-valuenow]="userVideoQuotaUsed" aria-valuemin="0" [attr.aria-valuemax]="user.videoQuota">
7 {{ userVideoQuotaUsed | bytes: 0 }}</div>
8 <span class="ml-auto mr-2">{{ userVideoQuota }}</span>
9 </div>
10 </div>
11
12 <div *ngIf="hasDailyQuota()" class="mt-3">
13 <strong class="user-quota-title" tabindex="0" i18n>Daily video quota</strong>
14 <div class="progress" tabindex="0" [ngbTooltip]="titleVideoQuotaDaily()">
15 <div class="progress-bar secondary" role="progressbar" [style]="{ width: userVideoQuotaDailyPercentage + '%' }"
16 [attr.aria-valuenow]="userVideoQuotaUsedDaily" aria-valuemin="0" [attr.aria-valuemax]="user.videoQuotaDaily">
17 {{ userVideoQuotaUsedDaily | bytes: 0 }}</div>
18 <span class="ml-auto mr-2">{{ userVideoQuotaDaily }}</span>
19 </div>
20 </div>
21</div> \ No newline at end of file
diff --git a/client/src/app/shared/shared-main/users/user-quota.component.scss b/client/src/app/shared/shared-main/users/user-quota.component.scss
new file mode 100644
index 000000000..904add0f4
--- /dev/null
+++ b/client/src/app/shared/shared-main/users/user-quota.component.scss
@@ -0,0 +1,31 @@
1@import '_variables';
2@import '_mixins';
3
4.user-quota {
5 font-size: 15px;
6 margin-top: 20px;
7
8 label {
9 margin-right: 5px;
10 }
11
12 &, .progress {
13 width: 100% !important;
14 }
15
16 .user-quota-title, .progress {
17 @include disable-outline;
18 @include button-focus(pvar(--mainColorLightest));
19 }
20
21 .progress {
22 @include progressbar;
23
24 height: 2rem;
25
26 span {
27 align-self: center;
28 }
29 }
30}
31
diff --git a/client/src/app/shared/shared-main/users/user-quota.component.ts b/client/src/app/shared/shared-main/users/user-quota.component.ts
new file mode 100644
index 000000000..a8f56e4d6
--- /dev/null
+++ b/client/src/app/shared/shared-main/users/user-quota.component.ts
@@ -0,0 +1,68 @@
1import { Subject } from 'rxjs'
2import { BytesPipe } from 'ngx-pipes'
3import { Component, Input, OnInit } from '@angular/core'
4import { User, UserService } from '@app/core'
5import { I18n } from '@ngx-translate/i18n-polyfill'
6
7@Component({
8 selector: 'my-user-quota',
9 templateUrl: './user-quota.component.html',
10 styleUrls: ['./user-quota.component.scss']
11})
12
13export class UserQuotaComponent implements OnInit {
14 @Input() user: User = null
15 @Input() userInformationLoaded: Subject<any>
16
17 userVideoQuota = '0'
18 userVideoQuotaUsed = 0
19 userVideoQuotaPercentage = 15
20
21 userVideoQuotaDaily = '0'
22 userVideoQuotaUsedDaily = 0
23 userVideoQuotaDailyPercentage = 15
24
25 constructor (
26 private userService: UserService,
27 private i18n: I18n
28 ) { }
29
30 ngOnInit () {
31 this.userInformationLoaded.subscribe(
32 () => {
33 if (this.user.videoQuota !== -1) {
34 this.userVideoQuota = new BytesPipe().transform(this.user.videoQuota, 0).toString()
35 } else {
36 this.userVideoQuota = this.i18n('Unlimited')
37 }
38
39 if (this.user.videoQuotaDaily !== -1) {
40 this.userVideoQuotaDaily = new BytesPipe().transform(this.user.videoQuotaDaily, 0).toString()
41 } else {
42 this.userVideoQuotaDaily = this.i18n('Unlimited')
43 }
44 }
45 )
46
47 this.userService.getMyVideoQuotaUsed()
48 .subscribe(data => {
49 this.userVideoQuotaUsed = data.videoQuotaUsed
50 this.userVideoQuotaPercentage = this.userVideoQuotaUsed * 100 / this.user.videoQuota
51
52 this.userVideoQuotaUsedDaily = data.videoQuotaUsedDaily
53 this.userVideoQuotaDailyPercentage = this.userVideoQuotaUsedDaily * 100 / this.user.videoQuotaDaily
54 })
55 }
56
57 hasDailyQuota () {
58 return this.user.videoQuotaDaily !== -1
59 }
60
61 titleVideoQuota () {
62 return `${new BytesPipe().transform(this.userVideoQuotaUsed, 0).toString()} / ${this.userVideoQuota}`
63 }
64
65 titleVideoQuotaDaily () {
66 return `${new BytesPipe().transform(this.userVideoQuotaUsedDaily, 0).toString()} / ${this.userVideoQuotaDaily}`
67 }
68}