#46 Upload files in a folder

This commit is contained in:
mauriziovitale84
2016-05-12 12:55:35 +01:00
parent 4898a2e63e
commit 3c2167273f
17 changed files with 85 additions and 27 deletions

View File

@@ -1,5 +1,5 @@
<alfresco-upload-drag-area [showUploadDialog]="true"> <alfresco-upload-drag-area [showUploadDialog]="true" uploaddirectory="{{relativePath}}" >
<alfresco-document-list> <alfresco-document-list (folderClick)="refreshDirectyory($event)">
<content-columns> <content-columns>
<content-column source="$thumbnail"></content-column> <content-column source="$thumbnail"></content-column>
<content-column <content-column

View File

@@ -39,6 +39,8 @@ export class FilesComponent {
breadcrumb: boolean = false; breadcrumb: boolean = false;
navigation: boolean = true; navigation: boolean = true;
events: any[] = []; events: any[] = [];
absolutePath: string = '';
relativePath: string = '';
constructor(documentActions: DocumentActionsService) { constructor(documentActions: DocumentActionsService) {
documentActions.setHandler('my-handler', this.myDocumentActionHandler.bind(this)); documentActions.setHandler('my-handler', this.myDocumentActionHandler.bind(this));
@@ -55,4 +57,17 @@ export class FilesComponent {
myFolderAction1(event) { myFolderAction1(event) {
alert('Custom folder action for ' + event.value.displayName); alert('Custom folder action for ' + event.value.displayName);
} }
refreshDirectyory(event: Object) {
this.absolutePath = event.value;
this.relativePath = this.getRelativeDirectory(this.absolutePath);
}
getRelativeDirectory(currentFolderPath: string): string {
if(currentFolderPath.indexOf('swsdp/documentLibrary/') !=-1) {
return currentFolderPath.replace('swsdp/documentLibrary/', '')
} else {
return currentFolderPath.replace('swsdp/documentLibrary', '')
}
}
} }

View File

@@ -46,6 +46,7 @@ System.register(['angular2/core', './../services/alfresco.service', './../models
this.navigate = true; this.navigate = true;
this.breadcrumb = false; this.breadcrumb = false;
this.itemClick = new core_1.EventEmitter(); this.itemClick = new core_1.EventEmitter();
this.folderClick = new core_1.EventEmitter();
this.rootFolder = { this.rootFolder = {
name: 'Document Library', name: 'Document Library',
path: 'Sites/swsdp/documentLibrary' path: 'Sites/swsdp/documentLibrary'
@@ -190,7 +191,10 @@ System.register(['angular2/core', './../services/alfresco.service', './../models
*/ */
DocumentList.prototype.displayFolderContent = function (path) { DocumentList.prototype.displayFolderContent = function (path) {
var _this = this; var _this = this;
if (path) { if (path !== null) {
this.folderClick.emit({
value: path
});
this.currentFolderPath = path; this.currentFolderPath = path;
this._alfrescoService this._alfrescoService
.getFolder(path) .getFolder(path)
@@ -266,6 +270,10 @@ System.register(['angular2/core', './../services/alfresco.service', './../models
core_1.Output(), core_1.Output(),
__metadata('design:type', core_1.EventEmitter) __metadata('design:type', core_1.EventEmitter)
], DocumentList.prototype, "itemClick", void 0); ], DocumentList.prototype, "itemClick", void 0);
__decorate([
core_1.Output(),
__metadata('design:type', core_1.EventEmitter)
], DocumentList.prototype, "folderClick", void 0);
DocumentList = __decorate([ DocumentList = __decorate([
core_1.Component({ core_1.Component({
moduleId: __moduleName, moduleId: __moduleName,

File diff suppressed because one or more lines are too long

View File

@@ -53,6 +53,9 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
@Output() @Output()
itemClick: EventEmitter<any> = new EventEmitter(); itemClick: EventEmitter<any> = new EventEmitter();
@Output()
folderClick: EventEmitter<any> = new EventEmitter();
rootFolder = { rootFolder = {
name: 'Document Library', name: 'Document Library',
path: 'Sites/swsdp/documentLibrary' path: 'Sites/swsdp/documentLibrary'
@@ -221,6 +224,9 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
*/ */
displayFolderContent(path) { displayFolderContent(path) {
if (path !== null) { if (path !== null) {
this.folderClick.emit({
value: path
});
this.currentFolderPath = path; this.currentFolderPath = path;
this._alfrescoService this._alfrescoService
.getFolder(path) .getFolder(path)

View File

@@ -17,6 +17,7 @@
import { ElementRef } from 'angular2/core'; import { ElementRef } from 'angular2/core';
import { FileModel } from '../models/file.model'; import { FileModel } from '../models/file.model';
import { FileUploadingDialogComponent } from './file-uploading-dialog.component'; import { FileUploadingDialogComponent } from './file-uploading-dialog.component';
import { TranslateService } from 'ng2-translate/ng2-translate';
/** /**
* <alfresco-upload-button [showDialogUpload]="boolean" * <alfresco-upload-button [showDialogUpload]="boolean"
* [showUdoNotificationBar]="boolean" * [showUdoNotificationBar]="boolean"
@@ -46,8 +47,10 @@ export declare class UploadButtonComponent {
uploadFolders: boolean; uploadFolders: boolean;
multipleFiles: boolean; multipleFiles: boolean;
acceptedFilesType: string; acceptedFilesType: string;
uploaddirectory: string;
filesUploadingList: FileModel[]; filesUploadingList: FileModel[];
constructor(el: ElementRef); translate: TranslateService;
constructor(el: ElementRef, translate: TranslateService);
/** /**
* Method called when files are dropped in the drag area. * Method called when files are dropped in the drag area.
* *
@@ -64,4 +67,9 @@ export declare class UploadButtonComponent {
* Show the upload dialog. * Show the upload dialog.
*/ */
private _showDialog(); private _showDialog();
/**
* Initial configuration for Multi language
* @param translate
*/
translationInit(translate: TranslateService): void;
} }

View File

@@ -70,6 +70,7 @@ System.register(['angular2/core', '../services/upload.service', './file-uploadin
this.uploadFolders = false; this.uploadFolders = false;
this.multipleFiles = false; this.multipleFiles = false;
this.acceptedFilesType = '*'; this.acceptedFilesType = '*';
this.uploaddirectory = '';
this.filesUploadingList = []; this.filesUploadingList = [];
console.log('UploadComponent constructor', el); console.log('UploadComponent constructor', el);
this._uploaderService = new upload_service_1.UploadService({ this._uploaderService = new upload_service_1.UploadService({
@@ -94,6 +95,7 @@ System.register(['angular2/core', '../services/upload.service', './file-uploadin
var files = $event.currentTarget.files; var files = $event.currentTarget.files;
if (files.length) { if (files.length) {
var latestFilesAdded = this._uploaderService.addToQueue(files); var latestFilesAdded = this._uploaderService.addToQueue(files);
this._uploaderService.uploadFilesInTheQueue(this.uploaddirectory);
this.filesUploadingList = this._uploaderService.getQueue(); this.filesUploadingList = this._uploaderService.getQueue();
if (this.showUploadDialog) { if (this.showUploadDialog) {
this._showDialog(); this._showDialog();
@@ -168,6 +170,10 @@ System.register(['angular2/core', '../services/upload.service', './file-uploadin
core_1.Input(), core_1.Input(),
__metadata('design:type', String) __metadata('design:type', String)
], UploadButtonComponent.prototype, "acceptedFilesType", void 0); ], UploadButtonComponent.prototype, "acceptedFilesType", void 0);
__decorate([
core_1.Input(),
__metadata('design:type', String)
], UploadButtonComponent.prototype, "uploaddirectory", void 0);
UploadButtonComponent = __decorate([ UploadButtonComponent = __decorate([
core_1.Component({ core_1.Component({
selector: 'alfresco-upload-button', selector: 'alfresco-upload-button',

View File

@@ -1 +1 @@
{"version":3,"file":"upload-button.component.js","sourceRoot":"","sources":["upload-button.component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAYH;;;;;;;;;;;;;;;;;;eAkBG;YASH;gBA6BI,+BAAmB,EAAc,EACrB,SAA2B;oBADpB,OAAE,GAAF,EAAE,CAAY;oBAlBjC,qBAAgB,GAAY,IAAI,CAAC;oBAGjC,2BAAsB,GAAY,IAAI,CAAC;oBAGvC,kBAAa,GAAY,KAAK,CAAC;oBAG/B,kBAAa,GAAY,KAAK,CAAC;oBAG/B,sBAAiB,GAAW,GAAG,CAAC;oBAEhC,uBAAkB,GAAiB,EAAE,CAAC;oBAMlC,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;oBAE/C,IAAI,CAAC,gBAAgB,GAAG,IAAI,8BAAa,CAAC;wBACtC,GAAG,EAAE,wDAAwD;wBAC7D,eAAe,EAAE,IAAI;wBACrB,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC;wBAC9B,eAAe,EAAE,OAAO;wBACxB,SAAS,EAAE,UAAU;wBACrB,UAAU,EAAE;4BACR,MAAM,EAAE,OAAO;4BACf,WAAW,EAAE,iBAAiB;yBACjC;qBACJ,CAAC,CAAC;oBAEH,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;gBACpC,CAAC;gBAED;;;;mBAIG;gBACH,4CAAY,GAAZ,UAAa,MAAM;oBACf,IAAI,KAAK,GAAG,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC;oBACvC,EAAE,CAAC,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5GD;oBAAC,gBAAS,CAAC,qBAAqB,CAAC;;kFAAA;gBAGjC;oBAAC,gBAAS,CAAC,qBAAqB,CAAC;;2FAAA;gBAGjC;oBAAC,YAAK,EAAE;;+EAAA;gBAGR;oBAAC,YAAK,EAAE;;qFAAA;gBAGR;oBAAC,YAAK,EAAE;;4EAAA;gBAGR;oBAAC,YAAK,EAAE;;4EAAA;gBAGR;oBAAC,YAAK,EAAE;;gFAAA;gBAGR;oBAAC,YAAK,EAAE;;8EAAA;gBAjCZ;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,wBAAwB;wBAClC,QAAQ,EAAE,YAAY;wBACtB,UAAU,EAAE,CAAC,8DAA4B,CAAC;wBAC1C,WAAW,EAAE,gCAAgC;wBAC7C,SAAS,EAAE,CAAC,+BAA+B,CAAC;wBAC5C,KAAK,EAAE,CAAC,6BAAa,CAAC;qBACzB,CAAC;;yCAAA;gBAkHF,4BAAC;YAAD,CAAC,AAjHD,IAiHC;YAjHD,yDAiHC,CAAA"}

View File

@@ -77,6 +77,9 @@ export class UploadButtonComponent {
@Input() @Input()
acceptedFilesType: string = '*'; acceptedFilesType: string = '*';
@Input()
uploaddirectory: string = '';
filesUploadingList: FileModel [] = []; filesUploadingList: FileModel [] = [];
translate: TranslateService; translate: TranslateService;
@@ -109,6 +112,7 @@ export class UploadButtonComponent {
let files = $event.currentTarget.files; let files = $event.currentTarget.files;
if (files.length) { if (files.length) {
let latestFilesAdded = this._uploaderService.addToQueue(files); let latestFilesAdded = this._uploaderService.addToQueue(files);
this._uploaderService.uploadFilesInTheQueue(this.uploaddirectory);
this.filesUploadingList = this._uploaderService.getQueue(); this.filesUploadingList = this._uploaderService.getQueue();
if (this.showUploadDialog) { if (this.showUploadDialog) {
this._showDialog(); this._showDialog();

View File

@@ -33,6 +33,7 @@ export declare class UploadDragAreaComponent {
fileUploadingDialogComponent: FileUploadingDialogComponent; fileUploadingDialogComponent: FileUploadingDialogComponent;
showUploadDialog: boolean; showUploadDialog: boolean;
filesUploadingList: FileModel[]; filesUploadingList: FileModel[];
uploaddirectory: string;
constructor(el: ElementRef); constructor(el: ElementRef);
/** /**
* Method called when files are dropped in the drag area. * Method called when files are dropped in the drag area.

View File

@@ -58,6 +58,7 @@ System.register(['angular2/core', '../services/upload.service', './file-uploadin
this.el = el; this.el = el;
this.showUploadDialog = true; this.showUploadDialog = true;
this.filesUploadingList = []; this.filesUploadingList = [];
this.uploaddirectory = '';
console.log('UploadComponent constructor', el); console.log('UploadComponent constructor', el);
this._uploaderService = new upload_service_1.UploadService({ this._uploaderService = new upload_service_1.UploadService({
url: 'http://192.168.99.100:8080/alfresco/service/api/upload', url: 'http://192.168.99.100:8080/alfresco/service/api/upload',
@@ -79,6 +80,7 @@ System.register(['angular2/core', '../services/upload.service', './file-uploadin
UploadDragAreaComponent.prototype.onFilesDropped = function (files) { UploadDragAreaComponent.prototype.onFilesDropped = function (files) {
if (files.length) { if (files.length) {
this._uploaderService.addToQueue(files); this._uploaderService.addToQueue(files);
this._uploaderService.uploadFilesInTheQueue(this.uploaddirectory);
this.filesUploadingList = this._uploaderService.getQueue(); this.filesUploadingList = this._uploaderService.getQueue();
if (this.showUploadDialog) { if (this.showUploadDialog) {
this._showDialog(); this._showDialog();
@@ -99,6 +101,10 @@ System.register(['angular2/core', '../services/upload.service', './file-uploadin
core_1.Input(), core_1.Input(),
__metadata('design:type', Boolean) __metadata('design:type', Boolean)
], UploadDragAreaComponent.prototype, "showUploadDialog", void 0); ], UploadDragAreaComponent.prototype, "showUploadDialog", void 0);
__decorate([
core_1.Input(),
__metadata('design:type', String)
], UploadDragAreaComponent.prototype, "uploaddirectory", void 0);
UploadDragAreaComponent = __decorate([ UploadDragAreaComponent = __decorate([
core_1.Component({ core_1.Component({
selector: 'alfresco-upload-drag-area', selector: 'alfresco-upload-drag-area',

View File

@@ -1 +1 @@
{"version":3,"file":"upload-drag-area.component.js","sourceRoot":"","sources":["upload-drag-area.component.ts"],"names":[],"mappings":"AAAA;;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,EAAE,CAAC;wBAC3D,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;4BACxB,IAAI,CAAC,WAAW,EAAE,CAAC;wBACvB,CAAC;oBACL,CAAC;gBACL,CAAC;gBAED;;mBAEG;gBACK,6CAAW,GAAnB;oBACI,IAAI,CAAC,4BAA4B,CAAC,UAAU,EAAE,CAAC;gBACnD,CAAC;gBAhDD;oBAAC,gBAAS,CAAC,qBAAqB,CAAC;;6FAAA;gBAGjC;oBAAC,YAAK,EAAE;;iFAAA;gBAKR;oBAAC,YAAK,EAAE;;gFAAA;gBAnBZ;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,2BAA2B;wBACrC,QAAQ,EAAE,YAAY;wBACtB,UAAU,EAAE,CAAC,iDAAsB,EAAE,8DAA4B,CAAC;wBAClE,WAAW,EAAE,mCAAmC;wBAChD,SAAS,EAAE,CAAC,kCAAkC,CAAC;qBAClD,CAAC;;2CAAA;gBAsDF,8BAAC;YAAD,CAAC,AArDD,IAqDC;YArDD,6DAqDC,CAAA"}

View File

@@ -16,7 +16,7 @@
*/ */
import {Component, ViewChild, ElementRef, Input} from 'angular2/core'; import {Component, ViewChild, ElementRef, Input, EventEmitter} from 'angular2/core';
import {UploadService} from '../services/upload.service'; import {UploadService} from '../services/upload.service';
import {FileModel} from '../models/file.model'; import {FileModel} from '../models/file.model';
import {FileUploadingDialogComponent} from './file-uploading-dialog.component'; import {FileUploadingDialogComponent} from './file-uploading-dialog.component';
@@ -53,6 +53,9 @@ export class UploadDragAreaComponent {
filesUploadingList: FileModel [] = []; filesUploadingList: FileModel [] = [];
@Input()
uploaddirectory: string = '';
constructor(public el: ElementRef) { constructor(public el: ElementRef) {
console.log('UploadComponent constructor', el); console.log('UploadComponent constructor', el);
@@ -77,6 +80,7 @@ export class UploadDragAreaComponent {
onFilesDropped(files): void { onFilesDropped(files): void {
if (files.length) { if (files.length) {
this._uploaderService.addToQueue(files); this._uploaderService.addToQueue(files);
this._uploaderService.uploadFilesInTheQueue(this.uploaddirectory);
this.filesUploadingList = this._uploaderService.getQueue(); this.filesUploadingList = this._uploaderService.getQueue();
if (this.showUploadDialog) { if (this.showUploadDialog) {
this._showDialog(); this._showDialog();

View File

@@ -42,20 +42,20 @@ export declare class UploadService {
*/ */
addToQueue(files: any[]): FileModel[]; addToQueue(files: any[]): FileModel[];
/** /**
* Pick all the files in the queue that are not been uploaded yet and upload it. * Pick all the files in the queue that are not been uploaded yet and upload it into the directory folder.
*/ */
private _uploadFilesInTheQueue(); uploadFilesInTheQueue(directory: string): void;
/** /**
* The method create a new XMLHttpRequest instance if doesn't exist * The method create a new XMLHttpRequest instance if doesn't exist
*/ */
private _configureXMLHttpRequest(); private _configureXMLHttpRequest(uploadingFileModel);
/** /**
* Upload a file, and enrich it with the xhr. * Upload a file into the directory folder, and enrich it with the xhr.
* *
* @param {FileModel} - files to be uploaded. * @param {FileModel} - files to be uploaded.
* *
*/ */
uploadFile(uploadingFileModel: any): void; uploadFile(uploadingFileModel: any, directory: string): void;
/** /**
* Return all the files in the uploading queue. * Return all the files in the uploading queue.
* *

View File

@@ -65,20 +65,19 @@ System.register(['../models/file.model'], function(exports_1, context_1) {
this._queue.push(uploadingFileModel); this._queue.push(uploadingFileModel);
} }
} }
this._uploadFilesInTheQueue();
return latestFilesAdded; return latestFilesAdded;
}; };
/** /**
* Pick all the files in the queue that are not been uploaded yet and upload it. * Pick all the files in the queue that are not been uploaded yet and upload it into the directory folder.
*/ */
UploadService.prototype._uploadFilesInTheQueue = function () { UploadService.prototype.uploadFilesInTheQueue = function (directory) {
var _this = this; var _this = this;
var filesToUpload = this._queue.filter(function (uploadingFileModel) { var filesToUpload = this._queue.filter(function (uploadingFileModel) {
return !uploadingFileModel.uploading && !uploadingFileModel.done && !uploadingFileModel.abort && !uploadingFileModel.error; return !uploadingFileModel.uploading && !uploadingFileModel.done && !uploadingFileModel.abort && !uploadingFileModel.error;
}); });
filesToUpload.forEach(function (uploadingFileModel) { filesToUpload.forEach(function (uploadingFileModel) {
uploadingFileModel.setUploading(); uploadingFileModel.setUploading();
_this.uploadFile(uploadingFileModel); _this.uploadFile(uploadingFileModel, directory);
}); });
}; };
; ;
@@ -113,18 +112,19 @@ System.register(['../models/file.model'], function(exports_1, context_1) {
} }
}; };
/** /**
* Upload a file, and enrich it with the xhr. * Upload a file into the directory folder, and enrich it with the xhr.
* *
* @param {FileModel} - files to be uploaded. * @param {FileModel} - files to be uploaded.
* *
*/ */
UploadService.prototype.uploadFile = function (uploadingFileModel) { UploadService.prototype.uploadFile = function (uploadingFileModel, directory) {
var _this = this; var _this = this;
var form = new FormData(); var form = new FormData();
form.append(this._fieldName, uploadingFileModel.file, uploadingFileModel.name); form.append(this._fieldName, uploadingFileModel.file, uploadingFileModel.name);
Object.keys(this._formFields).forEach(function (key) { Object.keys(this._formFields).forEach(function (key) {
form.append(key, _this._formFields[key]); form.append(key, _this._formFields[key]);
}); });
form.append('uploaddirectory', directory);
this._configureXMLHttpRequest(uploadingFileModel); this._configureXMLHttpRequest(uploadingFileModel);
uploadingFileModel.setXMLHttpRequest(this._xmlHttpRequest); uploadingFileModel.setXMLHttpRequest(this._xmlHttpRequest);
this._xmlHttpRequest.open(this._method, this._url, true); this._xmlHttpRequest.open(this._method, this._url, true);

View File

@@ -1 +1 @@
{"version":3,"file":"upload.service.js","sourceRoot":"","sources":["upload.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;YAMH;;;;;eAKG;YACH;gBAYI,uBAAoB,OAAY;oBAAZ,YAAO,GAAP,OAAO,CAAK;oBAVxB,YAAO,GAAW,MAAM,CAAC;oBACzB,qBAAgB,GAAW,OAAO,CAAC;oBACnC,eAAU,GAAW,SAAS,CAAC;oBAC/B,eAAU,GAAW,MAAM,CAAC;oBAC5B,gBAAW,GAAW,EAAE,CAAC;oBAIzB,WAAM,GAAgB,EAAE,CAAC;oBAG7B,OAAO,CAAC,GAAG,CAAC,2BA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EAAE,IAAI,CAAC,CAAC;oBACzD,IAAI,CAAC,eAAe,CAAC,eAAe,GAAG,IAAI,CAAC,gBAAgB,CAAC;oBAE7D,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;wBAClB,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,eAAe,EAAK,IAAI,CAAC,gBAAgB,SAAI,IAAI,CAAC,UAAY,CAAC,CAAC;oBAC1G,CAAC;oBAED,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACpC,CAAC;gBAED;;;;mBAIG;gBACH,gCAAQ,GAAR;oBACI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;gBACvB,CAAC;gBAED;;;;mBAIG;gBACK,+BAAO,GAAf,UAAgB,IAAS;oBACrB,MAAM,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,YAAY,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC/E,CAAC;gBAED;;;mBAGG;gBACI,yCAAiB,GAAxB,UAAyB,GAAmB;oBACxC,IAAI,CAAC,eAAe,GAAG,GAAG,CAAC;gBAC/B,CAAC;gBACL,oBAAC;YAAD,CAAC,AAlJD,IAkJC;YAlJD,yCAkJC,CAAA"}

View File

@@ -65,21 +65,19 @@ export class UploadService {
this._queue.push(uploadingFileModel); this._queue.push(uploadingFileModel);
} }
} }
this._uploadFilesInTheQueue();
return latestFilesAdded; return latestFilesAdded;
} }
/** /**
* Pick all the files in the queue that are not been uploaded yet and upload it. * Pick all the files in the queue that are not been uploaded yet and upload it into the directory folder.
*/ */
private _uploadFilesInTheQueue(): void { public uploadFilesInTheQueue(directory: string): void {
let filesToUpload = this._queue.filter((uploadingFileModel) => { let filesToUpload = this._queue.filter((uploadingFileModel) => {
return !uploadingFileModel.uploading && !uploadingFileModel.done && !uploadingFileModel.abort && !uploadingFileModel.error; return !uploadingFileModel.uploading && !uploadingFileModel.done && !uploadingFileModel.abort && !uploadingFileModel.error;
}); });
filesToUpload.forEach((uploadingFileModel) => { filesToUpload.forEach((uploadingFileModel) => {
uploadingFileModel.setUploading(); uploadingFileModel.setUploading();
this.uploadFile(uploadingFileModel); this.uploadFile(uploadingFileModel, directory);
}); });
}; };
@@ -121,18 +119,20 @@ export class UploadService {
} }
/** /**
* Upload a file, and enrich it with the xhr. * Upload a file into the directory folder, and enrich it with the xhr.
* *
* @param {FileModel} - files to be uploaded. * @param {FileModel} - files to be uploaded.
* *
*/ */
uploadFile(uploadingFileModel: any): void { uploadFile(uploadingFileModel: any, directory: string): void {
let form = new FormData(); let form = new FormData();
form.append(this._fieldName, uploadingFileModel.file, uploadingFileModel.name); form.append(this._fieldName, uploadingFileModel.file, uploadingFileModel.name);
Object.keys(this._formFields).forEach((key) => { Object.keys(this._formFields).forEach((key) => {
form.append(key, this._formFields[key]); form.append(key, this._formFields[key]);
}); });
form.append('uploaddirectory', directory);
this._configureXMLHttpRequest(uploadingFileModel); this._configureXMLHttpRequest(uploadingFileModel);
uploadingFileModel.setXMLHttpRequest(this._xmlHttpRequest); uploadingFileModel.setXMLHttpRequest(this._xmlHttpRequest);