[ADF-1002] Move the UploadService from the upload to core component and share it with the Process service (#2055)

* use the same upload component between the content and process service

* Create a BaseUploadServe inside the core
The AlfrescoUpload should extend the BaseUpload

* Improve the code

* Move the process service from the demo shell to form component

* Merge [ADF-917] added exlcluded files into app config to prevent special files

* Remove typo

* Fix import

* Fix FileModel import

* Fix Denys comment

* Fix unit test with the new path of UploadService

* Add missing implementation
This commit is contained in:
Maurizio Vitale
2017-07-07 15:58:59 +01:00
committed by Eugenio Romano
parent dd61cf7b45
commit 183dd3c990
24 changed files with 141 additions and 57 deletions

View File

@@ -16,9 +16,7 @@
*/
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { AlfrescoTranslationService, FileInfo, FileUtils, NotificationService } from 'ng2-alfresco-core';
import { FileModel } from '../models/file.model';
import { UploadService } from '../services/upload.service';
import { AlfrescoTranslationService, FileInfo, FileModel, FileUtils, NotificationService, UploadService } from 'ng2-alfresco-core';
@Component({
selector: 'adf-upload-drag-area, alfresco-upload-drag-area',
@@ -60,9 +58,18 @@ export class UploadDragAreaComponent {
@Input()
currentFolderPath: string = '/';
/**
* @deprecated Deprecated in 1.6.2, this property is not used for couple of releases already. Use parentId instead.
*
* @type {string}
* @memberof UploadDragAreaComponent
*/
@Input()
rootFolderId: string = '-root-';
@Input()
parentId: string;
@Output()
onSuccess = new EventEmitter();
@@ -85,9 +92,9 @@ export class UploadDragAreaComponent {
if (isAllowed) {
let files: FileInfo[] = event.detail.files;
if (files && files.length > 0) {
let parentId = this.rootFolderId;
let parentId = this.parentId || this.rootFolderId;
if (event.detail.data && event.detail.data.obj.entry.isFolder) {
parentId = event.detail.data.obj.entry.id || this.rootFolderId;
parentId = event.detail.data.obj.entry.id || this.parentId || this.rootFolderId;
}
const fileModels = files.map(fileInfo => new FileModel(fileInfo.file, {
newVersion: this.versioning,
@@ -109,7 +116,7 @@ export class UploadDragAreaComponent {
const fileModels = files.map(file => new FileModel(file, {
newVersion: this.versioning,
path: '/',
parentId: this.rootFolderId
parentId: this.parentId || this.rootFolderId
}));
this.uploadService.addToQueue(...fileModels);
this.uploadService.uploadFilesInTheQueue(this.onSuccess);
@@ -129,7 +136,7 @@ export class UploadDragAreaComponent {
item.file((file: File) => {
const fileModel = new FileModel(file, {
newVersion: this.versioning,
parentId: this.rootFolderId,
parentId: this.parentId || this.rootFolderId,
path: item.fullPath.replace(item.name, '')
});
this.uploadService.addToQueue(fileModel);
@@ -151,7 +158,7 @@ export class UploadDragAreaComponent {
let files = entries.map(entry => {
return new FileModel(entry.file, {
newVersion: this.versioning,
parentId: this.rootFolderId,
parentId: this.parentId || this.rootFolderId,
path: entry.relativeFolder
});
});