Fix upload folder not supported for Safari and Firefox

This commit is contained in:
mauriziovitale84
2016-06-28 17:56:10 +01:00
parent 221c0e3d9b
commit e4546061f1
8 changed files with 158 additions and 22 deletions

View File

@@ -76,15 +76,37 @@ export class UploadDragAreaComponent {
*/
onFilesDropped(files: File[]): void {
if (files.length) {
this._uploaderService.addToQueue(files);
this._uploaderService.uploadFilesInTheQueue(this.currentFolderPath, this.onSuccess);
let latestFilesAdded = this._uploaderService.getQueue();
if (this.showUdoNotificationBar) {
this._showUndoNotificationBar(latestFilesAdded);
if (this.checkValidity(files)) {
this._uploaderService.addToQueue(files);
this._uploaderService.uploadFilesInTheQueue(this.currentFolderPath, this.onSuccess);
let latestFilesAdded = this._uploaderService.getQueue();
if (this.showUdoNotificationBar) {
this._showUndoNotificationBar(latestFilesAdded);
}
} else {
let errorMessage: any;
errorMessage = this.translate.get('FILE_UPLOAD.MESSAGES.FOLDER_NOT_SUPPORTED');
if (this.showUdoNotificationBar) {
this._showErrorNotificationBar(errorMessage.value);
} else {
console.error(errorMessage.value);
}
}
}
}
/**
* Check il the file is valid or not
* @param files
* @returns {boolean}
*/
checkValidity(files: File[]): boolean {
if (files.length && files[0].type === '') {
return false;
}
return true;
}
/**
* Called when the file are dropped in the drag area
* @param item - FileEntity
@@ -126,10 +148,12 @@ export class UploadDragAreaComponent {
error => {
let errorMessagePlaceholder = this.getErrorMessage(error.response);
let errorMessage = this.formatString(errorMessagePlaceholder, [folder.name]);
if (errorMessage) {
if (this.showUdoNotificationBar) {
this._showErrorNotificationBar(errorMessage);
} else {
console.error(errorMessage);
}
console.log(error);
}
);
}