mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
[ADF-643] upload enhancements (#1949)
* rework folder uploading - flatterns hierarchy on folder upload - performs a single traversal for the entire folder heirarchy and ends with a comple file list - allows now dropping folders on existing folders - overall code improvements * fix unit tests * readme updates * clean old and unused code * code cleanup * limit concurrent uploads * update code as per review * fix upload button for Safari * fixes for Safari - Safari compatibility - code updates based on review * fix code * fix unit tests
This commit is contained in:
committed by
Eugenio Romano
parent
6faf2b2ec1
commit
c2c75bc73d
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Directive, EventEmitter, Input, Output, OnInit, OnDestroy, ElementRef, NgZone } from '@angular/core';
|
||||
import { FileUtils } from 'ng2-alfresco-core';
|
||||
|
||||
@Directive({
|
||||
selector: '[file-draggable]'
|
||||
@@ -28,7 +29,7 @@ export class FileDraggableDirective implements OnInit, OnDestroy {
|
||||
enabled: boolean = true;
|
||||
|
||||
@Output()
|
||||
onFilesDropped: EventEmitter<any> = new EventEmitter();
|
||||
onFilesDropped: EventEmitter<File[]> = new EventEmitter<File[]>();
|
||||
|
||||
@Output()
|
||||
onFilesEntityDropped: EventEmitter<any> = new EventEmitter();
|
||||
@@ -73,16 +74,20 @@ export class FileDraggableDirective implements OnInit, OnDestroy {
|
||||
if (typeof items[i].webkitGetAsEntry !== 'undefined') {
|
||||
let item = items[i].webkitGetAsEntry();
|
||||
if (item) {
|
||||
this.traverseFileTree(item);
|
||||
if (item.isFile) {
|
||||
this.onFilesEntityDropped.emit(item);
|
||||
} else if (item.isDirectory) {
|
||||
this.onFolderEntityDropped.emit(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let files = event.dataTransfer.files;
|
||||
let files = FileUtils.toFileArray(event.dataTransfer.files);
|
||||
this.onFilesDropped.emit(files);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// safari or FF
|
||||
let files = event.dataTransfer.files;
|
||||
let files = FileUtils.toFileArray(event.dataTransfer.files);
|
||||
this.onFilesDropped.emit(files);
|
||||
}
|
||||
|
||||
@@ -90,22 +95,6 @@ export class FileDraggableDirective implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Travers all the files and folders, and emit an event for each file or directory.
|
||||
*
|
||||
* @param {Object} item - can contains files or folders.
|
||||
*/
|
||||
private traverseFileTree(item: any): void {
|
||||
if (item.isFile) {
|
||||
let self = this;
|
||||
self.onFilesEntityDropped.emit(item);
|
||||
} else {
|
||||
if (item.isDirectory) {
|
||||
this.onFolderEntityDropped.emit(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the style of the drag area when a file drag in.
|
||||
*
|
||||
|
Reference in New Issue
Block a user