mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
committed by
Eugenio Romano
parent
dd61cf7b45
commit
183dd3c990
@@ -81,15 +81,17 @@
|
||||
<i class="material-icons">add</i>
|
||||
</button>
|
||||
</div>
|
||||
<adf-upload-drag-area [parentId]="currentTaskId">
|
||||
<adf-task-attachment-list #taskAttach
|
||||
*ngIf="currentTaskId"
|
||||
[taskId]="currentTaskId"
|
||||
(attachmentClick)="onAttachmentClick($event)">
|
||||
</adf-task-attachment-list>
|
||||
</adf-upload-drag-area>
|
||||
<div *ngIf="isCreateTaskAttachVisible()">
|
||||
<adf-create-task-attachment *ngIf="currentTaskId"
|
||||
[taskId]="currentTaskId"
|
||||
(success)="onCreateTaskSuccess()">
|
||||
(success)="onFileUploadComplete($event)">
|
||||
</adf-create-task-attachment>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -42,8 +42,8 @@ import {
|
||||
ObjectDataRow,
|
||||
DataSorting
|
||||
} from 'ng2-alfresco-datatable';
|
||||
import { AlfrescoApiService } from 'ng2-alfresco-core';
|
||||
import { FormService, FormRenderingService, FormEvent, FormFieldEvent } from 'ng2-activiti-form';
|
||||
import { AlfrescoApiService, UploadService } from 'ng2-alfresco-core';
|
||||
import { FormService, FormRenderingService, FormEvent, FormFieldEvent, ProcessUploadService } from 'ng2-activiti-form';
|
||||
import { /*CustomEditorComponent*/ CustomStencil01 } from './custom-editor/custom-editor.component';
|
||||
|
||||
declare var componentHandler;
|
||||
@@ -53,7 +53,10 @@ const currentProcessIdNew = '__NEW__';
|
||||
@Component({
|
||||
selector: 'activiti-demo',
|
||||
templateUrl: './activiti-demo.component.html',
|
||||
styleUrls: ['./activiti-demo.component.css']
|
||||
styleUrls: ['./activiti-demo.component.css'],
|
||||
providers: [
|
||||
{ provide: UploadService, useClass: ProcessUploadService }
|
||||
]
|
||||
})
|
||||
export class ActivitiDemoComponent implements AfterViewInit {
|
||||
|
||||
@@ -122,6 +125,7 @@ export class ActivitiDemoComponent implements AfterViewInit {
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private apiService: AlfrescoApiService,
|
||||
private uploadService: UploadService,
|
||||
private formRenderingService: FormRenderingService,
|
||||
private formService: FormService) {
|
||||
this.dataTasks = new ObjectDataTableAdapter();
|
||||
@@ -170,6 +174,9 @@ export class ActivitiDemoComponent implements AfterViewInit {
|
||||
this.currentProcessInstanceId = null;
|
||||
});
|
||||
this.layoutType = ActivitiApps.LAYOUT_GRID;
|
||||
|
||||
this.uploadService.fileUploadComplete.subscribe(value => this.onFileUploadComplete(value.data));
|
||||
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
@@ -274,6 +281,10 @@ export class ActivitiDemoComponent implements AfterViewInit {
|
||||
this.contentName = content.name;
|
||||
}
|
||||
|
||||
onFileUploadComplete(content: any) {
|
||||
this.taskAttachList.add(content);
|
||||
}
|
||||
|
||||
onAttachmentClick(content: any): void {
|
||||
this.fileShowed = true;
|
||||
this.content = content.contentBlob;
|
||||
|
@@ -18,9 +18,8 @@
|
||||
import { Component, Input, OnInit, Optional, ViewChild, ChangeDetectorRef } from '@angular/core';
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
import { MdDialog } from '@angular/material';
|
||||
import { AlfrescoContentService, FolderCreatedEvent, NotificationService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoContentService, FolderCreatedEvent, NotificationService, FileUploadCompleteEvent, UploadService } from 'ng2-alfresco-core';
|
||||
import { DocumentListComponent } from 'ng2-alfresco-documentlist';
|
||||
import { UploadService, FileUploadCompleteEvent } from 'ng2-alfresco-upload';
|
||||
|
||||
import { CreateFolderDialog } from '../../dialogs/create-folder.dialog';
|
||||
|
||||
|
@@ -33,12 +33,14 @@ import { FormRenderingService } from './src/services/form-rendering.service';
|
||||
import { FormService } from './src/services/form.service';
|
||||
import { NodeService } from './src/services/node.service';
|
||||
import { WidgetVisibilityService } from './src/services/widget-visibility.service';
|
||||
import { ProcessUploadService } from './src/services/process-upload.service';
|
||||
|
||||
export * from './src/components/activiti-form.component';
|
||||
export * from './src/components/adf-form-list.component';
|
||||
export * from './src/components/activiti-content.component';
|
||||
export * from './src/components/activiti-start-form.component';
|
||||
export * from './src/services/form.service';
|
||||
export * from './src/services/process-upload.service';
|
||||
export * from './src/services/activiti-content-service';
|
||||
export * from './src/components/widgets/index';
|
||||
export * from './src/services/ecm-model.service';
|
||||
@@ -57,6 +59,7 @@ export const ACTIVITI_FORM_DIRECTIVES: any[] = [
|
||||
|
||||
export const ACTIVITI_FORM_PROVIDERS: any[] = [
|
||||
FormService,
|
||||
ProcessUploadService,
|
||||
ActivitiContentService,
|
||||
EcmModelService,
|
||||
NodeService,
|
||||
|
@@ -0,0 +1,39 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AlfrescoApiService, AppConfigService, UploadService } from 'ng2-alfresco-core';
|
||||
|
||||
@Injectable()
|
||||
export class ProcessUploadService extends UploadService {
|
||||
|
||||
instanceApi: AlfrescoApiService;
|
||||
|
||||
constructor(apiService: AlfrescoApiService, appConfigService: AppConfigService) {
|
||||
super(apiService, appConfigService);
|
||||
this.instanceApi = apiService;
|
||||
}
|
||||
|
||||
getUploadPromise(file: any) {
|
||||
let opts = {
|
||||
isRelatedContent: true
|
||||
};
|
||||
let taskId = file.options.parentId;
|
||||
return this.instanceApi.getInstance().activiti.contentApi.createRelatedContentOnTask(taskId, file.file, opts);
|
||||
}
|
||||
|
||||
}
|
@@ -73,7 +73,7 @@ export const ACTIVITI_TASKLIST_PROVIDERS: any[] = [
|
||||
DataTableModule,
|
||||
ActivitiFormModule,
|
||||
MdIconModule,
|
||||
MdButtonModule
|
||||
MdButtonModule,
|
||||
],
|
||||
declarations: [
|
||||
...ACTIVITI_TASKLIST_DIRECTIVES
|
||||
|
@@ -64,12 +64,7 @@ export class TaskAttachmentListComponent implements OnChanges {
|
||||
this.loadAttachmentsByTaskId(this.taskId);
|
||||
}
|
||||
|
||||
private loadAttachmentsByTaskId(taskId: string) {
|
||||
if (taskId) {
|
||||
this.reset();
|
||||
this.activitiContentService.getTaskRelatedContent(taskId).subscribe(
|
||||
(res: any) => {
|
||||
res.data.forEach(content => {
|
||||
add(content: any): void {
|
||||
this.attachments.push({
|
||||
id: content.id,
|
||||
name: content.name,
|
||||
@@ -77,7 +72,23 @@ export class TaskAttachmentListComponent implements OnChanges {
|
||||
createdBy: content.createdBy.firstName + ' ' + content.createdBy.lastName,
|
||||
icon: this.thumbnailService.getMimeTypeIcon(content.mimeType)
|
||||
});
|
||||
}
|
||||
|
||||
private loadAttachmentsByTaskId(taskId: string) {
|
||||
if (taskId) {
|
||||
this.activitiContentService.getTaskRelatedContent(taskId).subscribe(
|
||||
(res: any) => {
|
||||
let attachList = [];
|
||||
res.data.forEach(content => {
|
||||
attachList.push({
|
||||
id: content.id,
|
||||
name: content.name,
|
||||
created: content.created,
|
||||
createdBy: content.createdBy.firstName + ' ' + content.createdBy.lastName,
|
||||
icon: this.thumbnailService.getMimeTypeIcon(content.mimeType)
|
||||
});
|
||||
});
|
||||
this.attachments = attachList;
|
||||
this.success.emit(this.attachments);
|
||||
},
|
||||
(err) => {
|
||||
|
@@ -49,7 +49,8 @@ import {
|
||||
NotificationService,
|
||||
RenditionsService,
|
||||
StorageService,
|
||||
ThumbnailService
|
||||
ThumbnailService,
|
||||
UploadService
|
||||
} from './src/services/index';
|
||||
|
||||
import { DataColumnListComponent } from './src/components/data-column/data-column-list.component';
|
||||
@@ -75,6 +76,7 @@ export * from './src/utils/index';
|
||||
export * from './src/events/base.event';
|
||||
export * from './src/events/base-ui.event';
|
||||
export * from './src/events/folder-created.event';
|
||||
export * from './src/events/file.event';
|
||||
export * from './src/models/index';
|
||||
|
||||
export * from './src/models/index';
|
||||
|
@@ -16,3 +16,4 @@
|
||||
*/
|
||||
|
||||
export * from './card-view.model';
|
||||
export * from './file.model';
|
||||
|
@@ -32,3 +32,4 @@ export * from './alfresco-translation.service';
|
||||
export * from './alfresco-translate-loader.service';
|
||||
export * from './app-config.service';
|
||||
export * from './thumbnail.service';
|
||||
export * from './upload.service';
|
||||
|
@@ -17,9 +17,8 @@
|
||||
|
||||
import { EventEmitter } from '@angular/core';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { CoreModule, AppConfigModule } from 'ng2-alfresco-core';
|
||||
import { AppConfigModule, CoreModule, FileModel, FileUploadOptions } from 'ng2-alfresco-core';
|
||||
import { UploadService } from './upload.service';
|
||||
import { FileModel, FileUploadOptions } from '../models/file.model';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
@@ -17,10 +17,11 @@
|
||||
|
||||
import { EventEmitter, Injectable } from '@angular/core';
|
||||
import * as minimatch from 'minimatch';
|
||||
import { AlfrescoApiService, AppConfigService } from 'ng2-alfresco-core';
|
||||
import { Subject } from 'rxjs/Rx';
|
||||
import { FileUploadCompleteEvent, FileUploadEvent } from '../events/file.event';
|
||||
import { FileModel, FileUploadProgress, FileUploadStatus } from '../models/file.model';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { AppConfigService } from './app-config.service';
|
||||
|
||||
@Injectable()
|
||||
export class UploadService {
|
||||
@@ -142,7 +143,7 @@ export class UploadService {
|
||||
this.totalAborted = 0;
|
||||
}
|
||||
|
||||
private beginUpload(file: FileModel, /* @deprecated */emitter: EventEmitter<any>): any {
|
||||
getUploadPromise(file: FileModel) {
|
||||
let opts: any = {
|
||||
renditions: 'doclib'
|
||||
};
|
||||
@@ -153,13 +154,19 @@ export class UploadService {
|
||||
} else {
|
||||
opts.autoRename = true;
|
||||
}
|
||||
let promise = this.apiService.getInstance().upload.uploadFile(
|
||||
return this.apiService.getInstance().upload.uploadFile(
|
||||
file.file,
|
||||
file.options.path,
|
||||
file.options.parentId,
|
||||
null,
|
||||
opts
|
||||
);
|
||||
}
|
||||
|
||||
private beginUpload(file: FileModel, /* @deprecated */emitter: EventEmitter<any>): any {
|
||||
|
||||
let promise = this.getUploadPromise(file);
|
||||
|
||||
promise.on('progress', (progress: FileUploadProgress) => {
|
||||
this.onUploadProgress(file, progress);
|
||||
})
|
||||
@@ -178,6 +185,7 @@ export class UploadService {
|
||||
.catch(err => {
|
||||
this.onUploadError(file, err);
|
||||
});
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ import {
|
||||
} from '@angular/core';
|
||||
import { MdCheckboxChange } from '@angular/material';
|
||||
import { DataColumnListComponent } from 'ng2-alfresco-core';
|
||||
import { Observable, Observer } from 'rxjs/Rx';
|
||||
import { Observable, Observer, Subscription } from 'rxjs/Rx';
|
||||
import { DataColumn, DataRow, DataRowEvent, DataSorting, DataTableAdapter } from '../../data/datatable-adapter';
|
||||
import { ObjectDataRow, ObjectDataTableAdapter } from '../../data/object-datatable-adapter';
|
||||
import { DataCellEvent } from './data-cell.event';
|
||||
@@ -101,6 +101,9 @@ export class DataTableComponent implements AfterContentInit, AfterViewInit, OnCh
|
||||
|
||||
private differ: any;
|
||||
|
||||
private singleClickStreamSub: Subscription;
|
||||
private multiClickStreamSub: Subscription;
|
||||
|
||||
constructor(
|
||||
@Optional() private el: ElementRef,
|
||||
private differs: IterableDiffers) {
|
||||
@@ -169,12 +172,13 @@ export class DataTableComponent implements AfterContentInit, AfterViewInit, OnCh
|
||||
}
|
||||
|
||||
private initAndSubscribeClickStream() {
|
||||
this.unsubscribeClickStream();
|
||||
let singleClickStream = this.click$
|
||||
.buffer(this.click$.debounceTime(250))
|
||||
.map(list => list)
|
||||
.filter(x => x.length === 1);
|
||||
|
||||
singleClickStream.subscribe((obj: DataRowEvent[]) => {
|
||||
this.singleClickStreamSub = singleClickStream.subscribe((obj: DataRowEvent[]) => {
|
||||
let event: DataRowEvent = obj[0];
|
||||
let el = obj[0].sender.el;
|
||||
this.rowClick.emit(event);
|
||||
@@ -193,7 +197,7 @@ export class DataTableComponent implements AfterContentInit, AfterViewInit, OnCh
|
||||
.map(list => list)
|
||||
.filter(x => x.length >= 2);
|
||||
|
||||
multiClickStream.subscribe((obj: DataRowEvent[]) => {
|
||||
this.multiClickStreamSub = multiClickStream.subscribe((obj: DataRowEvent[]) => {
|
||||
let event: DataRowEvent = obj[0];
|
||||
let el = obj[0].sender.el;
|
||||
this.rowDblClick.emit(event);
|
||||
@@ -208,6 +212,15 @@ export class DataTableComponent implements AfterContentInit, AfterViewInit, OnCh
|
||||
});
|
||||
}
|
||||
|
||||
private unsubscribeClickStream() {
|
||||
if(this.singleClickStreamSub) {
|
||||
this.singleClickStreamSub.unsubscribe();
|
||||
}
|
||||
if (this.multiClickStreamSub) {
|
||||
this.multiClickStreamSub.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
private initTable() {
|
||||
this.data = new ObjectDataTableAdapter(this.rows, this.schema);
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ npm install ng2-alfresco-upload
|
||||
|
||||
```html
|
||||
<adf-upload-button
|
||||
[rootFolderId]="-my-"
|
||||
[parentId]="-my-"
|
||||
[uploadFolders]="true"
|
||||
[multipleFiles]="false"
|
||||
[acceptedFilesType]=".jpg,.gif,.png,.svg"
|
||||
@@ -86,7 +86,9 @@ npm install ng2-alfresco-upload
|
||||
| multipleFiles | boolean | false | Allow/disallow multiple files |
|
||||
| acceptedFilesType | string | * | array of allowed file extensions , example: ".jpg,.gif,.png,.svg" |
|
||||
| **(deprecated)** currentFolderPath | string | '/Sites/swsdp/documentLibrary' | define the path where the files are uploaded. **Deprecated in 1.6.0: use rootFolderId instead.** |
|
||||
| rootFolderId | string | '-root-' | The ID of the root folder node. |
|
||||
| **(deprecated)** rootFolderId | string | '-root-' | The ID of the root folder node.
|
||||
**Deprecated in 1.6.2: use parentId instead.** |
|
||||
| parentId | string | empty | The ID of the root. It can be the nodeId if you are using the upload for the Content Service or taskId/processId for the Process Service. |
|
||||
| versioning | boolean | false | Versioning false is the default uploader behaviour and it rename using an integer suffix if there is a name clash. Versioning true to indicate that a major version should be created |
|
||||
| staticTitle | string | (predefined) | define the text of the upload button |
|
||||
| disableWithNoPermission | boolean | false | If the value is true and the user doesn't have the permission to delete the node the button will be disabled |
|
||||
|
@@ -24,17 +24,13 @@ import { FileUploadingListComponent } from './src/components/file-uploading-list
|
||||
import { UploadButtonComponent } from './src/components/upload-button.component';
|
||||
import { UploadDragAreaComponent } from './src/components/upload-drag-area.component';
|
||||
import { FileDraggableDirective } from './src/directives/file-draggable.directive';
|
||||
import { UploadService } from './src/services/upload.service';
|
||||
|
||||
export * from './src/components/upload-button.component';
|
||||
export * from './src/components/file-uploading-dialog.component';
|
||||
export * from './src/components/upload-drag-area.component';
|
||||
export * from './src/services/upload.service';
|
||||
export * from './src/directives/file-draggable.directive';
|
||||
export * from './src/components/file-uploading-list.component';
|
||||
export * from './src/models/file.model';
|
||||
export * from './src/models/permissions.model';
|
||||
export * from './src/events/file.event';
|
||||
|
||||
export const UPLOAD_DIRECTIVES: any[] = [
|
||||
FileDraggableDirective,
|
||||
@@ -45,7 +41,7 @@ export const UPLOAD_DIRECTIVES: any[] = [
|
||||
];
|
||||
|
||||
export const UPLOAD_PROVIDERS: any[] = [
|
||||
UploadService
|
||||
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
@@ -21,9 +21,8 @@ import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { CoreModule } from 'ng2-alfresco-core';
|
||||
import { FileUploadingDialogComponent } from './file-uploading-dialog.component';
|
||||
import { FileUploadingListComponent } from './file-uploading-list.component';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
import { FileModel, FileUploadStatus } from '../models/file.model';
|
||||
import { FileUploadCompleteEvent, FileUploadEvent } from '../events/file.event';
|
||||
import { FileModel, FileUploadStatus } from 'ng2-alfresco-core';
|
||||
import { FileUploadCompleteEvent, FileUploadEvent, UploadService } from 'ng2-alfresco-core';
|
||||
|
||||
describe('FileUploadingDialogComponent', () => {
|
||||
|
||||
|
@@ -16,10 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||
import { FileUploadCompleteEvent } from '../events/file.event';
|
||||
import { FileModel, FileUploadStatus } from '../models/file.model';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
import { AlfrescoTranslationService, FileModel, FileUploadCompleteEvent, FileUploadStatus, UploadService } from 'ng2-alfresco-core';
|
||||
|
||||
@Component({
|
||||
selector: 'file-uploading-dialog',
|
||||
|
@@ -16,8 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { FileModel, FileUploadStatus } from '../models/file.model';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
import { FileModel, FileUploadStatus, UploadService } from 'ng2-alfresco-core';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-file-uploading-list, alfresco-file-uploading-list',
|
||||
|
@@ -18,9 +18,8 @@
|
||||
import { DebugElement, SimpleChange } from '@angular/core';
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { UploadButtonComponent } from './upload-button.component';
|
||||
import { CoreModule, AlfrescoTranslationService, AlfrescoContentService} from 'ng2-alfresco-core';
|
||||
import { CoreModule, AlfrescoTranslationService, AlfrescoContentService, UploadService } from 'ng2-alfresco-core';
|
||||
import { TranslationMock } from '../assets/translation.service.mock';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
|
||||
describe('UploadButtonComponent', () => {
|
||||
|
@@ -17,11 +17,9 @@
|
||||
|
||||
import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
|
||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
import { AlfrescoApiService, AlfrescoContentService, AlfrescoTranslationService, FileUtils, LogService, NotificationService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoApiService, AlfrescoContentService, AlfrescoTranslationService, FileModel, FileUtils, LogService, NotificationService, UploadService } from 'ng2-alfresco-core';
|
||||
import { Observable, Subject } from 'rxjs/Rx';
|
||||
import { FileModel } from '../models/file.model';
|
||||
import { PermissionModel } from '../models/permissions.model';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-upload-button, alfresco-upload-button',
|
||||
|
@@ -17,13 +17,11 @@
|
||||
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { DebugElement } from '@angular/core';
|
||||
import { AlfrescoTranslationService, CoreModule, LogService, LogServiceMock } from 'ng2-alfresco-core';
|
||||
import { AlfrescoTranslationService, CoreModule, FileModel, LogService, LogServiceMock, UploadService } from 'ng2-alfresco-core';
|
||||
|
||||
import { UploadDragAreaComponent } from './upload-drag-area.component';
|
||||
import { FileDraggableDirective } from '../directives/file-draggable.directive';
|
||||
import { TranslationMock } from '../assets/translation.service.mock';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
import { FileModel } from '../models/file.model';
|
||||
|
||||
let fakeShareDataRow = {
|
||||
obj: {
|
||||
|
@@ -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
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user