From 1cdb5c0f582502eac4d851cecc015e81cf16316b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 4 Jun 2016 20:37:38 +0200 Subject: Handle error for the video upload --- client/src/app/videos/video-add/video-add.component.html | 2 ++ client/src/app/videos/video-add/video-add.component.ts | 13 +++++++++++++ client/src/app/videos/video-list/video-list.component.html | 6 +++++- 3 files changed, 20 insertions(+), 1 deletion(-) (limited to 'client/src') diff --git a/client/src/app/videos/video-add/video-add.component.html b/client/src/app/videos/video-add/video-add.component.html index 80d229cb8..cbe274e8a 100644 --- a/client/src/app/videos/video-add/video-add.component.html +++ b/client/src/app/videos/video-add/video-add.component.html @@ -1,5 +1,7 @@

Upload a video

+
{{ error }}
+
diff --git a/client/src/app/videos/video-add/video-add.component.ts b/client/src/app/videos/video-add/video-add.component.ts index 8df4f951b..144879a54 100644 --- a/client/src/app/videos/video-add/video-add.component.ts +++ b/client/src/app/videos/video-add/video-add.component.ts @@ -18,6 +18,7 @@ import { AuthService, User } from '../../shared'; }) export class VideoAddComponent implements OnInit { + error: string = null; fileToUpload: any; progressBar: { value: number; max: number; } = { value: 0, max: 0 }; user: User; @@ -57,11 +58,23 @@ export class VideoAddComponent implements OnInit { // Print all the videos once it's finished this.router.navigate(['VideosList']); + }, + + fail: (e, data) => { + const xhr = data.jqXHR; + if (xhr.status === 400) { + this.error = xhr.responseText; + } else { + this.error = 'Unknow error'; + } + + console.error(data); } }); } uploadFile() { + this.error = null; this.form.formData = jQuery(this.elementRef.nativeElement).find('form').serializeArray(); this.form.headers = this.authService.getRequestHeader().toJSON(); this.form.submit(); diff --git a/client/src/app/videos/video-list/video-list.component.html b/client/src/app/videos/video-list/video-list.component.html index 155025b5e..00392a81f 100644 --- a/client/src/app/videos/video-list/video-list.component.html +++ b/client/src/app/videos/video-list/video-list.component.html @@ -1,5 +1,9 @@
-
{{ pagination.total }} videos
+
+ {{ pagination.total }} videos + + +
-- cgit v1.2.3