aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-08 12:53:09 +0100
committerChocobozzz <me@florianbigard.com>2018-01-08 12:53:09 +0100
commitce5496d6a31b9617aba67970f5dc135e73335234 (patch)
treeb5d2578f4618b71632e92838c3ceae36aa102798 /client/src/app/videos
parent108af66140713c4beec681a71d360ab788226528 (diff)
downloadPeerTube-ce5496d6a31b9617aba67970f5dc135e73335234.tar.gz
PeerTube-ce5496d6a31b9617aba67970f5dc135e73335234.tar.zst
PeerTube-ce5496d6a31b9617aba67970f5dc135e73335234.zip
Support video quota on client
Diffstat (limited to 'client/src/app/videos')
-rw-r--r--client/src/app/videos/+video-edit/video-add.component.html2
-rw-r--r--client/src/app/videos/+video-edit/video-add.component.ts25
-rw-r--r--client/src/app/videos/+video-edit/video-update.component.ts5
3 files changed, 24 insertions, 8 deletions
diff --git a/client/src/app/videos/+video-edit/video-add.component.html b/client/src/app/videos/+video-edit/video-add.component.html
index 193cc55ee..2040ff9d4 100644
--- a/client/src/app/videos/+video-edit/video-add.component.html
+++ b/client/src/app/videos/+video-edit/video-add.component.html
@@ -3,8 +3,6 @@
3 Upload your video 3 Upload your video
4 </div> 4 </div>
5 5
6 <div *ngIf="error" class="alert alert-danger">{{ error }}</div>
7
8 <div *ngIf="!isUploadingVideo" class="upload-video-container"> 6 <div *ngIf="!isUploadingVideo" class="upload-video-container">
9 <div class="upload-video"> 7 <div class="upload-video">
10 <div class="icon icon-upload"></div> 8 <div class="icon icon-upload"></div>
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 066f945fc..a86d9d3c2 100644
--- a/client/src/app/videos/+video-edit/video-add.component.ts
+++ b/client/src/app/videos/+video-edit/video-add.component.ts
@@ -2,7 +2,9 @@ import { HttpEventType, HttpResponse } from '@angular/common/http'
2import { Component, OnInit, ViewChild } from '@angular/core' 2import { Component, OnInit, ViewChild } from '@angular/core'
3import { FormBuilder, FormGroup } from '@angular/forms' 3import { FormBuilder, FormGroup } from '@angular/forms'
4import { Router } from '@angular/router' 4import { Router } from '@angular/router'
5import { UserService } from '@app/shared'
5import { NotificationsService } from 'angular2-notifications' 6import { NotificationsService } from 'angular2-notifications'
7import { BytesPipe } from 'ngx-pipes'
6import { VideoPrivacy } from '../../../../../shared/models/videos' 8import { VideoPrivacy } from '../../../../../shared/models/videos'
7import { AuthService, ServerService } from '../../core' 9import { AuthService, ServerService } from '../../core'
8import { FormReactive } from '../../shared' 10import { FormReactive } from '../../shared'
@@ -31,12 +33,12 @@ export class VideoAddComponent extends FormReactive implements OnInit {
31 uuid: '' 33 uuid: ''
32 } 34 }
33 35
34 error: string = null
35 form: FormGroup 36 form: FormGroup
36 formErrors: { [ id: string ]: string } = {} 37 formErrors: { [ id: string ]: string } = {}
37 validationMessages: ValidatorMessage = {} 38 validationMessages: ValidatorMessage = {}
38 39
39 userVideoChannels = [] 40 userVideoChannels = []
41 userVideoQuotaUsed = 0
40 videoPrivacies = [] 42 videoPrivacies = []
41 firstStepPrivacyId = 0 43 firstStepPrivacyId = 0
42 firstStepChannelId = 0 44 firstStepChannelId = 0
@@ -46,6 +48,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
46 private router: Router, 48 private router: Router,
47 private notificationsService: NotificationsService, 49 private notificationsService: NotificationsService,
48 private authService: AuthService, 50 private authService: AuthService,
51 private userService: UserService,
49 private serverService: ServerService, 52 private serverService: ServerService,
50 private videoService: VideoService 53 private videoService: VideoService
51 ) { 54 ) {
@@ -67,6 +70,9 @@ export class VideoAddComponent extends FormReactive implements OnInit {
67 populateAsyncUserVideoChannels(this.authService, this.userVideoChannels) 70 populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
68 .then(() => this.firstStepChannelId = this.userVideoChannels[0].id) 71 .then(() => this.firstStepChannelId = this.userVideoChannels[0].id)
69 72
73 this.userService.getMyVideoQuotaUsed()
74 .subscribe(data => this.userVideoQuotaUsed = data.videoQuotaUsed)
75
70 this.serverService.videoPrivaciesLoaded 76 this.serverService.videoPrivaciesLoaded
71 .subscribe( 77 .subscribe(
72 () => { 78 () => {
@@ -89,6 +95,18 @@ export class VideoAddComponent extends FormReactive implements OnInit {
89 95
90 uploadFirstStep () { 96 uploadFirstStep () {
91 const videofile = this.videofileInput.nativeElement.files[0] 97 const videofile = this.videofileInput.nativeElement.files[0]
98 const videoQuota = this.authService.getUser().videoQuota
99 if ((this.userVideoQuotaUsed + videofile.size) > videoQuota) {
100 const bytePipes = new BytesPipe()
101
102 const msg = 'Your video quota is exceeded with this video ' +
103 `(video size: ${bytePipes.transform(videofile.size, 0)}, ` +
104 `used: ${bytePipes.transform(this.userVideoQuotaUsed, 0)}, ` +
105 `quota: ${bytePipes.transform(videoQuota, 0)})`
106 this.notificationsService.error('Error', msg)
107 return
108 }
109
92 const name = videofile.name.replace(/\.[^/.]+$/, '') 110 const name = videofile.name.replace(/\.[^/.]+$/, '')
93 const privacy = this.firstStepPrivacyId.toString() 111 const privacy = this.firstStepPrivacyId.toString()
94 const nsfw = false 112 const nsfw = false
@@ -127,8 +145,9 @@ export class VideoAddComponent extends FormReactive implements OnInit {
127 145
128 err => { 146 err => {
129 // Reset progress 147 // Reset progress
148 this.isUploadingVideo = false
130 this.videoUploadPercents = 0 149 this.videoUploadPercents = 0
131 this.error = err.message 150 this.notificationsService.error('Error', err.message)
132 } 151 }
133 ) 152 )
134 } 153 }
@@ -152,7 +171,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
152 }, 171 },
153 172
154 err => { 173 err => {
155 this.error = 'Cannot update the video.' 174 this.notificationsService.error('Error', err.message)
156 console.error(err) 175 console.error(err)
157 } 176 }
158 ) 177 )
diff --git a/client/src/app/videos/+video-edit/video-update.component.ts b/client/src/app/videos/+video-edit/video-update.component.ts
index 941ef2478..7f41b56d8 100644
--- a/client/src/app/videos/+video-edit/video-update.component.ts
+++ b/client/src/app/videos/+video-edit/video-update.component.ts
@@ -21,7 +21,6 @@ import { VideoService } from '../../shared/video/video.service'
21export class VideoUpdateComponent extends FormReactive implements OnInit { 21export class VideoUpdateComponent extends FormReactive implements OnInit {
22 video: VideoEdit 22 video: VideoEdit
23 23
24 error: string = null
25 form: FormGroup 24 form: FormGroup
26 formErrors: { [ id: string ]: string } = {} 25 formErrors: { [ id: string ]: string } = {}
27 validationMessages: ValidatorMessage = {} 26 validationMessages: ValidatorMessage = {}
@@ -82,7 +81,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
82 81
83 err => { 82 err => {
84 console.error(err) 83 console.error(err)
85 this.error = 'Cannot fetch video.' 84 this.notificationsService.error('Error', err.message)
86 } 85 }
87 ) 86 )
88 } 87 }
@@ -108,7 +107,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
108 }, 107 },
109 108
110 err => { 109 err => {
111 this.error = 'Cannot update the video.' 110 this.notificationsService.error('Error', err.message)
112 console.error(err) 111 console.error(err)
113 } 112 }
114 ) 113 )