[ADF-610] Upload button and DnD area should not upload hidden files and folders (#1908)

[ADF-610]  upload cleanup
- more strongly typing
- api improvements

* Upload cleanup and api improvements

- remove old unused settings (formFields variable)
- individual options for uploaded files (i.e. versioning)
- upload button and drag-and-drop area now set individual settings for file versioning

* exclude hidden files from upload
This commit is contained in:
Denys Vuika
2017-05-26 14:39:36 +01:00
committed by Eugenio Romano
parent 2e1649e1da
commit 9bb7d90670
7 changed files with 90 additions and 138 deletions

View File

@@ -66,11 +66,6 @@ export class UploadDragAreaComponent {
}
}
ngOnChanges(changes) {
let formFields = this.createFormFields();
this.uploadService.setOptions(formFields, this.versioning);
}
/**
* Handles 'upload-files' events raised by child components.
* @param e DOM event
@@ -79,13 +74,14 @@ export class UploadDragAreaComponent {
e.stopPropagation();
e.preventDefault();
let files = e.detail.files;
let files: File[] = e.detail.files;
if (files && files.length > 0) {
const fileModels = files.map(f => new FileModel(f, { newVersion: this.versioning }));
if (e.detail.data.obj.entry.isFolder) {
let id = e.detail.data.obj.entry.id;
this.onFilesDropped(files, id, '/');
this.onFilesDropped(fileModels, id, '/');
} else {
this.onFilesDropped(files);
this.onFilesDropped(fileModels);
}
}
}
@@ -95,9 +91,9 @@ export class UploadDragAreaComponent {
*
* @param {File[]} files - files dropped in the drag area.
*/
onFilesDropped(files: File[], rootId?: string, directory?: string): void {
onFilesDropped(files: FileModel[], rootId?: string, directory?: string): void {
if (files.length) {
this.uploadService.addToQueue(files);
this.uploadService.addToQueue(...files);
this.uploadService.uploadFilesInTheQueue(rootId || this.rootFolderId, directory || this.currentFolderPath, this.onSuccess);
let latestFilesAdded = this.uploadService.getQueue();
if (this.showNotificationBar) {
@@ -111,8 +107,9 @@ export class UploadDragAreaComponent {
* @param item - FileEntity
*/
onFilesEntityDropped(item: any): void {
item.file((file: any) => {
this.uploadService.addToQueue([file]);
item.file((file: File) => {
const fileModel = new FileModel(file, { newVersion: this.versioning });
this.uploadService.addToQueue(fileModel);
let path = item.fullPath.replace(item.name, '');
let filePath = this.currentFolderPath + path;
this.uploadService.uploadFilesInTheQueue(this.rootFolderId, filePath, this.onSuccess);
@@ -228,12 +225,4 @@ export class UploadDragAreaComponent {
}
return message;
}
private createFormFields(): any {
return {
formFields: {
overwrite: true
}
};
}
}