mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[ADF-571] upload feature rework (#1922)
* upload feature rework lots of improvements for upload dialog and underlying services * readme update - readme cleanup - remove some old comments from code - update readme with new events for Upload Service * restore prerequisites section in readme
This commit is contained in:
parent
0b3a909004
commit
b815034ef8
@ -88,6 +88,23 @@ export class AlfrescoContentService {
|
|||||||
.catch(err => this.handleError(err));
|
.catch(err => this.handleError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a folder
|
||||||
|
* @param name - the folder name
|
||||||
|
*/
|
||||||
|
createFolder(relativePath: string, name: string, parentId?: string): Observable<MinimalNodeEntity> {
|
||||||
|
return Observable.fromPromise(this.apiService.getInstance().nodes.createFolder(name, relativePath, parentId))
|
||||||
|
.do(data => {
|
||||||
|
this.folderCreated.next({
|
||||||
|
relativePath: relativePath,
|
||||||
|
name: name,
|
||||||
|
parentId: parentId,
|
||||||
|
node: data
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(err => this.handleError(err));
|
||||||
|
}
|
||||||
|
|
||||||
private handleError(error: any) {
|
private handleError(error: any) {
|
||||||
this.logService.error(error);
|
this.logService.error(error);
|
||||||
return Observable.throw(error || 'Server error');
|
return Observable.throw(error || 'Server error');
|
||||||
|
@ -190,6 +190,7 @@ export class UploadButtonComponent implements OnInit, OnChanges {
|
|||||||
error => this.onError.emit(error)
|
error => this.onError.emit(error)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
return 'Error';
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move to AlfrescoContentService
|
// TODO: move to AlfrescoContentService
|
||||||
@ -210,6 +211,23 @@ export class UploadButtonComponent implements OnInit, OnChanges {
|
|||||||
return Observable.throw(error || 'Server error');
|
return Observable.throw(error || 'Server error');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFolderNode(nodeId: string): Observable<MinimalNodeEntryEntity> {
|
||||||
|
let opts: any = {
|
||||||
|
includeSource: true,
|
||||||
|
include: ['allowableOperations']
|
||||||
|
};
|
||||||
|
|
||||||
|
return Observable.fromPromise(this.apiService.getInstance().nodes.getNodeInfo(nodeId, opts))
|
||||||
|
.catch(err => this.handleError(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
private handleError(error: Response) {
|
||||||
|
// in a real world app, we may send the error to some remote logging infrastructure
|
||||||
|
// instead of just logging it to the console
|
||||||
|
this.logService.error(error);
|
||||||
|
return Observable.throw(error || 'Server error');
|
||||||
|
}
|
||||||
|
|
||||||
private hasCreatePermission(node: any): boolean {
|
private hasCreatePermission(node: any): boolean {
|
||||||
if (node && node.allowableOperations) {
|
if (node && node.allowableOperations) {
|
||||||
return node.allowableOperations.find(permision => permision === 'create') ? true : false;
|
return node.allowableOperations.find(permision => permision === 'create') ? true : false;
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
/*!
|
|
||||||
* @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 { MinimalNodeEntity } from 'alfresco-js-api';
|
|
||||||
|
|
||||||
export interface FolderCreatedEvent {
|
|
||||||
|
|
||||||
name: string;
|
|
||||||
relativePath?: string;
|
|
||||||
parentId?: string;
|
|
||||||
node?: MinimalNodeEntity;
|
|
||||||
|
|
||||||
}
|
|
@ -72,7 +72,3 @@ export class FileModel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FileUploadOptions {
|
|
||||||
newVersion?: boolean;
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user