mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-08 14:51:32 +00:00
Extract all the content
This commit is contained in:
@@ -151,13 +151,13 @@ export class CoreModule {
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: directionalityConfigFactory,
|
||||
deps: [ DirectionalityConfigService ],
|
||||
deps: [DirectionalityConfigService],
|
||||
multi: true
|
||||
},
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: versionCompatibilityFactory,
|
||||
deps: [ VersionCompatibilityService ],
|
||||
deps: [VersionCompatibilityService],
|
||||
multi: true
|
||||
}
|
||||
]
|
||||
|
@@ -18,11 +18,11 @@
|
||||
/* tslint:disable:no-input-rename */
|
||||
|
||||
import { Directive, ElementRef, EventEmitter, HostListener, Input, OnChanges, Output } from '@angular/core';
|
||||
import { NodeEntry, Node, DeletedNodeEntity, DeletedNode, TrashcanApi, NodesApi } from '@alfresco/js-api';
|
||||
import { NodeEntry, Node, DeletedNodeEntity, DeletedNode } from '@alfresco/js-api';
|
||||
import { Observable, forkJoin, from, of } from 'rxjs';
|
||||
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
||||
import { TranslationService } from '../services/translation.service';
|
||||
import { map, catchError, retry } from 'rxjs/operators';
|
||||
import { ContentService } from '../services/content.service';
|
||||
|
||||
interface ProcessedNodeData {
|
||||
entry: Node | DeletedNode;
|
||||
@@ -62,24 +62,12 @@ export class NodeDeleteDirective implements OnChanges {
|
||||
@Output()
|
||||
delete: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
_trashcanApi: TrashcanApi;
|
||||
get trashcanApi(): TrashcanApi {
|
||||
this._trashcanApi = this._trashcanApi ?? new TrashcanApi(this.alfrescoApiService.getInstance());
|
||||
return this._trashcanApi;
|
||||
}
|
||||
|
||||
_nodesApi: NodesApi;
|
||||
get nodesApi(): NodesApi {
|
||||
this._nodesApi = this._nodesApi ?? new NodesApi(this.alfrescoApiService.getInstance());
|
||||
return this._nodesApi;
|
||||
}
|
||||
|
||||
@HostListener('click')
|
||||
onClick() {
|
||||
this.process(this.selection);
|
||||
}
|
||||
|
||||
constructor(private alfrescoApiService: AlfrescoApiService,
|
||||
constructor(private contentService: ContentService,
|
||||
private translation: TranslationService,
|
||||
private elementRef: ElementRef) {
|
||||
}
|
||||
@@ -125,9 +113,9 @@ export class NodeDeleteDirective implements OnChanges {
|
||||
let promise: Promise<any>;
|
||||
|
||||
if (node.entry.hasOwnProperty('archivedAt') && node.entry['archivedAt']) {
|
||||
promise = this.trashcanApi.deleteDeletedNode(id);
|
||||
promise = this.contentService.deleteDeletedNode(id);
|
||||
} else {
|
||||
promise = this.nodesApi.deleteNode(id, { permanent: this.permanent });
|
||||
promise = this.contentService.deleteNode(id, { permanent: this.permanent });
|
||||
}
|
||||
|
||||
return from(promise).pipe(
|
||||
|
@@ -17,10 +17,10 @@
|
||||
|
||||
import { Directive, Input, HostListener } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
||||
import { DownloadZipDialogComponent } from '../dialogs/download-zip/download-zip.dialog';
|
||||
import { ContentApi, NodeEntry, VersionEntry } from '@alfresco/js-api';
|
||||
import { NodeEntry, VersionEntry } from '@alfresco/js-api';
|
||||
import { DownloadService } from '../services/download.service';
|
||||
import { ContentService } from '../services/content.service';
|
||||
|
||||
/**
|
||||
* Directive selectors without adf- prefix will be deprecated on 3.0.0
|
||||
@@ -31,12 +31,6 @@ import { DownloadService } from '../services/download.service';
|
||||
})
|
||||
export class NodeDownloadDirective {
|
||||
|
||||
_contentApi: ContentApi;
|
||||
get contentApi(): ContentApi {
|
||||
this._contentApi = this._contentApi ?? new ContentApi(this.apiService.getInstance());
|
||||
return this._contentApi;
|
||||
}
|
||||
|
||||
/** Nodes to download. */
|
||||
@Input('adfNodeDownload')
|
||||
nodes: NodeEntry | NodeEntry[];
|
||||
@@ -51,7 +45,7 @@ export class NodeDownloadDirective {
|
||||
}
|
||||
|
||||
constructor(
|
||||
private apiService: AlfrescoApiService,
|
||||
private contentService: ContentService,
|
||||
private downloadService: DownloadService,
|
||||
private dialog: MatDialog) {
|
||||
}
|
||||
@@ -112,10 +106,10 @@ export class NodeDownloadDirective {
|
||||
|
||||
let url, fileName;
|
||||
if (this.version) {
|
||||
url = this.contentApi.getVersionContentUrl(id, this.version.entry.id, true);
|
||||
url = this.contentService.getVersionContentUrl(id, this.version.entry.id, true);
|
||||
fileName = this.version.entry.name;
|
||||
} else {
|
||||
url = this.contentApi.getContentUrl(id, true);
|
||||
url = this.contentService.getContentUrl(id, true);
|
||||
fileName = node.entry.name;
|
||||
}
|
||||
|
||||
|
576
lib/core/services/acs-content.service.ts
Normal file
576
lib/core/services/acs-content.service.ts
Normal file
@@ -0,0 +1,576 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 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 {
|
||||
ContentApi,
|
||||
DeletedNodesPaging,
|
||||
DiscoveryApi,
|
||||
DiscoveryEntry,
|
||||
FavoriteBodyCreate,
|
||||
FavoriteEntry,
|
||||
FavoritePaging,
|
||||
FavoritesApi,
|
||||
NodeBodyCopy,
|
||||
NodeBodyCreate,
|
||||
NodeBodyLock,
|
||||
NodeBodyMove,
|
||||
NodeBodyUpdate,
|
||||
NodeChildAssociationPaging,
|
||||
NodeEntry,
|
||||
NodesApi,
|
||||
PeopleApi,
|
||||
PersonEntry,
|
||||
RenditionBodyCreate,
|
||||
RenditionEntry,
|
||||
RenditionPaging,
|
||||
RenditionsApi,
|
||||
ResultSetPaging,
|
||||
RevertBody,
|
||||
SearchApi,
|
||||
SearchRequest,
|
||||
SharedLinkEntry,
|
||||
SharedLinkPaging,
|
||||
SharedlinksApi,
|
||||
SiteBody,
|
||||
SiteEntry,
|
||||
SiteMemberPaging,
|
||||
SitePaging,
|
||||
SiteRolePaging,
|
||||
SitesApi,
|
||||
TrashcanApi,
|
||||
UploadApi,
|
||||
VersionEntry,
|
||||
VersionPaging,
|
||||
VersionsApi
|
||||
} from '@alfresco/js-api';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { ContentServiceProvider } from './content-provider.service';
|
||||
import { PaginationModel } from '../models/pagination.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AcsContentService implements ContentServiceProvider {
|
||||
|
||||
private CREATE_PERMISSION = 'create';
|
||||
|
||||
_contentApi: ContentApi;
|
||||
get contentApi(): ContentApi {
|
||||
this._contentApi = this._contentApi ?? new ContentApi(this.apiService.getInstance());
|
||||
return this._contentApi;
|
||||
}
|
||||
|
||||
_nodesApi: NodesApi;
|
||||
get nodesApi(): NodesApi {
|
||||
this._nodesApi = this._nodesApi ?? new NodesApi(this.apiService.getInstance());
|
||||
return this._nodesApi;
|
||||
}
|
||||
|
||||
_versionsApi: VersionsApi;
|
||||
get versionsApi(): VersionsApi {
|
||||
this._versionsApi = this._versionsApi ?? new VersionsApi(this.apiService.getInstance());
|
||||
return this._versionsApi;
|
||||
}
|
||||
|
||||
_trashcanApi: TrashcanApi;
|
||||
get trashcanApi(): TrashcanApi {
|
||||
this._trashcanApi = this._trashcanApi ?? new TrashcanApi(this.apiService.getInstance());
|
||||
return this._trashcanApi;
|
||||
}
|
||||
|
||||
_sharedLinksApi: SharedlinksApi;
|
||||
get sharedLinksApi(): SharedlinksApi {
|
||||
this._sharedLinksApi = this._sharedLinksApi ?? new SharedlinksApi(this.apiService.getInstance());
|
||||
return this._sharedLinksApi;
|
||||
}
|
||||
|
||||
_uploadApi: UploadApi;
|
||||
get uploadApi(): UploadApi {
|
||||
this._uploadApi = this._uploadApi ?? new UploadApi(this.apiService.getInstance());
|
||||
return this._uploadApi;
|
||||
}
|
||||
|
||||
_renditionsApi: RenditionsApi;
|
||||
get renditionsApi(): RenditionsApi {
|
||||
this._renditionsApi = this._renditionsApi ?? new RenditionsApi(this.apiService.getInstance());
|
||||
return this._renditionsApi;
|
||||
}
|
||||
|
||||
_peopleApi: PeopleApi;
|
||||
get peopleApi(): PeopleApi {
|
||||
this._peopleApi = this._peopleApi ?? new PeopleApi(this.apiService.getInstance());
|
||||
return this._peopleApi;
|
||||
}
|
||||
|
||||
_sitesApi: SitesApi;
|
||||
get sitesApi(): SitesApi {
|
||||
this._sitesApi = this._sitesApi ?? new SitesApi(this.apiService.getInstance());
|
||||
return this._sitesApi;
|
||||
}
|
||||
|
||||
_searchApi: SearchApi;
|
||||
get searchApi(): SearchApi {
|
||||
this._searchApi = this._searchApi ?? new SearchApi(this.apiService.getInstance());
|
||||
return this._searchApi;
|
||||
}
|
||||
|
||||
_favoritesApi: FavoritesApi;
|
||||
get favoritesApi(): FavoritesApi {
|
||||
this._favoritesApi = this._favoritesApi ?? new FavoritesApi(this.apiService.getInstance());
|
||||
return this._favoritesApi;
|
||||
}
|
||||
|
||||
_discoveryApi: DiscoveryApi;
|
||||
get discoveryApi(): DiscoveryApi {
|
||||
this._discoveryApi = this._discoveryApi ?? new DiscoveryApi(this.apiService.getInstance());
|
||||
return this._discoveryApi;
|
||||
}
|
||||
|
||||
constructor(public apiService: AlfrescoApiService) {
|
||||
}
|
||||
|
||||
getNodePrefix() {
|
||||
return 'alfresco://';
|
||||
}
|
||||
|
||||
getContentUrl(node: NodeEntry | string, attachment?: boolean, ticket?: string): string {
|
||||
if (node) {
|
||||
let nodeId: string;
|
||||
|
||||
if (typeof node === 'string') {
|
||||
nodeId = node;
|
||||
} else if (node.entry) {
|
||||
nodeId = node.entry.id;
|
||||
}
|
||||
|
||||
return this.contentApi.getContentUrl(nodeId, attachment, ticket);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
getDocumentThumbnailUrl(nodeId: string, attachment?: boolean, ticket?: string): string {
|
||||
return this.contentApi.getDocumentThumbnailUrl(nodeId, attachment, ticket);
|
||||
}
|
||||
|
||||
getVersionContentUrl(nodeId: string, versionId: string, attachment?: boolean, ticket?: string): string {
|
||||
return this.contentApi.getVersionContentUrl(nodeId, versionId, attachment, ticket);
|
||||
}
|
||||
|
||||
getSharedLinkContentUrl(linkId: string, attachment?: boolean): string {
|
||||
return this.contentApi.getSharedLinkContentUrl(linkId, attachment);
|
||||
}
|
||||
|
||||
getSharedLinkRenditionUrl(sharedId: string, renditionId: string, attachment?: boolean): string {
|
||||
return this.contentApi.getSharedLinkRenditionUrl(sharedId, renditionId, attachment);
|
||||
}
|
||||
|
||||
getRenditionUrl(nodeId: string, encoding: string, attachment?: boolean, ticket?: string): string {
|
||||
return this.contentApi.getRenditionUrl(nodeId, encoding, attachment, ticket);
|
||||
}
|
||||
|
||||
getVersionRenditionUrl(nodeId: string, versionId: string, encoding: string, attachment?: boolean, ticket?: string): string {
|
||||
return this.contentApi.getVersionRenditionUrl(nodeId, versionId, encoding, attachment, ticket);
|
||||
}
|
||||
|
||||
getNodeContent(nodeId: string): Promise<any> {
|
||||
return this.nodesApi.getNodeContent(nodeId);
|
||||
}
|
||||
|
||||
getNode(nodeId: string, opts?: any): Promise<NodeEntry> {
|
||||
return this.nodesApi.getNode(nodeId, opts);
|
||||
}
|
||||
|
||||
lockNode(nodeId: string, nodeBodyLock: NodeBodyLock, opts?: any): Promise<NodeEntry> {
|
||||
return this.nodesApi.lockNode(nodeId, nodeBodyLock, opts);
|
||||
}
|
||||
|
||||
unlockNode(nodeId: string, opts?: any): Promise<NodeEntry> {
|
||||
return this.nodesApi.unlockNode(nodeId, opts);
|
||||
}
|
||||
|
||||
deleteNode(nodeId: string, opts?: any): Promise<any> {
|
||||
return this.nodesApi.deleteNode(nodeId, opts);
|
||||
}
|
||||
|
||||
copyNode(nodeId: string, nodeBodyCopy: NodeBodyCopy, opts?: any): Promise<NodeEntry> {
|
||||
return this.nodesApi.copyNode(nodeId, nodeBodyCopy, opts);
|
||||
}
|
||||
|
||||
moveNode(nodeId: string, nodeBodyMove: NodeBodyMove, opts?: any): Promise<NodeEntry> {
|
||||
return this.nodesApi.moveNode(nodeId, nodeBodyMove, opts);
|
||||
}
|
||||
|
||||
listNodeChildren(nodeId: string, opts?: any): Promise<NodeChildAssociationPaging> {
|
||||
return this.nodesApi.listNodeChildren(nodeId, opts);
|
||||
}
|
||||
|
||||
createNode(nodeId: string, nodeBodyCreate: NodeBodyCreate, opts?: any, formParams?: any): Promise<NodeEntry | any> {
|
||||
return this.nodesApi.createNode(nodeId, nodeBodyCreate, opts, formParams);
|
||||
}
|
||||
|
||||
updateNode(nodeId: string, nodeBodyUpdate: NodeBodyUpdate, opts?: any): Promise<NodeEntry> {
|
||||
return this.nodesApi.updateNode(nodeId, nodeBodyUpdate, opts);
|
||||
}
|
||||
|
||||
updateNodeContent(nodeId: string, contentBodyUpdate: string, opts?: any): Promise<NodeEntry> {
|
||||
return this.nodesApi.updateNodeContent(nodeId, contentBodyUpdate, opts);
|
||||
}
|
||||
|
||||
revertVersion(nodeId: string, versionId: string, revertBody: RevertBody, opts?: any): Promise<VersionEntry> {
|
||||
return this.versionsApi.revertVersion(nodeId, versionId, revertBody, opts);
|
||||
}
|
||||
|
||||
deleteVersion(nodeId: string, versionId: string): Promise<any> {
|
||||
return this.versionsApi.deleteVersion(nodeId, versionId);
|
||||
}
|
||||
|
||||
listVersionHistory(nodeId: string, opts?: any): Promise<VersionPaging> {
|
||||
return this.versionsApi.listVersionHistory(nodeId, opts);
|
||||
}
|
||||
|
||||
getVersion(nodeId: string, versionId: string): Promise<VersionEntry> {
|
||||
return this.versionsApi.getVersion(nodeId, versionId);
|
||||
}
|
||||
|
||||
listVersionRenditions(nodeId: string, versionId: string, opts?: any): Promise<RenditionPaging> {
|
||||
return this.versionsApi.listVersionRenditions(nodeId, versionId, opts);
|
||||
}
|
||||
|
||||
createVersionRendition(nodeId: string, versionId: string, renditionBodyCreate: RenditionBodyCreate): Promise<any> {
|
||||
return this.versionsApi.createVersionRendition(nodeId, versionId, renditionBodyCreate);
|
||||
}
|
||||
|
||||
getVersionRendition(nodeId: string, versionId: string, renditionId: string): Promise<RenditionEntry> {
|
||||
return this.versionsApi.getVersionRendition(nodeId, versionId, renditionId);
|
||||
}
|
||||
|
||||
getNodeVersions(nodeId: string, opts?: any) {
|
||||
return from(this.versionsApi.listVersionHistory(nodeId, opts));
|
||||
}
|
||||
|
||||
deleteDeletedNode(nodeId: string): Promise<any> {
|
||||
return this.trashcanApi.deleteDeletedNode(nodeId);
|
||||
}
|
||||
|
||||
listDeletedNodes(opts?: any): Promise<DeletedNodesPaging> {
|
||||
return this.trashcanApi.listDeletedNodes(opts);
|
||||
}
|
||||
|
||||
restoreDeletedNode(nodeId: string, opts?: any): Promise<NodeEntry> {
|
||||
return this.trashcanApi.restoreDeletedNode(nodeId, opts);
|
||||
}
|
||||
|
||||
getSharedLink(sharedId: string, opts?: any): Promise<SharedLinkEntry> {
|
||||
return this.sharedLinksApi.getSharedLink(sharedId, opts);
|
||||
}
|
||||
|
||||
getSharedLinkRendition(sharedId: string, renditionId: string): Promise<RenditionEntry> {
|
||||
return this.sharedLinksApi.getSharedLinkRendition(sharedId, renditionId);
|
||||
}
|
||||
|
||||
listSharedLinks(opts?: any): Promise<SharedLinkPaging> {
|
||||
return this.sharedLinksApi.listSharedLinks(opts);
|
||||
}
|
||||
|
||||
deleteSharedLink(sharedId: string): Promise<any> {
|
||||
return this.sharedLinksApi.deleteSharedLink(sharedId);
|
||||
}
|
||||
|
||||
uploadFile(fileDefinition: any, relativePath: string, rootFolderId: string, nodeBody: any, opts?: any): Promise<any> {
|
||||
return this.uploadApi.uploadFile(fileDefinition, relativePath, rootFolderId, nodeBody, opts);
|
||||
}
|
||||
|
||||
listRenditions(nodeId: string, opts?: any): Promise<RenditionPaging> {
|
||||
return this.renditionsApi.listRenditions(nodeId, opts);
|
||||
}
|
||||
|
||||
createRendition(nodeId: string, renditionBodyCreate: RenditionBodyCreate): Promise<any> {
|
||||
return this.renditionsApi.createRendition(nodeId, renditionBodyCreate);
|
||||
}
|
||||
|
||||
getRendition(nodeId: string, renditionId: string): Promise<RenditionEntry> {
|
||||
return this.renditionsApi.getRendition(nodeId, renditionId);
|
||||
}
|
||||
|
||||
getPerson(personId: string, opts?: any): Promise<PersonEntry> {
|
||||
return this.peopleApi.getPerson(personId, opts);
|
||||
}
|
||||
|
||||
getRepositoryInformation(): Promise<DiscoveryEntry> {
|
||||
return this.discoveryApi.getRepositoryInformation();
|
||||
}
|
||||
|
||||
listFavorites(personId: string, opts?: any): Promise<FavoritePaging> {
|
||||
return this.favoritesApi.listFavorites(personId, opts);
|
||||
}
|
||||
|
||||
createFavorite(personId: string, favoriteBodyCreate: FavoriteBodyCreate, opts?: any): Promise<FavoriteEntry> {
|
||||
return this.favoritesApi.createFavorite(personId, favoriteBodyCreate, opts);
|
||||
}
|
||||
|
||||
deleteFavorite(personId: string, favoriteId: string): Promise<any> {
|
||||
return this.favoritesApi.deleteFavorite(personId, favoriteId);
|
||||
}
|
||||
|
||||
search(request: SearchRequest): Promise<ResultSetPaging> {
|
||||
return this.searchApi.search(request);
|
||||
}
|
||||
|
||||
deleteSite(siteId?: string, opts?: { permanent?: boolean }): Promise<any> {
|
||||
return this.sitesApi.deleteSite(siteId, opts);
|
||||
}
|
||||
|
||||
deleteSiteMembership(siteId: string, personId: string): Promise<any> {
|
||||
return this.sitesApi.deleteSiteMembership(siteId, personId);
|
||||
}
|
||||
|
||||
createSite(
|
||||
siteBody: SiteBody,
|
||||
opts?: {
|
||||
fields?: Array<string>;
|
||||
skipConfiguration?: boolean;
|
||||
skipAddToFavorites?: boolean;
|
||||
}
|
||||
): Promise<SiteEntry> {
|
||||
return this.sitesApi.createSite(siteBody, opts);
|
||||
}
|
||||
|
||||
getSite(siteId?: string, opts?: { relations?: Array<string>; fields?: Array<string> }): Promise<SiteEntry> {
|
||||
return this.sitesApi.getSite(siteId, opts);
|
||||
}
|
||||
|
||||
updateSite(siteId: string, siteBody: SiteBody): Promise<SiteEntry> {
|
||||
return this.sitesApi.updateSite(siteId, siteBody);
|
||||
}
|
||||
|
||||
getRecentFiles(personId: string, pagination: PaginationModel, filters?: string[]): Observable<ResultSetPaging> {
|
||||
const defaultFilter = [
|
||||
'TYPE:"content"',
|
||||
'-PNAME:"0/wiki"',
|
||||
'-TYPE:"app:filelink"',
|
||||
'-TYPE:"cm:thumbnail"',
|
||||
'-TYPE:"cm:failedThumbnail"',
|
||||
'-TYPE:"cm:rating"',
|
||||
'-TYPE:"dl:dataList"',
|
||||
'-TYPE:"dl:todoList"',
|
||||
'-TYPE:"dl:issue"',
|
||||
'-TYPE:"dl:contact"',
|
||||
'-TYPE:"dl:eventAgenda"',
|
||||
'-TYPE:"dl:event"',
|
||||
'-TYPE:"dl:task"',
|
||||
'-TYPE:"dl:simpletask"',
|
||||
'-TYPE:"dl:meetingAgenda"',
|
||||
'-TYPE:"dl:location"',
|
||||
'-TYPE:"fm:topic"',
|
||||
'-TYPE:"fm:post"',
|
||||
'-TYPE:"ia:calendarEvent"',
|
||||
'-TYPE:"lnk:link"'
|
||||
];
|
||||
|
||||
return new Observable((observer) => {
|
||||
this.peopleApi.getPerson(personId)
|
||||
.then((person) => {
|
||||
const username = person.entry.id;
|
||||
const filterQueries = [
|
||||
{ query: `cm:modified:[NOW/DAY-30DAYS TO NOW/DAY+1DAY]` },
|
||||
{ query: `cm:modifier:${username} OR cm:creator:${username}` },
|
||||
{ query: defaultFilter.join(' AND ') }
|
||||
];
|
||||
|
||||
if (filters && filters.length > 0) {
|
||||
filterQueries.push({
|
||||
query: filters.join()
|
||||
});
|
||||
}
|
||||
|
||||
const query = new SearchRequest({
|
||||
query: {
|
||||
query: '*',
|
||||
language: 'afts'
|
||||
},
|
||||
filterQueries,
|
||||
include: ['path', 'properties', 'allowableOperations'],
|
||||
sort: [{
|
||||
type: 'FIELD',
|
||||
field: 'cm:modified',
|
||||
ascending: false
|
||||
}],
|
||||
paging: {
|
||||
maxItems: pagination.maxItems,
|
||||
skipCount: pagination.skipCount
|
||||
}
|
||||
});
|
||||
return this.searchApi.search(query)
|
||||
.then((searchResult) => {
|
||||
observer.next(searchResult);
|
||||
observer.complete();
|
||||
},
|
||||
(err) => {
|
||||
observer.error(err);
|
||||
observer.complete();
|
||||
});
|
||||
},
|
||||
(err) => {
|
||||
observer.error(err);
|
||||
observer.complete();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
loadFavorites(pagination: PaginationModel, includeFields: string[] = [], where?: string): Observable<FavoritePaging> {
|
||||
const includeFieldsRequest = this.getIncludesFields(includeFields);
|
||||
const defaultPredicate = '(EXISTS(target/file) OR EXISTS(target/folder))';
|
||||
|
||||
const options = {
|
||||
maxItems: pagination.maxItems,
|
||||
skipCount: pagination.skipCount,
|
||||
where: where ? `${where} AND ${defaultPredicate}` : defaultPredicate,
|
||||
include: includeFieldsRequest
|
||||
};
|
||||
|
||||
return new Observable((observer) => {
|
||||
this.favoritesApi.listFavorites('-me-', options)
|
||||
.then((result: FavoritePaging) => {
|
||||
const page: FavoritePaging = {
|
||||
list: {
|
||||
entries: result.list.entries
|
||||
.map(({ entry }: any) => {
|
||||
const target = entry.target.file || entry.target.folder;
|
||||
target.properties = {
|
||||
...(target.properties || {
|
||||
'cm:title': entry.title || target.title,
|
||||
'cm:description': entry.description || target.description
|
||||
}),
|
||||
...(entry.properties || {})
|
||||
};
|
||||
|
||||
return {
|
||||
entry: target
|
||||
};
|
||||
}),
|
||||
pagination: result.list.pagination
|
||||
}
|
||||
};
|
||||
|
||||
observer.next(page);
|
||||
observer.complete();
|
||||
},
|
||||
(err) => {
|
||||
observer.error(err);
|
||||
observer.complete();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
loadMemberSites(pagination: PaginationModel, where?: string): Observable<SiteMemberPaging> {
|
||||
const options = {
|
||||
include: ['properties'],
|
||||
maxItems: pagination.maxItems,
|
||||
skipCount: pagination.skipCount,
|
||||
where
|
||||
};
|
||||
|
||||
return new Observable((observer) => {
|
||||
this.sitesApi.listSiteMembershipsForPerson('-me-', options)
|
||||
.then((result: SiteRolePaging) => {
|
||||
const page: SiteMemberPaging = new SiteMemberPaging({
|
||||
list: {
|
||||
entries: result.list.entries
|
||||
.map(({ entry: { site } }: any) => {
|
||||
site.allowableOperations = site.allowableOperations ? site.allowableOperations : [this.CREATE_PERMISSION];
|
||||
site.name = site.name || site.title;
|
||||
return {
|
||||
entry: site
|
||||
};
|
||||
}),
|
||||
pagination: result.list.pagination
|
||||
}
|
||||
});
|
||||
|
||||
observer.next(page);
|
||||
observer.complete();
|
||||
},
|
||||
(err) => {
|
||||
observer.error(err);
|
||||
observer.complete();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
loadSites(pagination: PaginationModel, where?: string): Observable<SitePaging> {
|
||||
const options = {
|
||||
include: ['properties', 'aspectNames'],
|
||||
maxItems: pagination.maxItems,
|
||||
skipCount: pagination.skipCount,
|
||||
where
|
||||
};
|
||||
|
||||
return new Observable((observer) => {
|
||||
this.sitesApi
|
||||
.listSites(options)
|
||||
.then(
|
||||
(page) => {
|
||||
page.list.entries.map(
|
||||
({ entry }: any) => {
|
||||
entry.name = entry.name || entry.title;
|
||||
return { entry };
|
||||
}
|
||||
);
|
||||
observer.next(page);
|
||||
observer.complete();
|
||||
},
|
||||
(err) => {
|
||||
observer.error(err);
|
||||
observer.complete();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
loadTrashcan(pagination: PaginationModel, includeFields: string[] = []): Observable<DeletedNodesPaging> {
|
||||
const includeFieldsRequest = this.getIncludesFields(includeFields);
|
||||
|
||||
const options = {
|
||||
include: includeFieldsRequest,
|
||||
maxItems: pagination.maxItems,
|
||||
skipCount: pagination.skipCount
|
||||
};
|
||||
|
||||
return from(this.trashcanApi.listDeletedNodes(options));
|
||||
|
||||
}
|
||||
|
||||
loadSharedLinks(pagination: PaginationModel, includeFields: string[] = [], where?: string): Observable<SharedLinkPaging> {
|
||||
const includeFieldsRequest = this.getIncludesFields(includeFields);
|
||||
|
||||
const options = {
|
||||
include: includeFieldsRequest,
|
||||
maxItems: pagination.maxItems,
|
||||
skipCount: pagination.skipCount,
|
||||
where
|
||||
};
|
||||
|
||||
return from(this.sharedLinksApi.listSharedLinks(options));
|
||||
}
|
||||
|
||||
private getIncludesFields(includeFields: string[]): string[] {
|
||||
return ['path', 'properties', 'allowableOperations', 'permissions', 'aspectNames', ...includeFields]
|
||||
.filter((element, index, array) => index === array.indexOf(element));
|
||||
}
|
||||
}
|
191
lib/core/services/content-provider.service.ts
Normal file
191
lib/core/services/content-provider.service.ts
Normal file
@@ -0,0 +1,191 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 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 {
|
||||
DeletedNodesPaging,
|
||||
DiscoveryEntry,
|
||||
FavoriteBodyCreate,
|
||||
FavoriteEntry,
|
||||
FavoritePaging,
|
||||
NodeBodyCopy,
|
||||
NodeBodyCreate,
|
||||
NodeBodyLock,
|
||||
NodeBodyMove,
|
||||
NodeBodyUpdate,
|
||||
NodeChildAssociationPaging,
|
||||
NodeEntry,
|
||||
PersonEntry,
|
||||
RenditionBodyCreate,
|
||||
RenditionEntry,
|
||||
RenditionPaging,
|
||||
ResultSetPaging,
|
||||
RevertBody,
|
||||
SearchRequest,
|
||||
SharedLinkEntry,
|
||||
SharedLinkPaging,
|
||||
SiteBody,
|
||||
SiteEntry,
|
||||
SiteMemberPaging,
|
||||
SitePaging,
|
||||
VersionEntry,
|
||||
VersionPaging
|
||||
} from '@alfresco/js-api';
|
||||
import { InjectionToken, Provider, Type } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PaginationModel } from '../models/pagination.model';
|
||||
|
||||
export const CONTENT_SERVICES_PROVIDERS = new InjectionToken<ContentServiceProvider[]>('content-services-providers');
|
||||
|
||||
export const DEFAULT_CONTENT_SERVICES_PROVIDER = new InjectionToken<ContentServiceProvider>('default-content-services-provider');
|
||||
|
||||
export function registerContentServiceProvider(implementationClass: Type<ContentServiceProvider>, defaultProvider: boolean): Provider[] {
|
||||
const providers = [{
|
||||
provide: CONTENT_SERVICES_PROVIDERS,
|
||||
multi: true,
|
||||
useExisting: implementationClass
|
||||
}];
|
||||
|
||||
if (defaultProvider) {
|
||||
providers.push({
|
||||
provide: DEFAULT_CONTENT_SERVICES_PROVIDER,
|
||||
multi: false,
|
||||
useExisting: implementationClass
|
||||
});
|
||||
}
|
||||
|
||||
return providers;
|
||||
}
|
||||
|
||||
export interface ContentServiceProvider {
|
||||
|
||||
getNodePrefix();
|
||||
|
||||
getContentUrl(node: NodeEntry | string, attachment?: boolean, ticket?: string);
|
||||
|
||||
getDocumentThumbnailUrl(nodeId: string, attachment?: boolean, ticket?: string);
|
||||
|
||||
getVersionContentUrl(nodeId: string, versionId: string, attachment?: boolean, ticket?: string);
|
||||
|
||||
getSharedLinkContentUrl(linkId: string, attachment?: boolean);
|
||||
|
||||
getSharedLinkRenditionUrl(sharedId: string, renditionId: string, attachment?: boolean);
|
||||
|
||||
getRenditionUrl(nodeId: string, encoding: string, attachment?: boolean, ticket?: string);
|
||||
|
||||
getVersionRenditionUrl(nodeId: string, versionId: string, encoding: string, attachment?: boolean, ticket?: string): string;
|
||||
|
||||
getNodeContent(nodeId: string): Promise<any>;
|
||||
|
||||
getNode(nodeId: string, opts?: any): Promise<NodeEntry>;
|
||||
|
||||
lockNode(nodeId: string, nodeBodyLock: NodeBodyLock, opts?: any): Promise<NodeEntry>;
|
||||
|
||||
unlockNode(nodeId: string, opts?: any): Promise<NodeEntry>;
|
||||
|
||||
deleteNode(nodeId: string, opts?: any): Promise<any>;
|
||||
|
||||
copyNode(nodeId: string, nodeBodyCopy: NodeBodyCopy, opts?: any): Promise<NodeEntry>;
|
||||
|
||||
moveNode(nodeId: string, nodeBodyMove: NodeBodyMove, opts?: any): Promise<NodeEntry>;
|
||||
|
||||
listNodeChildren(nodeId: string, opts?: any): Promise<NodeChildAssociationPaging>;
|
||||
|
||||
createNode(nodeId: string, nodeBodyCreate: NodeBodyCreate, opts?: any, formParams?: any): Promise<NodeEntry | any>;
|
||||
|
||||
updateNode(nodeId: string, nodeBodyUpdate: NodeBodyUpdate, opts?: any): Promise<NodeEntry>;
|
||||
|
||||
updateNodeContent(nodeId: string, contentBodyUpdate: string, opts?: any): Promise<NodeEntry>;
|
||||
|
||||
revertVersion(nodeId: string, versionId: string, revertBody: RevertBody, opts?: any): Promise<VersionEntry>;
|
||||
|
||||
deleteVersion(nodeId: string, versionId: string): Promise<any>;
|
||||
|
||||
listVersionHistory(nodeId: string, opts?: any): Promise<VersionPaging>;
|
||||
|
||||
getVersion(nodeId: string, versionId: string): Promise<VersionEntry>;
|
||||
|
||||
listVersionRenditions(nodeId: string, versionId: string, opts?: any): Promise<RenditionPaging>;
|
||||
|
||||
createVersionRendition(nodeId: string, versionId: string, renditionBodyCreate: RenditionBodyCreate): Promise<any>;
|
||||
|
||||
getVersionRendition(nodeId: string, versionId: string, renditionId: string): Promise<RenditionEntry>;
|
||||
|
||||
getNodeVersions(nodeId: string, opts?: any);
|
||||
|
||||
deleteDeletedNode(nodeId: string): Promise<any>;
|
||||
|
||||
listDeletedNodes(opts?: any): Promise<DeletedNodesPaging>;
|
||||
|
||||
restoreDeletedNode(nodeId: string, opts?: any): Promise<NodeEntry>;
|
||||
|
||||
getSharedLink(sharedId: string, opts?: any): Promise<SharedLinkEntry>;
|
||||
|
||||
getSharedLinkRendition(sharedId: string, renditionId: string): Promise<RenditionEntry>;
|
||||
|
||||
listSharedLinks(opts?: any): Promise<SharedLinkPaging>;
|
||||
|
||||
deleteSharedLink(sharedId: string): Promise<any>;
|
||||
|
||||
uploadFile(fileDefinition: any, relativePath: string, rootFolderId: string, nodeBody: any, opts?: any): Promise<any>;
|
||||
|
||||
listRenditions(nodeId: string, opts?: any): Promise<RenditionPaging>;
|
||||
|
||||
createRendition(nodeId: string, renditionBodyCreate: RenditionBodyCreate): Promise<any>;
|
||||
|
||||
getRendition(nodeId: string, renditionId: string): Promise<RenditionEntry>;
|
||||
|
||||
getPerson(personId: string, opts?: any): Promise<PersonEntry>;
|
||||
|
||||
getRepositoryInformation(): Promise<DiscoveryEntry>;
|
||||
|
||||
listFavorites(personId: string, opts?: any): Promise<FavoritePaging>;
|
||||
|
||||
createFavorite(personId: string, favoriteBodyCreate: FavoriteBodyCreate, opts?: any): Promise<FavoriteEntry>;
|
||||
|
||||
deleteFavorite(personId: string, favoriteId: string): Promise<any>;
|
||||
|
||||
search(request: SearchRequest): Promise<ResultSetPaging>;
|
||||
|
||||
deleteSite(siteId?: string, opts?: { permanent?: boolean }): Promise<any>;
|
||||
|
||||
deleteSiteMembership(siteId: string, personId: string): Promise<any>;
|
||||
|
||||
createSite(
|
||||
siteBody: SiteBody,
|
||||
opts?: {
|
||||
fields?: Array<string>;
|
||||
skipConfiguration?: boolean;
|
||||
skipAddToFavorites?: boolean;
|
||||
}
|
||||
): Promise<SiteEntry>;
|
||||
|
||||
getSite(siteId?: string, opts?: { relations?: Array<string>; fields?: Array<string> }): Promise<SiteEntry>;
|
||||
|
||||
updateSite(siteId: string, siteBody: SiteBody): Promise<SiteEntry>;
|
||||
|
||||
getRecentFiles(personId: string, pagination: PaginationModel, filters?: string[]): Observable<ResultSetPaging>;
|
||||
|
||||
loadFavorites(pagination: PaginationModel, includeFields: string[], where?: string): Observable<FavoritePaging> ;
|
||||
|
||||
loadMemberSites(pagination: PaginationModel, where?: string): Observable<SiteMemberPaging>;
|
||||
|
||||
loadSites(pagination: PaginationModel, where?: string): Observable<SitePaging>;
|
||||
|
||||
loadTrashcan(pagination: PaginationModel, includeFields: string[]): Observable<DeletedNodesPaging>;
|
||||
|
||||
loadSharedLinks(pagination: PaginationModel, includeFields: string[], where?: string): Observable<SharedLinkPaging>;
|
||||
}
|
@@ -15,47 +15,96 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Inject, Injectable } from '@angular/core';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { ContentApi, MinimalNode, Node, NodeEntry, NodesApi } from '@alfresco/js-api';
|
||||
import { Observable, Subject, from, throwError } from 'rxjs';
|
||||
import {
|
||||
DeletedNodesPaging,
|
||||
DeletedNodesPagingList,
|
||||
DiscoveryEntry,
|
||||
FavoriteBodyCreate,
|
||||
FavoriteEntry,
|
||||
FavoritePaging,
|
||||
FavoritePagingList,
|
||||
MinimalNode,
|
||||
Node,
|
||||
NodeBodyCopy,
|
||||
NodeBodyCreate,
|
||||
NodeBodyLock,
|
||||
NodeBodyMove,
|
||||
NodeBodyUpdate,
|
||||
NodeChildAssociationPaging,
|
||||
NodeEntry,
|
||||
PersonEntry,
|
||||
RenditionBodyCreate,
|
||||
RenditionEntry,
|
||||
RenditionPaging,
|
||||
ResultSetPaging,
|
||||
ResultSetPagingList,
|
||||
RevertBody,
|
||||
SearchRequest,
|
||||
SharedLinkEntry,
|
||||
SharedLinkPaging,
|
||||
SharedLinkPagingList,
|
||||
SiteBody,
|
||||
SiteEntry,
|
||||
SiteMemberPaging,
|
||||
SiteMemberPagingList,
|
||||
SitePaging,
|
||||
SitePagingList,
|
||||
VersionEntry,
|
||||
VersionPaging
|
||||
} from '@alfresco/js-api';
|
||||
import { Observable, Subject, throwError, forkJoin, from } from 'rxjs';
|
||||
import { FolderCreatedEvent } from '../events/folder-created.event';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { AuthenticationService } from './authentication.service';
|
||||
import { LogService } from './log.service';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { PermissionsEnum } from '../models/permissions.enum';
|
||||
import { AllowableOperationsEnum } from '../models/allowable-operations.enum';
|
||||
import { DownloadService } from './download.service';
|
||||
import { ThumbnailService } from './thumbnail.service';
|
||||
|
||||
import { ContentServiceProvider, CONTENT_SERVICES_PROVIDERS, DEFAULT_CONTENT_SERVICES_PROVIDER } from './content-provider.service';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { AcsContentService } from './acs-content.service';
|
||||
import { PaginationModel } from '../models/pagination.model';
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ContentService {
|
||||
|
||||
private defaultProvider: ContentServiceProvider;
|
||||
|
||||
folderCreated: Subject<FolderCreatedEvent> = new Subject<FolderCreatedEvent>();
|
||||
folderCreate: Subject<MinimalNode> = new Subject<MinimalNode>();
|
||||
folderEdit: Subject<MinimalNode> = new Subject<MinimalNode>();
|
||||
|
||||
_contentApi: ContentApi;
|
||||
get contentApi(): ContentApi {
|
||||
this._contentApi = this._contentApi ?? new ContentApi(this.apiService.getInstance());
|
||||
return this._contentApi;
|
||||
constructor(
|
||||
public authService: AuthenticationService,
|
||||
private logService: LogService,
|
||||
private sanitizer: DomSanitizer,
|
||||
private downloadService: DownloadService,
|
||||
private apiService: AlfrescoApiService,
|
||||
@Inject(CONTENT_SERVICES_PROVIDERS) private providers: ContentServiceProvider[] = [],
|
||||
@Inject(DEFAULT_CONTENT_SERVICES_PROVIDER) private defaultContentServiceProvider: ContentServiceProvider = null) {
|
||||
switch (providers.length) {
|
||||
case 0:
|
||||
this.defaultProvider = new AcsContentService(this.apiService);
|
||||
this.providers = [this.defaultProvider];
|
||||
break;
|
||||
case 1:
|
||||
this.defaultProvider = providers[0];
|
||||
break;
|
||||
default:
|
||||
this.defaultProvider = defaultContentServiceProvider ? this.defaultContentServiceProvider : providers[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_nodesApi: NodesApi;
|
||||
get nodesApi(): NodesApi {
|
||||
this._nodesApi = this._nodesApi ?? new NodesApi(this.apiService.getInstance());
|
||||
return this._nodesApi;
|
||||
}
|
||||
|
||||
constructor(public authService: AuthenticationService,
|
||||
public apiService: AlfrescoApiService,
|
||||
private logService: LogService,
|
||||
private sanitizer: DomSanitizer,
|
||||
private downloadService: DownloadService,
|
||||
private thumbnailService: ThumbnailService) {
|
||||
private getProviderFromId(id: string): ContentServiceProvider {
|
||||
if (this.providers.length > 1) {
|
||||
return this.providers.find(provider => id.startsWith(provider.getNodePrefix())) || this.defaultProvider;
|
||||
} else {
|
||||
return this.defaultProvider;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,63 +128,6 @@ export class ContentService {
|
||||
return <string> this.sanitizer.bypassSecurityTrustUrl(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated in 3.2.0, use ThumbnailService instead.
|
||||
* Gets a thumbnail URL for the given document node.
|
||||
* @param node Node or Node ID to get URL for.
|
||||
* @param attachment Toggles whether to retrieve content as an attachment for download
|
||||
* @param ticket Custom ticket to use for authentication
|
||||
* @returns URL string
|
||||
*/
|
||||
getDocumentThumbnailUrl(node: NodeEntry | string, attachment?: boolean, ticket?: string): string {
|
||||
return this.thumbnailService.getDocumentThumbnailUrl(node, attachment, ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a content URL for the given node.
|
||||
* @param node Node or Node ID to get URL for.
|
||||
* @param attachment Toggles whether to retrieve content as an attachment for download
|
||||
* @param ticket Custom ticket to use for authentication
|
||||
* @returns URL string or `null`
|
||||
*/
|
||||
getContentUrl(node: NodeEntry | string, attachment?: boolean, ticket?: string): string {
|
||||
if (node) {
|
||||
let nodeId: string;
|
||||
|
||||
if (typeof node === 'string') {
|
||||
nodeId = node;
|
||||
} else if (node.entry) {
|
||||
nodeId = node.entry.id;
|
||||
}
|
||||
|
||||
return this.contentApi.getContentUrl(nodeId, attachment, ticket);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets content for the given node.
|
||||
* @param nodeId ID of the target node
|
||||
* @returns Content data
|
||||
*/
|
||||
getNodeContent(nodeId: string): Observable<any> {
|
||||
return from(this.nodesApi.getNodeContent(nodeId))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Node via its node ID.
|
||||
* @param nodeId ID of the target node
|
||||
* @param opts Options supported by JS-API
|
||||
* @returns Details of the folder
|
||||
*/
|
||||
getNode(nodeId: string, opts?: any): Observable<NodeEntry> {
|
||||
return from(this.nodesApi.getNode(nodeId, opts));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the user has permission on that node
|
||||
* @param node Node to check permissions
|
||||
@@ -211,4 +203,336 @@ export class ContentService {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
|
||||
getDocumentThumbnailUrl(nodeId: string, attachment?: boolean, ticket?: string): string {
|
||||
return this.getProviderFromId(nodeId).getDocumentThumbnailUrl(nodeId, attachment, ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a content URL for the given node.
|
||||
* @param node Node or Node ID to get URL for.
|
||||
* @param attachment Toggles whether to retrieve content as an attachment for download
|
||||
* @param ticket Custom ticket to use for authentication
|
||||
* @returns URL string or `null`
|
||||
*/
|
||||
getContentUrl(node: NodeEntry | string, attachment?: boolean, ticket?: string): string {
|
||||
if (node) {
|
||||
let nodeId: string;
|
||||
|
||||
if (typeof node === 'string') {
|
||||
nodeId = node;
|
||||
} else if (node.entry) {
|
||||
nodeId = node.entry.id;
|
||||
}
|
||||
|
||||
return this.getProviderFromId(nodeId).getContentUrl(nodeId, attachment, ticket);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
getVersionContentUrl(nodeId: string, versionId: string, attachment?: boolean, ticket?: string): string {
|
||||
return this.getProviderFromId(nodeId).getVersionContentUrl(nodeId, versionId, attachment, ticket);
|
||||
}
|
||||
|
||||
getSharedLinkContentUrl(linkId: string, attachment?: boolean): string {
|
||||
return this.getProviderFromId(linkId).getSharedLinkContentUrl(linkId, attachment);
|
||||
}
|
||||
|
||||
getSharedLinkRenditionUrl(sharedId: string, renditionId: string, attachment?: boolean): string {
|
||||
return this.getProviderFromId(sharedId).getSharedLinkRenditionUrl(sharedId, renditionId, attachment);
|
||||
}
|
||||
|
||||
getRenditionUrl(nodeId: string, encoding: string, attachment?: boolean, ticket?: string): string {
|
||||
return this.getProviderFromId(nodeId).getRenditionUrl(nodeId, encoding, attachment, ticket);
|
||||
}
|
||||
|
||||
getVersionRenditionUrl(nodeId: string, versionId: string, encoding: string, attachment?: boolean, ticket?: string): string {
|
||||
return this.getProviderFromId(nodeId).getVersionRenditionUrl(nodeId, versionId, encoding, attachment, ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets content for the given node.
|
||||
* @param nodeId ID of the target node
|
||||
* @returns Content data
|
||||
*/
|
||||
getNodeContent(nodeId: string): Observable<any> {
|
||||
return from(this.getProviderFromId(nodeId).getNodeContent(nodeId))
|
||||
.pipe(
|
||||
catchError((err: any) => this.handleError(err)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Node via its node ID.
|
||||
* @param nodeId ID of the target node
|
||||
* @param opts Options supported by JS-API
|
||||
* @returns Details of the folder
|
||||
*/
|
||||
getNode(nodeId: string, opts?: any): Observable<NodeEntry> {
|
||||
return from(this.getProviderFromId(nodeId).getNode(nodeId, opts));
|
||||
}
|
||||
|
||||
lockNode(nodeId: string, nodeBodyLock: NodeBodyLock, opts?: any): Promise<NodeEntry> {
|
||||
return this.getProviderFromId(nodeId).lockNode(nodeId, nodeBodyLock, opts);
|
||||
}
|
||||
|
||||
unlockNode(nodeId: string, opts?: any): Promise<NodeEntry> {
|
||||
return this.getProviderFromId(nodeId).unlockNode(nodeId, opts);
|
||||
}
|
||||
|
||||
deleteNode(nodeId: string, opts?: any): Promise<any> {
|
||||
return this.getProviderFromId(nodeId).deleteNode(nodeId, opts);
|
||||
}
|
||||
|
||||
copyNode(nodeId: string, nodeBodyCopy: NodeBodyCopy, opts?: any): Promise<NodeEntry> {
|
||||
return this.getProviderFromId(nodeId).copyNode(nodeId, nodeBodyCopy, opts);
|
||||
}
|
||||
|
||||
moveNode(nodeId: string, nodeBodyMove: NodeBodyMove, opts?: any): Promise<NodeEntry> {
|
||||
return this.getProviderFromId(nodeId).moveNode(nodeId, nodeBodyMove, opts);
|
||||
}
|
||||
|
||||
listNodeChildren(nodeId: string, opts?: any): Promise<NodeChildAssociationPaging> {
|
||||
return this.getProviderFromId(nodeId).listNodeChildren(nodeId, opts);
|
||||
}
|
||||
|
||||
createNode(nodeId: string, nodeBodyCreate: NodeBodyCreate, opts?: any, formParams?: any): Promise<NodeEntry | any> {
|
||||
return this.getProviderFromId(nodeId).createNode(nodeId, nodeBodyCreate, opts, formParams);
|
||||
}
|
||||
|
||||
updateNode(nodeId: string, nodeBodyUpdate: NodeBodyUpdate, opts?: any): Promise<NodeEntry> {
|
||||
return this.getProviderFromId(nodeId).updateNode(nodeId, nodeBodyUpdate, opts);
|
||||
}
|
||||
|
||||
updateNodeContent(nodeId: string, contentBodyUpdate: string, opts?: any): Promise<NodeEntry> {
|
||||
return this.getProviderFromId(nodeId).updateNodeContent(nodeId, contentBodyUpdate, opts);
|
||||
}
|
||||
|
||||
revertVersion(nodeId: string, versionId: string, revertBody: RevertBody, opts?: any): Promise<VersionEntry> {
|
||||
return this.getProviderFromId(nodeId).revertVersion(nodeId, versionId, revertBody, opts);
|
||||
}
|
||||
|
||||
deleteVersion(nodeId: string, versionId: string): Promise<any> {
|
||||
return this.getProviderFromId(nodeId).deleteVersion(nodeId, versionId);
|
||||
}
|
||||
|
||||
listVersionHistory(nodeId: string, opts?: any): Promise<VersionPaging> {
|
||||
return this.getProviderFromId(nodeId).listVersionHistory(nodeId, opts);
|
||||
}
|
||||
|
||||
getVersion(nodeId: string, versionId: string): Promise<VersionEntry> {
|
||||
return this.getProviderFromId(nodeId).getVersion(nodeId, versionId);
|
||||
}
|
||||
|
||||
listVersionRenditions(nodeId: string, versionId: string, opts?: any): Promise<RenditionPaging> {
|
||||
return this.getProviderFromId(nodeId).listVersionRenditions(nodeId, versionId, opts);
|
||||
}
|
||||
|
||||
createVersionRendition(nodeId: string, versionId: string, renditionBodyCreate: RenditionBodyCreate): Promise<any> {
|
||||
return this.getProviderFromId(nodeId).createVersionRendition(nodeId, versionId, renditionBodyCreate);
|
||||
}
|
||||
|
||||
getVersionRendition(nodeId: string, versionId: string, renditionId: string): Promise<RenditionEntry> {
|
||||
return this.getProviderFromId(nodeId).getVersionRendition(nodeId, versionId, renditionId);
|
||||
}
|
||||
|
||||
deleteDeletedNode(nodeId: string): Promise<any> {
|
||||
return this.getProviderFromId(nodeId).deleteDeletedNode(nodeId);
|
||||
}
|
||||
|
||||
listDeletedNodes(opts?: any): Promise<DeletedNodesPaging> {
|
||||
const deletedNodes: Promise<DeletedNodesPaging>[] = [];
|
||||
this.providers.map(provider => deletedNodes.push(provider.listDeletedNodes(opts)));
|
||||
|
||||
return Promise.all(deletedNodes).then(nodes => this.mergeDeletedNodesPaging(nodes));
|
||||
}
|
||||
|
||||
restoreDeletedNode(nodeId: string, opts?: any): Promise<NodeEntry> {
|
||||
return this.getProviderFromId(nodeId).restoreDeletedNode(nodeId, opts);
|
||||
}
|
||||
|
||||
getSharedLink(sharedId: string, opts?: any): Promise<SharedLinkEntry> {
|
||||
return this.getProviderFromId(sharedId).getSharedLink(sharedId, opts);
|
||||
}
|
||||
|
||||
getSharedLinkRendition(sharedId: string, renditionId: string): Promise<RenditionEntry> {
|
||||
return this.getProviderFromId(sharedId).getSharedLinkRendition(sharedId, renditionId);
|
||||
}
|
||||
|
||||
listSharedLinks(opts?: any): Promise<SharedLinkPaging> {
|
||||
const paging: Promise<SharedLinkPaging>[] = [];
|
||||
this.providers.map(provider => paging.push(provider.listSharedLinks(opts)));
|
||||
|
||||
return Promise.all(paging).then(nodes => this.mergeSharedLinkPaging(nodes));
|
||||
}
|
||||
|
||||
deleteSharedLink(sharedId: string): Promise<any> {
|
||||
return this.getProviderFromId(sharedId).deleteSharedLink(sharedId);
|
||||
}
|
||||
|
||||
uploadFile(fileDefinition: any, relativePath: string, rootFolderId: string, nodeBody: any, opts?: any): Promise<any> {
|
||||
return this.getProviderFromId(rootFolderId).uploadFile(fileDefinition, relativePath, rootFolderId, nodeBody, opts);
|
||||
}
|
||||
|
||||
listRenditions(nodeId: string, opts?: any): Promise<RenditionPaging> {
|
||||
return this.getProviderFromId(nodeId).listRenditions(nodeId, opts);
|
||||
}
|
||||
|
||||
createRendition(nodeId: string, renditionBodyCreate: RenditionBodyCreate): Promise<any> {
|
||||
return this.getProviderFromId(nodeId).createRendition(nodeId, renditionBodyCreate);
|
||||
}
|
||||
|
||||
getRendition(nodeId: string, renditionId: string): Promise<RenditionEntry> {
|
||||
return this.getProviderFromId(nodeId).getRendition(nodeId, renditionId);
|
||||
}
|
||||
|
||||
getPerson(personId: string, opts?: any): Promise<PersonEntry> {
|
||||
return this.defaultProvider.getPerson(personId, opts);
|
||||
}
|
||||
|
||||
getRepositoryInformation(): Promise<DiscoveryEntry> {
|
||||
return this.defaultProvider.getRepositoryInformation();
|
||||
}
|
||||
|
||||
listFavorites(personId: string, opts?: any): Promise<FavoritePaging> {
|
||||
return this.defaultProvider.listFavorites(personId, opts);
|
||||
}
|
||||
|
||||
createFavorite(personId: string, favoriteBodyCreate: FavoriteBodyCreate, opts?: any): Promise<FavoriteEntry> {
|
||||
return this.defaultProvider.createFavorite(personId, favoriteBodyCreate, opts);
|
||||
}
|
||||
|
||||
deleteFavorite(personId: string, favoriteId: string): Promise<any> {
|
||||
return this.getProviderFromId(favoriteId).deleteFavorite(personId, favoriteId);
|
||||
}
|
||||
|
||||
search(request: SearchRequest): Promise<ResultSetPaging> {
|
||||
const searchResultNodes: Promise<ResultSetPaging>[] = [];
|
||||
this.providers.map(provider => searchResultNodes.push(provider.search(request)));
|
||||
|
||||
return Promise.all(searchResultNodes).then(nodes => this.mergeResultSetPaging(nodes));
|
||||
}
|
||||
|
||||
deleteSite(siteId?: string, opts?: { permanent?: boolean }): Promise<any> {
|
||||
return this.getProviderFromId(siteId).deleteSite(siteId, opts);
|
||||
}
|
||||
|
||||
leaveSite(siteId?: string, personId?: string): Promise<any> {
|
||||
return this.getProviderFromId(siteId).deleteSiteMembership(siteId, personId);
|
||||
}
|
||||
|
||||
createSite(
|
||||
siteBody: SiteBody,
|
||||
opts?: {
|
||||
fields?: Array<string>;
|
||||
skipConfiguration?: boolean;
|
||||
skipAddToFavorites?: boolean;
|
||||
}
|
||||
): Promise<SiteEntry> {
|
||||
return this.getProviderFromId(siteBody.id).createSite(siteBody, opts);
|
||||
}
|
||||
|
||||
getSite(siteId?: string, opts?: { relations?: Array<string>; fields?: Array<string> }): Promise<SiteEntry> {
|
||||
return this.getProviderFromId(siteId).getSite(siteId, opts);
|
||||
}
|
||||
|
||||
updateSite(siteId: string, siteBody: SiteBody): Promise<SiteEntry> {
|
||||
return this.getProviderFromId(siteId).updateSite(siteId, siteBody);
|
||||
}
|
||||
|
||||
getRecentFiles(personId: string, pagination: PaginationModel, filters?: string[]): Observable<ResultSetPaging> {
|
||||
const resultSetPaging: Observable<ResultSetPaging>[] = [];
|
||||
this.providers.map(provider => resultSetPaging.push(provider.getRecentFiles(personId, pagination, filters)));
|
||||
|
||||
return forkJoin(resultSetPaging).pipe(map(nodes => this.mergeResultSetPaging(nodes)));
|
||||
}
|
||||
|
||||
loadFavorites(pagination: PaginationModel, includeFields: string[], where?: string): Observable<FavoritePaging> {
|
||||
const paging: Observable<FavoritePaging>[] = [];
|
||||
this.providers.map(provider => paging.push(provider.loadFavorites(pagination, includeFields, where)));
|
||||
|
||||
return forkJoin(paging).pipe(map(nodes => this.mergeFavoritePaging(nodes)));
|
||||
}
|
||||
|
||||
loadMemberSites(pagination: PaginationModel, where?: string): Observable<SiteMemberPaging> {
|
||||
const paging: Observable<SiteMemberPaging>[] = [];
|
||||
this.providers.map(provider => paging.push(provider.loadMemberSites(pagination, where)));
|
||||
|
||||
return forkJoin(paging).pipe(map(nodes => this.mergeSiteMemberPaging(nodes)));
|
||||
}
|
||||
|
||||
loadSites(pagination: PaginationModel, where?: string): Observable<SitePaging> {
|
||||
const paging: Observable<SitePaging>[] = [];
|
||||
this.providers.map(provider => paging.push(provider.loadSites(pagination, where)));
|
||||
|
||||
return forkJoin(paging).pipe(map(nodes => this.mergeSitePaging(nodes)));
|
||||
}
|
||||
|
||||
loadTrashcan(pagination: PaginationModel, includeFields: string[]): Observable<DeletedNodesPaging> {
|
||||
const paging: Observable<DeletedNodesPaging>[] = [];
|
||||
this.providers.map(provider => paging.push(provider.loadTrashcan(pagination, includeFields)));
|
||||
|
||||
return forkJoin(paging).pipe(map(nodes => this.mergeDeletedNodesPaging(nodes)));
|
||||
}
|
||||
|
||||
loadSharedLinks(pagination: PaginationModel, includeFields: string[], where?: string): Observable<SharedLinkPaging> {
|
||||
const paging: Observable<SharedLinkPaging>[] = [];
|
||||
this.providers.map(provider => paging.push(provider.loadSharedLinks(pagination, includeFields, where)));
|
||||
|
||||
return forkJoin(paging).pipe(map(nodes => this.mergeSharedLinkPaging(nodes)));
|
||||
}
|
||||
|
||||
private mergeDeletedNodesPaging(nodes: DeletedNodesPaging[]): DeletedNodesPaging {
|
||||
const result = new DeletedNodesPaging();
|
||||
result.list = new DeletedNodesPagingList();
|
||||
result.list.pagination = nodes[0].list.pagination;
|
||||
result.list.entries = [];
|
||||
nodes.map(node => result.list.entries = result.list.entries.concat(node.list.entries));
|
||||
return result;
|
||||
}
|
||||
|
||||
private mergeResultSetPaging(nodes: ResultSetPaging[]): ResultSetPaging {
|
||||
const result = new ResultSetPaging();
|
||||
result.list = new ResultSetPagingList();
|
||||
result.list.pagination = nodes[0].list.pagination;
|
||||
result.list.entries = [];
|
||||
nodes.map(node => result.list.entries = result.list.entries.concat(node.list.entries));
|
||||
return result;
|
||||
}
|
||||
|
||||
private mergeFavoritePaging(nodes: FavoritePaging[]): FavoritePaging {
|
||||
const result = new FavoritePaging();
|
||||
result.list = new FavoritePagingList();
|
||||
result.list.pagination = nodes[0].list.pagination;
|
||||
result.list.entries = [];
|
||||
nodes.map(node => result.list.entries = result.list.entries.concat(node.list.entries));
|
||||
return result;
|
||||
}
|
||||
|
||||
private mergeSiteMemberPaging(nodes: SiteMemberPaging[]): SiteMemberPaging {
|
||||
const result = new SiteMemberPaging();
|
||||
result.list = new SiteMemberPagingList();
|
||||
result.list.pagination = nodes[0].list.pagination;
|
||||
result.list.entries = [];
|
||||
nodes.map(node => result.list.entries = result.list.entries.concat(node.list.entries));
|
||||
return result;
|
||||
}
|
||||
|
||||
private mergeSitePaging(nodes: SitePaging[]): SitePaging {
|
||||
const result = new SitePaging();
|
||||
result.list = new SitePagingList();
|
||||
result.list.pagination = nodes[0].list.pagination;
|
||||
result.list.entries = [];
|
||||
nodes.map(node => result.list.entries = result.list.entries.concat(node.list.entries));
|
||||
return result;
|
||||
}
|
||||
|
||||
private mergeSharedLinkPaging(nodes: SharedLinkPaging[]): SharedLinkPaging {
|
||||
const result = new SharedLinkPaging();
|
||||
result.list = new SharedLinkPagingList();
|
||||
result.list.pagination = nodes[0].list.pagination;
|
||||
result.list.entries = [];
|
||||
nodes.map(node => result.list.entries = result.list.entries.concat(node.list.entries));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -18,30 +18,18 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, from, of } from 'rxjs';
|
||||
|
||||
import { NodePaging, NodesApi, TrashcanApi } from '@alfresco/js-api';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { NodePaging } from '@alfresco/js-api';
|
||||
import { UserPreferencesService } from './user-preferences.service';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { ContentService } from './content.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class DeletedNodesApiService {
|
||||
|
||||
_nodesApi: NodesApi;
|
||||
get nodesApi(): NodesApi {
|
||||
this._nodesApi = this._nodesApi ?? new NodesApi(this.apiService.getInstance());
|
||||
return this._nodesApi;
|
||||
}
|
||||
|
||||
_trashcanApi: TrashcanApi;
|
||||
get trashcanApi(): TrashcanApi {
|
||||
this._trashcanApi = this._trashcanApi ?? new TrashcanApi(this.apiService.getInstance());
|
||||
return this._trashcanApi;
|
||||
}
|
||||
|
||||
constructor(
|
||||
private apiService: AlfrescoApiService,
|
||||
private contentService: ContentService,
|
||||
private preferences: UserPreferencesService
|
||||
) {
|
||||
}
|
||||
@@ -58,7 +46,7 @@ export class DeletedNodesApiService {
|
||||
skipCount: 0
|
||||
};
|
||||
const queryOptions = Object.assign(defaultOptions, options);
|
||||
const promise = this.trashcanApi.listDeletedNodes(queryOptions);
|
||||
const promise = this.contentService.listDeletedNodes(queryOptions);
|
||||
|
||||
return from(promise).pipe(
|
||||
catchError((err) => of(err))
|
||||
|
@@ -16,31 +16,19 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MinimalNode, NodeEntry, NodePaging, NodesApi, TrashcanApi } from '@alfresco/js-api';
|
||||
import { MinimalNode, NodeEntry, NodePaging } from '@alfresco/js-api';
|
||||
import { from, Observable, throwError } from 'rxjs';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { UserPreferencesService } from './user-preferences.service';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { NodeMetadata } from '../models/node-metadata.model';
|
||||
import { ContentService } from './content.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NodesApiService {
|
||||
|
||||
_trashcanApi: TrashcanApi;
|
||||
get trashcanApi(): TrashcanApi {
|
||||
this._trashcanApi = this._trashcanApi ?? new TrashcanApi(this.apiService.getInstance());
|
||||
return this._trashcanApi;
|
||||
}
|
||||
|
||||
_nodesApi: NodesApi;
|
||||
get nodesApi(): NodesApi {
|
||||
this._nodesApi = this._nodesApi ?? new NodesApi(this.apiService.getInstance());
|
||||
return this._nodesApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService,
|
||||
constructor(private contentService: ContentService,
|
||||
private preferences: UserPreferencesService) {
|
||||
}
|
||||
|
||||
@@ -60,7 +48,7 @@ export class NodesApiService {
|
||||
};
|
||||
const queryOptions = Object.assign(defaults, options);
|
||||
|
||||
return from(this.nodesApi.getNode(nodeId, queryOptions)).pipe(
|
||||
return this.contentService.getNode(nodeId, queryOptions).pipe(
|
||||
map(this.getEntryFromEntity),
|
||||
catchError((err) => throwError(err))
|
||||
);
|
||||
@@ -80,7 +68,7 @@ export class NodesApiService {
|
||||
};
|
||||
const queryOptions = Object.assign(defaults, options);
|
||||
|
||||
return from(this.nodesApi.listNodeChildren(nodeId, queryOptions)).pipe(
|
||||
return from(this.contentService.listNodeChildren(nodeId, queryOptions)).pipe(
|
||||
catchError((err) => throwError(err))
|
||||
);
|
||||
}
|
||||
@@ -93,7 +81,7 @@ export class NodesApiService {
|
||||
* @returns Details of the new node
|
||||
*/
|
||||
createNode(parentNodeId: string, nodeBody: any, options: any = {}): Observable<MinimalNode> {
|
||||
return from(this.nodesApi.createNode(parentNodeId, nodeBody, options)).pipe(
|
||||
return from(this.contentService.createNode(parentNodeId, nodeBody, options)).pipe(
|
||||
map(this.getEntryFromEntity),
|
||||
catchError((err) => throwError(err))
|
||||
);
|
||||
@@ -124,7 +112,7 @@ export class NodesApiService {
|
||||
};
|
||||
const queryOptions = Object.assign(defaults, options);
|
||||
|
||||
return from(this.nodesApi.updateNode(nodeId, nodeBody, queryOptions)).pipe(
|
||||
return from(this.contentService.updateNode(nodeId, nodeBody, queryOptions)).pipe(
|
||||
map(this.getEntryFromEntity),
|
||||
catchError((err) => throwError(err))
|
||||
);
|
||||
@@ -137,7 +125,7 @@ export class NodesApiService {
|
||||
* @returns Empty result that notifies when the deletion is complete
|
||||
*/
|
||||
deleteNode(nodeId: string, options: any = {}): Observable<any> {
|
||||
return from(this.nodesApi.deleteNode(nodeId, options)).pipe(
|
||||
return from(this.contentService.deleteNode(nodeId, options)).pipe(
|
||||
catchError((err) => throwError(err))
|
||||
);
|
||||
}
|
||||
@@ -148,7 +136,7 @@ export class NodesApiService {
|
||||
* @returns Details of the restored node
|
||||
*/
|
||||
restoreNode(nodeId: string): Observable<MinimalNode> {
|
||||
return from(this.trashcanApi.restoreDeletedNode(nodeId)).pipe(
|
||||
return from(this.contentService.restoreDeletedNode(nodeId)).pipe(
|
||||
map(this.getEntryFromEntity),
|
||||
catchError((err) => throwError(err))
|
||||
);
|
||||
@@ -160,7 +148,7 @@ export class NodesApiService {
|
||||
* @returns Node metadata
|
||||
*/
|
||||
public getNodeMetadata(nodeId: string): Observable<NodeMetadata> {
|
||||
return from(this.nodesApi.getNode(nodeId))
|
||||
return this.contentService.getNode(nodeId)
|
||||
.pipe(map(this.cleanMetadataFromSemicolon));
|
||||
}
|
||||
|
||||
@@ -199,7 +187,7 @@ export class NodesApiService {
|
||||
properties: properties,
|
||||
relativePath: path
|
||||
};
|
||||
return from(this.nodesApi.createNode('-root-', body, {}));
|
||||
return from(this.contentService.createNode('-root-', body, {}));
|
||||
}
|
||||
|
||||
private generateUuid() {
|
||||
|
@@ -65,3 +65,5 @@ export * from './version-compatibility.service';
|
||||
export * from './auth-bearer.interceptor';
|
||||
export * from './oauth2.service';
|
||||
export * from './language.service';
|
||||
export * from './acs-content.service';
|
||||
export * from './content-provider.service';
|
||||
|
@@ -16,29 +16,17 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { RenditionEntry, RenditionPaging, RenditionsApi, ContentApi } from '@alfresco/js-api';
|
||||
import { RenditionEntry, RenditionPaging } from '@alfresco/js-api';
|
||||
import { Observable, from, interval, empty } from 'rxjs';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { concatMap, switchMap, takeWhile, map } from 'rxjs/operators';
|
||||
import { ContentService } from './content.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class RenditionsService {
|
||||
|
||||
_renditionsApi: RenditionsApi;
|
||||
get renditionsApi(): RenditionsApi {
|
||||
this._renditionsApi = this._renditionsApi ?? new RenditionsApi(this.apiService.getInstance());
|
||||
return this._renditionsApi;
|
||||
}
|
||||
|
||||
_contentApi: ContentApi;
|
||||
get contentApi(): ContentApi {
|
||||
this._contentApi = this._contentApi ?? new ContentApi(this.apiService.getInstance());
|
||||
return this._contentApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService) {
|
||||
constructor(private contentService: ContentService) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +35,7 @@ export class RenditionsService {
|
||||
* @returns Information object for the rendition
|
||||
*/
|
||||
getAvailableRenditionForNode(nodeId: string): Observable<RenditionEntry> {
|
||||
return from(this.renditionsApi.listRenditions(nodeId)).pipe(
|
||||
return from(this.contentService.listRenditions(nodeId)).pipe(
|
||||
map((availableRenditions: RenditionPaging) => {
|
||||
const renditionsAvailable: RenditionEntry[] = availableRenditions.list.entries.filter(
|
||||
(rendition) => (rendition.entry.id === 'pdf' || rendition.entry.id === 'imgpreview'));
|
||||
@@ -65,7 +53,7 @@ export class RenditionsService {
|
||||
return this.getAvailableRenditionForNode(nodeId).pipe(
|
||||
map((rendition: RenditionEntry) => {
|
||||
if (rendition.entry.status !== 'CREATED') {
|
||||
return from(this.renditionsApi.createRendition(nodeId, { id: rendition.entry.id }));
|
||||
return from(this.contentService.createRendition(nodeId, { id: rendition.entry.id }));
|
||||
} else {
|
||||
return empty();
|
||||
}
|
||||
@@ -126,7 +114,7 @@ export class RenditionsService {
|
||||
* @returns URL string
|
||||
*/
|
||||
getRenditionUrl(nodeId: string, encoding: string): string {
|
||||
return this.contentApi.getRenditionUrl(nodeId, encoding);
|
||||
return this.contentService.getRenditionUrl(nodeId, encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,7 +124,7 @@ export class RenditionsService {
|
||||
* @returns Information object about the rendition
|
||||
*/
|
||||
getRendition(nodeId: string, encoding: string): Observable<RenditionEntry> {
|
||||
return from(this.renditionsApi.getRendition(nodeId, encoding));
|
||||
return from(this.contentService.getRendition(nodeId, encoding));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,7 +133,7 @@ export class RenditionsService {
|
||||
* @returns Paged list of rendition details
|
||||
*/
|
||||
getRenditionsListByNodeId(nodeId: string): Observable<RenditionPaging> {
|
||||
return from(this.renditionsApi.listRenditions(nodeId));
|
||||
return from(this.contentService.listRenditions(nodeId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +143,7 @@ export class RenditionsService {
|
||||
* @returns Null response to indicate completion
|
||||
*/
|
||||
createRendition(nodeId: string, encoding: string): Observable<{}> {
|
||||
return from(this.renditionsApi.createRendition(nodeId, { id: encoding }));
|
||||
return from(this.contentService.createRendition(nodeId, { id: encoding }));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -19,8 +19,8 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MatIconRegistry } from '@angular/material/icon';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { ContentApi, NodeEntry } from '@alfresco/js-api';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { ContentService } from './content.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -164,13 +164,7 @@ export class ThumbnailService {
|
||||
'task': './assets/images/task.svg'
|
||||
};
|
||||
|
||||
_contentApi: ContentApi;
|
||||
get contentApi(): ContentApi {
|
||||
this._contentApi = this._contentApi ?? new ContentApi(this.apiService.getInstance());
|
||||
return this._contentApi;
|
||||
}
|
||||
|
||||
constructor(protected apiService: AlfrescoApiService, matIconRegistry: MatIconRegistry, sanitizer: DomSanitizer) {
|
||||
constructor(private contentService: ContentService, matIconRegistry: MatIconRegistry, sanitizer: DomSanitizer) {
|
||||
Object.keys(this.mimeTypeIcons).forEach((key) => {
|
||||
const url = sanitizer.bypassSecurityTrustResourceUrl(this.mimeTypeIcons[key]);
|
||||
|
||||
@@ -198,7 +192,7 @@ export class ThumbnailService {
|
||||
nodeId = node.entry.id;
|
||||
}
|
||||
|
||||
resultUrl = this.contentApi.getDocumentThumbnailUrl(nodeId, attachment, ticket);
|
||||
resultUrl = this.contentService.getDocumentThumbnailUrl(nodeId, attachment, ticket);
|
||||
}
|
||||
|
||||
return resultUrl || this.DEFAULT_ICON;
|
||||
|
@@ -26,10 +26,9 @@ import {
|
||||
FileUploadEvent
|
||||
} from '../events/file.event';
|
||||
import { FileModel, FileUploadProgress, FileUploadStatus } from '../models/file.model';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { DiscoveryApiService } from './discovery-api.service';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { NodesApi, UploadApi, VersionsApi } from '@alfresco/js-api';
|
||||
import { ContentService } from './content.service';
|
||||
|
||||
const MIN_CANCELLABLE_FILE_SIZE = 1000000;
|
||||
const MAX_CANCELLABLE_FILE_PERCENTAGE = 50;
|
||||
@@ -63,26 +62,8 @@ export class UploadService {
|
||||
fileUploadDeleted: Subject<FileUploadDeleteEvent> = new Subject<FileUploadDeleteEvent>();
|
||||
fileDeleted: Subject<string> = new Subject<string>();
|
||||
|
||||
_uploadApi: UploadApi;
|
||||
get uploadApi(): UploadApi {
|
||||
this._uploadApi = this._uploadApi ?? new UploadApi(this.apiService.getInstance());
|
||||
return this._uploadApi;
|
||||
}
|
||||
|
||||
_nodesApi: NodesApi;
|
||||
get nodesApi(): NodesApi {
|
||||
this._nodesApi = this._nodesApi ?? new NodesApi(this.apiService.getInstance());
|
||||
return this._nodesApi;
|
||||
}
|
||||
|
||||
_versionsApi: VersionsApi;
|
||||
get versionsApi(): VersionsApi {
|
||||
this._versionsApi = this._versionsApi ?? new VersionsApi(this.apiService.getInstance());
|
||||
return this._versionsApi;
|
||||
}
|
||||
|
||||
constructor(
|
||||
protected apiService: AlfrescoApiService,
|
||||
private contentService: ContentService,
|
||||
private appConfigService: AppConfigService,
|
||||
private discoveryApiService: DiscoveryApiService) {
|
||||
|
||||
@@ -260,9 +241,9 @@ export class UploadService {
|
||||
}
|
||||
|
||||
if (file.id) {
|
||||
return this.nodesApi.updateNodeContent(file.id, <any> file.file, opts);
|
||||
return this.contentService.updateNodeContent(file.id, <any> file.file, opts);
|
||||
} else {
|
||||
return this.uploadApi.uploadFile(
|
||||
return this.contentService.uploadFile(
|
||||
file.file,
|
||||
file.options.path,
|
||||
file.options.parentId,
|
||||
@@ -422,12 +403,12 @@ export class UploadService {
|
||||
}
|
||||
|
||||
private deleteAbortedNode(nodeId: string) {
|
||||
this.nodesApi.deleteNode(nodeId, { permanent: true })
|
||||
this.contentService.deleteNode(nodeId, { permanent: true })
|
||||
.then(() => (this.abortedFile = undefined));
|
||||
}
|
||||
|
||||
private deleteAbortedNodeVersion(nodeId: string, versionId: string) {
|
||||
this.versionsApi.deleteVersion(nodeId, versionId)
|
||||
this.contentService.deleteVersion(nodeId, versionId)
|
||||
.then(() => (this.abortedFile = undefined));
|
||||
}
|
||||
|
||||
|
@@ -26,8 +26,7 @@ import {
|
||||
Version,
|
||||
RenditionEntry,
|
||||
NodeEntry,
|
||||
VersionEntry,
|
||||
SharedlinksApi, VersionsApi, NodesApi, ContentApi
|
||||
VersionEntry
|
||||
} from '@alfresco/js-api';
|
||||
import { BaseEvent } from '../../events';
|
||||
import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
@@ -257,38 +256,15 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
private shouldCloseViewer = true;
|
||||
private keyDown$ = fromEvent<KeyboardEvent>(document, 'keydown');
|
||||
|
||||
_sharedLinksApi: SharedlinksApi;
|
||||
get sharedLinksApi(): SharedlinksApi {
|
||||
this._sharedLinksApi = this._sharedLinksApi ?? new SharedlinksApi(this.apiService.getInstance());
|
||||
return this._sharedLinksApi;
|
||||
}
|
||||
|
||||
_versionsApi: VersionsApi;
|
||||
get versionsApi(): VersionsApi {
|
||||
this._versionsApi = this._versionsApi ?? new VersionsApi(this.apiService.getInstance());
|
||||
return this._versionsApi;
|
||||
}
|
||||
|
||||
_nodesApi: NodesApi;
|
||||
get nodesApi(): NodesApi {
|
||||
this._nodesApi = this._nodesApi ?? new NodesApi(this.apiService.getInstance());
|
||||
return this._nodesApi;
|
||||
}
|
||||
|
||||
_contentApi: ContentApi;
|
||||
get contentApi(): ContentApi {
|
||||
this._contentApi = this._contentApi ?? new ContentApi(this.apiService.getInstance());
|
||||
return this._contentApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService,
|
||||
private viewUtilService: ViewUtilService,
|
||||
private logService: LogService,
|
||||
private extensionService: AppExtensionService,
|
||||
private contentService: ContentService,
|
||||
private uploadService: UploadService,
|
||||
private el: ElementRef,
|
||||
public dialog: MatDialog) {
|
||||
constructor(
|
||||
private apiService: AlfrescoApiService,
|
||||
private viewUtilService: ViewUtilService,
|
||||
private logService: LogService,
|
||||
private extensionService: AppExtensionService,
|
||||
private contentService: ContentService,
|
||||
private uploadService: UploadService,
|
||||
private el: ElementRef,
|
||||
public dialog: MatDialog) {
|
||||
viewUtilService.maxRetries = this.maxRetries;
|
||||
}
|
||||
|
||||
@@ -371,7 +347,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
private setupSharedLink() {
|
||||
this.allowGoBack = false;
|
||||
|
||||
this.sharedLinksApi.getSharedLink(this.sharedLinkId).then(
|
||||
this.contentService.getSharedLink(this.sharedLinkId).then(
|
||||
(sharedLinkEntry: SharedLinkEntry) => {
|
||||
this.setUpSharedLinkFile(sharedLinkEntry);
|
||||
this.isLoading = false;
|
||||
@@ -384,11 +360,11 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private setupNode() {
|
||||
this.nodesApi.getNode(this.nodeId, { include: ['allowableOperations'] }).then(
|
||||
this.contentService.getNode(this.nodeId, { include: ['allowableOperations'] }).subscribe(
|
||||
(node: NodeEntry) => {
|
||||
this.nodeEntry = node;
|
||||
if (this.versionId) {
|
||||
this.versionsApi.getVersion(this.nodeId, this.versionId).then(
|
||||
this.contentService.getVersion(this.nodeId, this.versionId).then(
|
||||
(version: VersionEntry) => {
|
||||
this.versionEntry = version;
|
||||
this.setUpNodeFile(node.entry, version.entry).then(() => {
|
||||
@@ -454,8 +430,8 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
const currentFileVersion = this.nodeEntry?.entry?.properties && this.nodeEntry.entry.properties['cm:versionLabel'] ?
|
||||
encodeURI(this.nodeEntry?.entry?.properties['cm:versionLabel']) : encodeURI('1.0');
|
||||
|
||||
this.urlFileContent = versionData ? this.contentApi.getVersionContentUrl(this.nodeId, versionData.id) :
|
||||
this.contentApi.getContentUrl(this.nodeId);
|
||||
this.urlFileContent = versionData ? this.contentService.getVersionContentUrl(this.nodeId, versionData.id) :
|
||||
this.contentService.getContentUrl(this.nodeId);
|
||||
this.urlFileContent = this.cacheBusterNumber ? this.urlFileContent + '&' + currentFileVersion + '&' + this.cacheBusterNumber :
|
||||
this.urlFileContent + '&' + currentFileVersion;
|
||||
|
||||
@@ -490,7 +466,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
this.extension = this.getFileExtension(details.entry.name);
|
||||
this.fileName = details.entry.name;
|
||||
|
||||
this.urlFileContent = this.contentApi.getSharedLinkContentUrl(this.sharedLinkId, false);
|
||||
this.urlFileContent = this.contentService.getSharedLinkContentUrl(this.sharedLinkId, false);
|
||||
|
||||
this.viewerType = this.getViewerTypeByMimeType(this.mimeType);
|
||||
if (this.viewerType === 'unknown') {
|
||||
@@ -507,8 +483,8 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
toggleSidebar() {
|
||||
this.showRightSidebar = !this.showRightSidebar;
|
||||
if (this.showRightSidebar && this.nodeId) {
|
||||
this.nodesApi.getNode(this.nodeId, { include: ['allowableOperations'] })
|
||||
.then((nodeEntry: NodeEntry) => {
|
||||
this.contentService.getNode(this.nodeId, { include: ['allowableOperations'] })
|
||||
.subscribe((nodeEntry: NodeEntry) => {
|
||||
this.sidebarRightTemplateContext.node = nodeEntry.entry;
|
||||
});
|
||||
}
|
||||
@@ -517,8 +493,8 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
toggleLeftSidebar() {
|
||||
this.showLeftSidebar = !this.showLeftSidebar;
|
||||
if (this.showRightSidebar && this.nodeId) {
|
||||
this.nodesApi.getNode(this.nodeId, { include: ['allowableOperations'] })
|
||||
.then((nodeEntry: NodeEntry) => {
|
||||
this.contentService.getNode(this.nodeId, { include: ['allowableOperations'] })
|
||||
.subscribe((nodeEntry: NodeEntry) => {
|
||||
this.sidebarLeftTemplateContext.node = nodeEntry.entry;
|
||||
});
|
||||
}
|
||||
@@ -702,18 +678,18 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
|
||||
private async displaySharedLinkRendition(sharedId: string) {
|
||||
try {
|
||||
const rendition: RenditionEntry = await this.sharedLinksApi.getSharedLinkRendition(sharedId, 'pdf');
|
||||
const rendition: RenditionEntry = await this.contentService.getSharedLinkRendition(sharedId, 'pdf');
|
||||
if (rendition.entry.status.toString() === 'CREATED') {
|
||||
this.viewerType = 'pdf';
|
||||
this.urlFileContent = this.contentApi.getSharedLinkRenditionUrl(sharedId, 'pdf');
|
||||
this.urlFileContent = this.contentService.getSharedLinkRenditionUrl(sharedId, 'pdf');
|
||||
}
|
||||
} catch (error) {
|
||||
this.logService.error(error);
|
||||
try {
|
||||
const rendition: RenditionEntry = await this.sharedLinksApi.getSharedLinkRendition(sharedId, 'imgpreview');
|
||||
const rendition: RenditionEntry = await this.contentService.getSharedLinkRendition(sharedId, 'imgpreview');
|
||||
if (rendition.entry.status.toString() === 'CREATED') {
|
||||
this.viewerType = 'image';
|
||||
this.urlFileContent = this.contentApi.getSharedLinkRenditionUrl(sharedId, 'imgpreview');
|
||||
this.urlFileContent = this.contentService.getSharedLinkRenditionUrl(sharedId, 'imgpreview');
|
||||
}
|
||||
} catch (error) {
|
||||
this.logService.error(error);
|
||||
|
@@ -16,12 +16,12 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ContentApi, RenditionEntry, RenditionPaging, RenditionsApi, VersionsApi } from '@alfresco/js-api';
|
||||
import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
import { RenditionEntry, RenditionPaging } from '@alfresco/js-api';
|
||||
import { LogService } from '../../services/log.service';
|
||||
import { Subject } from 'rxjs';
|
||||
import { Track } from '../models/viewer.model';
|
||||
import { TranslationService } from '../../services/translation.service';
|
||||
import { ContentService } from '../../services/content.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -74,25 +74,7 @@ export class ViewUtilService {
|
||||
viewerTypeChange: Subject<string> = new Subject<string>();
|
||||
urlFileContentChange: Subject<string> = new Subject<string>();
|
||||
|
||||
_renditionsApi: RenditionsApi;
|
||||
get renditionsApi(): RenditionsApi {
|
||||
this._renditionsApi = this._renditionsApi ?? new RenditionsApi(this.apiService.getInstance());
|
||||
return this._renditionsApi;
|
||||
}
|
||||
|
||||
_contentApi: ContentApi;
|
||||
get contentApi(): ContentApi {
|
||||
this._contentApi = this._contentApi ?? new ContentApi(this.apiService.getInstance());
|
||||
return this._contentApi;
|
||||
}
|
||||
|
||||
_versionsApi: VersionsApi;
|
||||
get versionsApi(): VersionsApi {
|
||||
this._versionsApi = this._versionsApi ?? new VersionsApi(this.apiService.getInstance());
|
||||
return this._versionsApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService,
|
||||
constructor(private contentService: ContentService,
|
||||
private logService: LogService,
|
||||
private translateService: TranslationService) {
|
||||
}
|
||||
@@ -147,12 +129,12 @@ export class ViewUtilService {
|
||||
|
||||
getRenditionUrl(nodeId: string, type: string, renditionExists: boolean): string {
|
||||
return (renditionExists && type !== ViewUtilService.ContentGroup.IMAGE) ?
|
||||
this.contentApi.getRenditionUrl(nodeId, ViewUtilService.ContentGroup.PDF) :
|
||||
this.contentApi.getContentUrl(nodeId, false);
|
||||
this.contentService.getRenditionUrl(nodeId, ViewUtilService.ContentGroup.PDF) :
|
||||
this.contentService.getContentUrl(nodeId, false);
|
||||
}
|
||||
|
||||
private async waitRendition(nodeId: string, renditionId: string, retries: number): Promise<RenditionEntry> {
|
||||
const rendition = await this.renditionsApi.getRendition(nodeId, renditionId);
|
||||
const rendition = await this.contentService.getRendition(nodeId, renditionId);
|
||||
|
||||
if (this.maxRetries < retries) {
|
||||
const status = rendition.entry.status.toString();
|
||||
@@ -188,7 +170,7 @@ export class ViewUtilService {
|
||||
}
|
||||
|
||||
async getRendition(nodeId: string, renditionId: string): Promise<RenditionEntry> {
|
||||
const renditionPaging: RenditionPaging = await this.renditionsApi.listRenditions(nodeId);
|
||||
const renditionPaging: RenditionPaging = await this.contentService.listRenditions(nodeId);
|
||||
let rendition: RenditionEntry = renditionPaging.list.entries.find((renditionEntry: RenditionEntry) => renditionEntry.entry.id.toLowerCase() === renditionId);
|
||||
|
||||
if (rendition) {
|
||||
@@ -196,7 +178,7 @@ export class ViewUtilService {
|
||||
|
||||
if (status === 'NOT_CREATED') {
|
||||
try {
|
||||
await this.renditionsApi.createRendition(nodeId, { id: renditionId });
|
||||
await this.contentService.createRendition(nodeId, { id: renditionId });
|
||||
rendition = await this.waitRendition(nodeId, renditionId, 0);
|
||||
} catch (err) {
|
||||
this.logService.error(err);
|
||||
@@ -219,8 +201,8 @@ export class ViewUtilService {
|
||||
this.viewerTypeChange.next('image');
|
||||
}
|
||||
|
||||
const urlFileContent = versionId ? this.contentApi.getVersionRenditionUrl(nodeId, versionId, renditionId) :
|
||||
this.contentApi.getRenditionUrl(nodeId, renditionId);
|
||||
const urlFileContent = versionId ? this.contentService.getVersionRenditionUrl(nodeId, versionId, renditionId) :
|
||||
this.contentService.getRenditionUrl(nodeId, renditionId);
|
||||
this.urlFileContentChange.next(urlFileContent);
|
||||
}
|
||||
} catch (err) {
|
||||
@@ -231,8 +213,8 @@ export class ViewUtilService {
|
||||
private async resolveNodeRendition(nodeId: string, renditionId: string, versionId?: string): Promise<RenditionEntry> {
|
||||
renditionId = renditionId.toLowerCase();
|
||||
|
||||
const supportedRendition: RenditionPaging = versionId ? await this.versionsApi.listVersionRenditions(nodeId, versionId) :
|
||||
await this.renditionsApi.listRenditions(nodeId);
|
||||
const supportedRendition: RenditionPaging = versionId ? await this.contentService.listVersionRenditions(nodeId, versionId) :
|
||||
await this.contentService.listRenditions(nodeId);
|
||||
|
||||
let rendition: RenditionEntry = supportedRendition.list.entries.find((renditionEntry: RenditionEntry) => renditionEntry.entry.id.toLowerCase() === renditionId);
|
||||
if (!rendition) {
|
||||
@@ -246,11 +228,11 @@ export class ViewUtilService {
|
||||
if (status === 'NOT_CREATED') {
|
||||
try {
|
||||
if (versionId) {
|
||||
await this.versionsApi.createVersionRendition(nodeId, versionId, { id: renditionId }).then(() => {
|
||||
await this.contentService.createVersionRendition(nodeId, versionId, { id: renditionId }).then(() => {
|
||||
this.viewerTypeChange.next('in_creation');
|
||||
});
|
||||
} else {
|
||||
await this.renditionsApi.createRendition(nodeId, { id: renditionId }).then(() => {
|
||||
await this.contentService.createRendition(nodeId, { id: renditionId }).then(() => {
|
||||
this.viewerTypeChange.next('in_creation');
|
||||
});
|
||||
}
|
||||
@@ -277,7 +259,7 @@ export class ViewUtilService {
|
||||
currentRetry++;
|
||||
if (this.maxRetries >= currentRetry) {
|
||||
if (versionId) {
|
||||
this.versionsApi.getVersionRendition(nodeId, versionId, renditionId).then((rendition: RenditionEntry) => {
|
||||
this.contentService.getVersionRendition(nodeId, versionId, renditionId).then((rendition: RenditionEntry) => {
|
||||
const status: string = rendition.entry.status.toString();
|
||||
|
||||
if (status === 'CREATED') {
|
||||
@@ -289,7 +271,7 @@ export class ViewUtilService {
|
||||
return reject();
|
||||
});
|
||||
} else {
|
||||
this.renditionsApi.getRendition(nodeId, renditionId).then((rendition: RenditionEntry) => {
|
||||
this.contentService.getRendition(nodeId, renditionId).then((rendition: RenditionEntry) => {
|
||||
const status: string = rendition.entry.status.toString();
|
||||
|
||||
if (status === 'CREATED') {
|
||||
@@ -316,8 +298,8 @@ export class ViewUtilService {
|
||||
this.viewerTypeChange.next('image');
|
||||
}
|
||||
|
||||
const urlFileContent = versionId ? this.contentApi.getVersionRenditionUrl(nodeId, versionId, renditionId) :
|
||||
this.contentApi.getRenditionUrl(nodeId, renditionId);
|
||||
const urlFileContent = versionId ? this.contentService.getVersionRenditionUrl(nodeId, versionId, renditionId) :
|
||||
this.contentService.getRenditionUrl(nodeId, renditionId);
|
||||
this.urlFileContentChange.next(urlFileContent);
|
||||
}
|
||||
|
||||
@@ -328,7 +310,7 @@ export class ViewUtilService {
|
||||
if (value) {
|
||||
tracks.push({
|
||||
kind: 'subtitles',
|
||||
src: this.contentApi.getRenditionUrl(nodeId, ViewUtilService.SUBTITLES_RENDITION_NAME),
|
||||
src: this.contentService.getRenditionUrl(nodeId, ViewUtilService.SUBTITLES_RENDITION_NAME),
|
||||
label: this.translateService.instant('ADF_VIEWER.SUBTITLES')
|
||||
});
|
||||
}
|
||||
@@ -342,7 +324,7 @@ export class ViewUtilService {
|
||||
}
|
||||
|
||||
private async isRenditionAvailable(nodeId: string, renditionId: string): Promise<boolean> {
|
||||
const renditionPaging: RenditionPaging = await this.renditionsApi.listRenditions(nodeId);
|
||||
const renditionPaging: RenditionPaging = await this.contentService.listRenditions(nodeId);
|
||||
const rendition: RenditionEntry = renditionPaging.list.entries.find((renditionEntry: RenditionEntry) => renditionEntry.entry.id.toLowerCase() === renditionId);
|
||||
|
||||
return rendition?.entry?.status?.toString() === 'CREATED' || false;
|
||||
|
Reference in New Issue
Block a user