aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/video-add
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/videos/video-add')
-rw-r--r--client/src/app/videos/video-add/video-add.component.html2
-rw-r--r--client/src/app/videos/video-add/video-add.component.ts13
2 files changed, 15 insertions, 0 deletions
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 @@
1<h3>Upload a video</h3> 1<h3>Upload a video</h3>
2 2
3<div *ngIf="error" class="alert alert-danger">{{ error }}</div>
4
3<form (ngSubmit)="uploadFile()" #videoForm="ngForm"> 5<form (ngSubmit)="uploadFile()" #videoForm="ngForm">
4 <div class="form-group"> 6 <div class="form-group">
5 <label for="name">Video name</label> 7 <label for="name">Video name</label>
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';
18}) 18})
19 19
20export class VideoAddComponent implements OnInit { 20export class VideoAddComponent implements OnInit {
21 error: string = null;
21 fileToUpload: any; 22 fileToUpload: any;
22 progressBar: { value: number; max: number; } = { value: 0, max: 0 }; 23 progressBar: { value: number; max: number; } = { value: 0, max: 0 };
23 user: User; 24 user: User;
@@ -57,11 +58,23 @@ export class VideoAddComponent implements OnInit {
57 58
58 // Print all the videos once it's finished 59 // Print all the videos once it's finished
59 this.router.navigate(['VideosList']); 60 this.router.navigate(['VideosList']);
61 },
62
63 fail: (e, data) => {
64 const xhr = data.jqXHR;
65 if (xhr.status === 400) {
66 this.error = xhr.responseText;
67 } else {
68 this.error = 'Unknow error';
69 }
70
71 console.error(data);
60 } 72 }
61 }); 73 });
62 } 74 }
63 75
64 uploadFile() { 76 uploadFile() {
77 this.error = null;
65 this.form.formData = jQuery(this.elementRef.nativeElement).find('form').serializeArray(); 78 this.form.formData = jQuery(this.elementRef.nativeElement).find('form').serializeArray();
66 this.form.headers = this.authService.getRequestHeader().toJSON(); 79 this.form.headers = this.authService.getRequestHeader().toJSON();
67 this.form.submit(); 80 this.form.submit();