mirror of https://github.com/Chocobozzz/PeerTube
Handle error for the video upload
parent
fe3b20cdaf
commit
1cdb5c0f58
|
@ -1,5 +1,7 @@
|
|||
<h3>Upload a video</h3>
|
||||
|
||||
<div *ngIf="error" class="alert alert-danger">{{ error }}</div>
|
||||
|
||||
<form (ngSubmit)="uploadFile()" #videoForm="ngForm">
|
||||
<div class="form-group">
|
||||
<label for="name">Video name</label>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
<div class="row videos-info">
|
||||
<div class="col-md-9 videos-total-results"> {{ pagination.total }} videos</div>
|
||||
<div class="col-md-9 videos-total-results">
|
||||
{{ pagination.total }} videos
|
||||
|
||||
<my-loader [loading]="loading"></my-loader>
|
||||
</div>
|
||||
<my-video-sort class="col-md-3" [currentSort]="sort" (sort)="onSort($event)"></my-video-sort>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ function videosAdd (req, res, next) {
|
|||
}
|
||||
|
||||
if (duration > constants.MAXIMUM_VIDEO_DURATION) {
|
||||
return res.status(400).send('Duration of the video file is too big (' + constants.MAXIMUM_VIDEO_DURATION + ').')
|
||||
return res.status(400).send('Duration of the video file is too big (max: ' + constants.MAXIMUM_VIDEO_DURATION + 's).')
|
||||
}
|
||||
|
||||
videoFile.duration = duration
|
||||
|
|
Loading…
Reference in New Issue