aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-edit/video-add.component.ts
diff options
context:
space:
mode:
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.ts16
1 files changed, 15 insertions, 1 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 d0d17fa86..6e0830ab7 100644
--- a/client/src/app/videos/+video-edit/video-add.component.ts
+++ b/client/src/app/videos/+video-edit/video-add.component.ts
@@ -27,6 +27,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
27 27
28 isUploadingVideo = false 28 isUploadingVideo = false
29 videoUploaded = false 29 videoUploaded = false
30 videoUploadObservable = null
30 videoUploadPercents = 0 31 videoUploadPercents = 0
31 videoUploadedIds = { 32 videoUploadedIds = {
32 id: 0, 33 id: 0,
@@ -93,6 +94,16 @@ export class VideoAddComponent extends FormReactive implements OnInit {
93 return this.form.valid 94 return this.form.valid
94 } 95 }
95 96
97 cancelUpload () {
98 if (this.videoUploadObservable !== null) {
99 this.videoUploadObservable.unsubscribe()
100 this.isUploadingVideo = false
101 this.videoUploadPercents = 0
102 this.notificationsService.error('Error', 'Upload cancelled')
103 this.videoUploadObservable = null
104 }
105 }
106
96 uploadFirstStep () { 107 uploadFirstStep () {
97 const videofile = this.videofileInput.nativeElement.files[0] 108 const videofile = this.videofileInput.nativeElement.files[0]
98 if (!videofile) return 109 if (!videofile) return
@@ -132,7 +143,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
132 channelId 143 channelId
133 }) 144 })
134 145
135 this.videoService.uploadVideo(formData).subscribe( 146 this.videoUploadObservable = this.videoService.uploadVideo(formData).subscribe(
136 event => { 147 event => {
137 if (event.type === HttpEventType.UploadProgress) { 148 if (event.type === HttpEventType.UploadProgress) {
138 this.videoUploadPercents = Math.round(100 * event.loaded / event.total) 149 this.videoUploadPercents = Math.round(100 * event.loaded / event.total)
@@ -142,6 +153,8 @@ export class VideoAddComponent extends FormReactive implements OnInit {
142 this.videoUploaded = true 153 this.videoUploaded = true
143 154
144 this.videoUploadedIds = event.body.video 155 this.videoUploadedIds = event.body.video
156
157 this.videoUploadObservable = null
145 } 158 }
146 }, 159 },
147 160
@@ -149,6 +162,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
149 // Reset progress 162 // Reset progress
150 this.isUploadingVideo = false 163 this.isUploadingVideo = false
151 this.videoUploadPercents = 0 164 this.videoUploadPercents = 0
165 this.videoUploadObservable = null
152 this.notificationsService.error('Error', err.message) 166 this.notificationsService.error('Error', err.message)
153 } 167 }
154 ) 168 )