diff options
author | Ms Kimsible <1877318+kimsible@users.noreply.github.com> | 2021-08-26 08:40:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-26 08:40:18 +0200 |
commit | 52a354ab7af7bd29ca0128fa7c501ea08aa5a343 (patch) | |
tree | d0bdd4e4e113d0b82774d6efd236a127b5f9db35 /client/src/app/+videos/+video-edit/video-add.component.ts | |
parent | 7dca45f99db58d9bb3423a3765aaee68c69bc9f2 (diff) | |
download | PeerTube-52a354ab7af7bd29ca0128fa7c501ea08aa5a343.tar.gz PeerTube-52a354ab7af7bd29ca0128fa7c501ea08aa5a343.tar.zst PeerTube-52a354ab7af7bd29ca0128fa7c501ea08aa5a343.zip |
Fix user quota alerts always displayed (#4354)
* Fix user quota alerts display on upload page
* Fix border-radius upload messages alerts
Co-authored-by: Ms Kimsible <kimsible@users.noreply.github.com>
Diffstat (limited to 'client/src/app/+videos/+video-edit/video-add.component.ts')
-rw-r--r-- | client/src/app/+videos/+video-edit/video-add.component.ts | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/client/src/app/+videos/+video-edit/video-add.component.ts b/client/src/app/+videos/+video-edit/video-add.component.ts index a107ad123..46881be4e 100644 --- a/client/src/app/+videos/+video-edit/video-add.component.ts +++ b/client/src/app/+videos/+video-edit/video-add.component.ts | |||
@@ -1,6 +1,13 @@ | |||
1 | import { Component, HostListener, OnInit, ViewChild } from '@angular/core' | 1 | import { Component, HostListener, OnInit, ViewChild } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | 2 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { AuthService, AuthUser, CanComponentDeactivate, HooksService, ServerService } from '@app/core' | 3 | import { |
4 | AuthService, | ||
5 | AuthUser, | ||
6 | CanComponentDeactivate, | ||
7 | HooksService, | ||
8 | ServerService, | ||
9 | UserService | ||
10 | } from '@app/core' | ||
4 | import { HTMLServerConfig } from '@shared/models' | 11 | import { HTMLServerConfig } from '@shared/models' |
5 | import { VideoEditType } from './shared/video-edit.type' | 12 | import { VideoEditType } from './shared/video-edit.type' |
6 | import { VideoGoLiveComponent } from './video-add-components/video-go-live.component' | 13 | import { VideoGoLiveComponent } from './video-add-components/video-go-live.component' |
@@ -33,10 +40,14 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate { | |||
33 | quotaLeft: string | 40 | quotaLeft: string |
34 | } | 41 | } |
35 | 42 | ||
43 | hasNoQuotaLeft = false | ||
44 | hasNoQuotaLeftDaily = false | ||
45 | |||
36 | private serverConfig: HTMLServerConfig | 46 | private serverConfig: HTMLServerConfig |
37 | 47 | ||
38 | constructor ( | 48 | constructor ( |
39 | private auth: AuthService, | 49 | private auth: AuthService, |
50 | private userService: UserService, | ||
40 | private hooks: HooksService, | 51 | private hooks: HooksService, |
41 | private serverService: ServerService, | 52 | private serverService: ServerService, |
42 | private route: ActivatedRoute, | 53 | private route: ActivatedRoute, |
@@ -56,13 +67,34 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate { | |||
56 | 67 | ||
57 | this.serverConfig = this.serverService.getHTMLConfig() | 68 | this.serverConfig = this.serverService.getHTMLConfig() |
58 | 69 | ||
59 | this.user = this.auth.getUser() | ||
60 | |||
61 | if (this.route.snapshot.fragment) { | 70 | if (this.route.snapshot.fragment) { |
62 | this.onNavChange(this.route.snapshot.fragment) | 71 | this.onNavChange(this.route.snapshot.fragment) |
63 | } | 72 | } |
64 | 73 | ||
65 | this.buildUploadMessages() | 74 | this.buildUploadMessages() |
75 | |||
76 | this.userService.getMyVideoQuotaUsed() | ||
77 | .subscribe(data => { | ||
78 | // videoQuota left lower than 10% | ||
79 | if (data.videoQuotaUsed > this.user.videoQuota * 0.9) { | ||
80 | this.hasNoQuotaLeft = true | ||
81 | } | ||
82 | |||
83 | // unlimited videoQuota | ||
84 | if (this.user.videoQuota === -1) { | ||
85 | this.hasNoQuotaLeft = false | ||
86 | } | ||
87 | |||
88 | // videoQuotaDaily left lower than 10% | ||
89 | if (data.videoQuotaUsedDaily > this.user.videoQuotaDaily * 0.9) { | ||
90 | this.hasNoQuotaLeftDaily = true | ||
91 | } | ||
92 | |||
93 | // unlimited videoQuotaDaily | ||
94 | if (this.user.videoQuotaDaily === -1) { | ||
95 | this.hasNoQuotaLeftDaily = false | ||
96 | } | ||
97 | }) | ||
66 | } | 98 | } |
67 | 99 | ||
68 | private async buildUploadMessages () { | 100 | private async buildUploadMessages () { |