mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-] update library to use new js-api 3.0.0 (#4097)
This commit is contained in:
committed by
Eugenio Romano
parent
2acd1b4e26
commit
3ef7d3b7ea
@@ -21,7 +21,7 @@ import {
|
||||
} from '@alfresco/adf-core';
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MinimalNodeEntity, MinimalNodeEntryEntity, NodeEntry, NodePaging } from 'alfresco-js-api';
|
||||
import { NodeEntry, NodePaging } from '@alfresco/js-api';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@@ -39,37 +39,6 @@ export class DocumentListService {
|
||||
private thumbnailService: ThumbnailService) {
|
||||
}
|
||||
|
||||
private getNodesPromise(folder: string, opts?: any, includeFields: string[] = []): Promise<NodePaging> {
|
||||
|
||||
let rootNodeId = DocumentListService.ROOT_ID;
|
||||
if (opts && opts.rootFolderId) {
|
||||
rootNodeId = opts.rootFolderId;
|
||||
}
|
||||
|
||||
let includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', 'aspectNames', ...includeFields]
|
||||
.filter((element, index, array) => index === array.indexOf(element));
|
||||
|
||||
let params: any = {
|
||||
includeSource: true,
|
||||
include: includeFieldsRequest
|
||||
};
|
||||
|
||||
if (folder) {
|
||||
params.relativePath = folder;
|
||||
}
|
||||
|
||||
if (opts) {
|
||||
if (opts.maxItems) {
|
||||
params.maxItems = opts.maxItems;
|
||||
}
|
||||
if (opts.skipCount) {
|
||||
params.skipCount = opts.skipCount;
|
||||
}
|
||||
}
|
||||
|
||||
return this.apiService.getInstance().nodes.getNodeChildren(rootNodeId, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a node.
|
||||
* @param nodeId ID of the node to delete
|
||||
@@ -105,19 +74,6 @@ export class DocumentListService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new folder in the path.
|
||||
* @param name Folder name
|
||||
* @param parentId Parent folder ID
|
||||
* @returns Details of the created folder node
|
||||
*/
|
||||
createFolder(name: string, parentId: string): Observable<MinimalNodeEntity> {
|
||||
return from(this.apiService.getInstance().nodes.createFolder(name, '/', parentId))
|
||||
.pipe(
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the folder node with the specified relative name path below the root node.
|
||||
* @param folder Path to folder.
|
||||
@@ -126,10 +82,35 @@ export class DocumentListService {
|
||||
* @returns Details of the folder
|
||||
*/
|
||||
getFolder(folder: string, opts?: any, includeFields: string[] = []): Observable<NodePaging> {
|
||||
return from(this.getNodesPromise(folder, opts, includeFields))
|
||||
.pipe(
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
let rootNodeId = DocumentListService.ROOT_ID;
|
||||
if (opts && opts.rootFolderId) {
|
||||
rootNodeId = opts.rootFolderId;
|
||||
}
|
||||
|
||||
let includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', 'aspectNames', ...includeFields]
|
||||
.filter((element, index, array) => index === array.indexOf(element));
|
||||
|
||||
let params: any = {
|
||||
includeSource: true,
|
||||
include: includeFieldsRequest
|
||||
};
|
||||
|
||||
if (folder) {
|
||||
params.relativePath = folder;
|
||||
}
|
||||
|
||||
if (opts) {
|
||||
if (opts.maxItems) {
|
||||
params.maxItems = opts.maxItems;
|
||||
}
|
||||
if (opts.skipCount) {
|
||||
params.skipCount = opts.skipCount;
|
||||
}
|
||||
}
|
||||
|
||||
return from(this.apiService.getInstance().nodes.getNodeChildren(rootNodeId, params)).pipe(
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,12 +134,11 @@ export class DocumentListService {
|
||||
|
||||
/**
|
||||
* Gets a folder node via its node ID.
|
||||
* @deprecated 2.3.0
|
||||
* @param nodeId ID of the folder node
|
||||
* @param includeFields Extra information to include (available options are "aspectNames", "isLink" and "association")
|
||||
* @returns Details of the folder
|
||||
*/
|
||||
getFolderNode(nodeId: string, includeFields: string[] = []): Observable<MinimalNodeEntryEntity> {
|
||||
getFolderNode(nodeId: string, includeFields: string[] = []): Observable<NodeEntry> {
|
||||
|
||||
let includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', 'aspectNames', ...includeFields]
|
||||
.filter((element, index, array) => index === array.indexOf(element));
|
||||
@@ -168,14 +148,17 @@ export class DocumentListService {
|
||||
include: includeFieldsRequest
|
||||
};
|
||||
|
||||
return from(this.apiService.getInstance().nodes.getNodeInfo(nodeId, opts));
|
||||
return from(this.apiService.getInstance().nodes.getNode(nodeId, opts)).pipe(
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get thumbnail URL for the given document node.
|
||||
* @param node Node to get URL for.
|
||||
* @returns Thumbnail URL string
|
||||
*/
|
||||
getDocumentThumbnailUrl(node: MinimalNodeEntity): string {
|
||||
getDocumentThumbnailUrl(node: NodeEntry): string {
|
||||
return this.thumbnailService.getDocumentThumbnailUrl(node);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user