mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Use new upload API
This commit is contained in:
@@ -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
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user