Use new upload API

This commit is contained in:
mauriziovitale84
2016-06-22 16:17:19 +01:00
parent 970c478d5b
commit 05c0a8246a
5 changed files with 42 additions and 77 deletions

View File

@@ -51,9 +51,6 @@ export class UploadDragAreaComponent {
@Input()
showUdoNotificationBar: boolean = true;
@Input()
uploaddirectory: string = '';
@Input()
currentFolderPath: string = '/Sites/swsdp/documentLibrary';
@@ -65,15 +62,8 @@ export class UploadDragAreaComponent {
constructor(private _uploaderService: UploadService,
translate: AlfrescoTranslationService) {
let site = this.getSiteId();
let container = this.getContainerId();
this._uploaderService.setOptions({
formFields: {
siteid: site,
containerid: container
}
});
let formFields = this.createFormFields();
this._uploaderService.setOptions(formFields);
this.translate = translate;
this.translate.addTranslationFolder('node_modules/ng2-alfresco-upload');
@@ -87,7 +77,7 @@ export class UploadDragAreaComponent {
onFilesDropped(files: File[]): void {
if (files.length) {
this._uploaderService.addToQueue(files);
this._uploaderService.uploadFilesInTheQueue(this.uploaddirectory, this.onSuccess);
this._uploaderService.uploadFilesInTheQueue(this.currentFolderPath, this.onSuccess);
let latestFilesAdded = this._uploaderService.getQueue();
if (this.showUdoNotificationBar) {
this._showUndoNotificationBar(latestFilesAdded);
@@ -104,7 +94,7 @@ export class UploadDragAreaComponent {
item.file(function (file: any) {
self._uploaderService.addToQueue([file]);
let path = item.fullPath.replace(item.name, '');
let filePath = self.uploaddirectory + path;
let filePath = self.currentFolderPath + path;
self._uploaderService.uploadFilesInTheQueue(filePath, self.onSuccess);
let latestFilesAdded = self._uploaderService.getQueue();
if (self.showUdoNotificationBar) {
@@ -162,22 +152,6 @@ export class UploadDragAreaComponent {
}
}
/**
* Return the site from the path
* @returns {string}
*/
private getSiteId(): string {
return this.currentFolderPath.replace('/Sites/', '').split('/')[0];
}
/**
* Return the container from the path
* @returns {string}
*/
private getContainerId(): string {
return this.currentFolderPath.replace('/Sites/', '').split('/')[1];
}
/**
* Show undo notification bar.
*
@@ -246,4 +220,12 @@ export class UploadDragAreaComponent {
}
return message;
}
private createFormFields(): any {
return {
formFields: {
overwrite: true
}
};
}
}