[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 Denys Vuika
parent 69b835a86d
commit 990865a701
24 changed files with 143 additions and 58 deletions

View File

@@ -0,0 +1,74 @@
/*!
* @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.
*/
export interface FileUploadProgress {
loaded: number;
total: number;
percent: number;
}
export interface FileUploadOptions {
newVersion?: boolean;
parentId?: string;
path?: string;
}
export enum FileUploadStatus {
Pending = 0,
Complete = 1,
Starting = 2,
Progress = 3,
Cancelled = 4,
Aborted = 5,
Error = 6
}
export class FileModel {
readonly id: string;
readonly name: string;
readonly size: number;
readonly file: File;
status: FileUploadStatus = FileUploadStatus.Pending;
progress: FileUploadProgress;
options: FileUploadOptions;
constructor(file: File, options?: FileUploadOptions) {
this.file = file;
this.id = this.generateId();
this.name = file.name;
this.size = file.size;
this.progress = {
loaded: 0,
total: 0,
percent: 0
};
this.options = Object.assign({}, {
newVersion: false
}, options);
}
private generateId(): string {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
let r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
}