Handled error on upload file

This commit is contained in:
Giuseppe
2018-10-09 11:56:14 +02:00
parent e7dc095156
commit a33513ef4b
3 changed files with 15 additions and 1 deletions

View File

@@ -58,6 +58,11 @@ export class UploaderComponent {
*/ */
@Output() onCompleteItem: EventEmitter<any> = new EventEmitter<any>(); @Output() onCompleteItem: EventEmitter<any> = new EventEmitter<any>();
/**
* The function to call on error occurred
*/
@Output() onUploadError: EventEmitter<any> = new EventEmitter<any>();
public uploader: FileUploader; public uploader: FileUploader;
public uploaderId: string; public uploaderId: string;
public isOverBaseDropZone = Observable.of(false); public isOverBaseDropZone = Observable.of(false);
@@ -125,6 +130,10 @@ export class UploaderComponent {
this.onCompleteItem.emit(responsePath); this.onCompleteItem.emit(responsePath);
} }
}; };
this.uploader.onErrorItem = (item: any, response: any, status: any, headers: any) => {
this.onUploadError.emit(null);
this.uploader.cancelAll();
};
this.uploader.onProgressAll = () => this.onProgress(); this.uploader.onProgressAll = () => this.onProgress();
this.uploader.onProgressItem = () => this.onProgress(); this.uploader.onProgressItem = () => this.onProgress();
} }

View File

@@ -4,4 +4,5 @@
[enableDragOverDocument]="enableDragOverDocument" [enableDragOverDocument]="enableDragOverDocument"
[onBeforeUpload]="onBeforeUpload" [onBeforeUpload]="onBeforeUpload"
[uploadFilesOptions]="uploadFilesOptions" [uploadFilesOptions]="uploadFilesOptions"
(onCompleteItem)="onCompleteItem($event)"></ds-uploader> (onCompleteItem)="onCompleteItem($event)"
(onUploadError)="onUploadError($event)"></ds-uploader>

View File

@@ -85,6 +85,10 @@ export class SubmissionUploadFilesComponent implements OnChanges {
); );
} }
public onUploadError() {
this.notificationsService.error(null, this.translate.get('submission.sections.upload.upload-failed'));
}
/** /**
* Method provided by Angular. Invoked when the instance is destroyed. * Method provided by Angular. Invoked when the instance is destroyed.
*/ */