mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
Handled error on upload file
This commit is contained in:
@@ -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();
|
||||||
}
|
}
|
||||||
|
@@ -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>
|
||||||
|
@@ -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.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user