aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos
diff options
context:
space:
mode:
authorFelix Ableitner <me@nutomic.com>2018-08-28 02:01:35 -0500
committerChocobozzz <me@florianbigard.com>2018-08-28 09:01:35 +0200
commitbee0abffff73804d816b90c7fd599e0a51c09d61 (patch)
treefae6d58637f9c63a3800090277f8e130b43442dd /client/src/app/videos
parentc907c2fa3fd7c0a741117a0204d0ebca675124bd (diff)
downloadPeerTube-bee0abffff73804d816b90c7fd599e0a51c09d61.tar.gz
PeerTube-bee0abffff73804d816b90c7fd599e0a51c09d61.tar.zst
PeerTube-bee0abffff73804d816b90c7fd599e0a51c09d61.zip
Implement daily upload limit (#956)
* Implement daily upload limit (ref #652) * remove duplicate code * review fixes * fix tests? * whitespace fixes, finish leftover todo * fix tests * added some new tests * use different config value for tests * remove todo
Diffstat (limited to 'client/src/app/videos')
-rw-r--r--client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts22
1 files changed, 20 insertions, 2 deletions
diff --git a/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts
index 3ec89ff62..c9ab35b1d 100644
--- a/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts
+++ b/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts
@@ -31,6 +31,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
31 readonly SPECIAL_SCHEDULED_PRIVACY = VideoEdit.SPECIAL_SCHEDULED_PRIVACY 31 readonly SPECIAL_SCHEDULED_PRIVACY = VideoEdit.SPECIAL_SCHEDULED_PRIVACY
32 32
33 userVideoQuotaUsed = 0 33 userVideoQuotaUsed = 0
34 userVideoQuotaUsedDaily = 0
34 35
35 isUploadingVideo = false 36 isUploadingVideo = false
36 isUpdatingVideo = false 37 isUpdatingVideo = false
@@ -68,6 +69,9 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
68 69
69 this.userService.getMyVideoQuotaUsed() 70 this.userService.getMyVideoQuotaUsed()
70 .subscribe(data => this.userVideoQuotaUsed = data.videoQuotaUsed) 71 .subscribe(data => this.userVideoQuotaUsed = data.videoQuotaUsed)
72
73 this.userService.getMyVideoQuotaUsed()
74 .subscribe(data => this.userVideoQuotaUsedDaily = data.videoQuotaUsedDaily)
71 } 75 }
72 76
73 ngOnDestroy () { 77 ngOnDestroy () {
@@ -115,10 +119,9 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
115 return 119 return
116 } 120 }
117 121
122 const bytePipes = new BytesPipe()
118 const videoQuota = this.authService.getUser().videoQuota 123 const videoQuota = this.authService.getUser().videoQuota
119 if (videoQuota !== -1 && (this.userVideoQuotaUsed + videofile.size) > videoQuota) { 124 if (videoQuota !== -1 && (this.userVideoQuotaUsed + videofile.size) > videoQuota) {
120 const bytePipes = new BytesPipe()
121
122 const msg = this.i18n( 125 const msg = this.i18n(
123 'Your video quota is exceeded with this video (video size: {{ videoSize }}, used: {{ videoQuotaUsed }}, quota: {{ videoQuota }})', 126 'Your video quota is exceeded with this video (video size: {{ videoSize }}, used: {{ videoQuotaUsed }}, quota: {{ videoQuota }})',
124 { 127 {
@@ -131,6 +134,21 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
131 return 134 return
132 } 135 }
133 136
137 const videoQuotaDaily = this.authService.getUser().videoQuotaDaily
138 if (videoQuotaDaily !== -1 && (this.userVideoQuotaUsedDaily + videofile.size) > videoQuotaDaily) {
139 const msg = this.i18n(
140 'Your daily video quota is exceeded with this video (video size: {{ videoSize }}, ' +
141 'used: {{ videoQuotaUsedDaily }}, quota: {{ videoQuotaDaily }})',
142 {
143 videoSize: bytePipes.transform(videofile.size, 0),
144 videoQuotaUsedDaily: bytePipes.transform(this.userVideoQuotaUsedDaily, 0),
145 videoQuotaDaily: bytePipes.transform(videoQuotaDaily, 0)
146 }
147 )
148 this.notificationsService.error(this.i18n('Error'), msg)
149 return
150 }
151
134 const nameWithoutExtension = videofile.name.replace(/\.[^/.]+$/, '') 152 const nameWithoutExtension = videofile.name.replace(/\.[^/.]+$/, '')
135 let name: string 153 let name: string
136 154