mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-6227] cleanup error handling and fix typing issues (#9035)
* cleanup audit service, remove useless ajax tests * cleanup sites service and remove useless ajax tests * cleanup services * cleanup services * fix typings * code cleanup
This commit is contained in:
@@ -1,202 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* 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 { AuditService } from './audit.service';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('AuditService', () => {
|
||||
let service: AuditService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
ContentTestingModule
|
||||
]
|
||||
});
|
||||
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
|
||||
appConfig.config = {
|
||||
ecmHost: 'http://localhost:9876/ecm',
|
||||
files: {
|
||||
excluded: ['.DS_Store', 'desktop.ini', '.git', '*.git']
|
||||
}
|
||||
};
|
||||
service = TestBed.inject(AuditService);
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('Should get Audit Applications', (done) => {
|
||||
service.getAuditApps().subscribe((data) => {
|
||||
expect(data.list.pagination.count).toBe(3);
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
list: {
|
||||
pagination: {
|
||||
count: 3,
|
||||
hasMoreItems: false,
|
||||
totalItems: 3,
|
||||
skipCount: 0,
|
||||
maxItems: 100
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
isEnabled: true,
|
||||
name: 'Alfresco Tagging Service',
|
||||
id: 'tagging'
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
isEnabled: true,
|
||||
name: 'ShareSiteAccess',
|
||||
id: 'share-site-access'
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
isEnabled: true,
|
||||
name: 'alfresco-access',
|
||||
id: 'alfresco-access'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('Should get an Audit Application', (done) => {
|
||||
service.getAuditApp('alfresco-access').subscribe((data) => {
|
||||
expect(data.entry.id).toBe('alfresco-access');
|
||||
expect(data.entry.name).toBe('alfresco-access');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
entry: {
|
||||
id: 'alfresco-access',
|
||||
name: 'alfresco-access',
|
||||
isEnabled: true
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('Should get Audit Entries', (done) => {
|
||||
service.getAuditEntries('alfresco-access').subscribe((data) => {
|
||||
expect(data.list.pagination.count).toBe(3);
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
list: {
|
||||
pagination: {
|
||||
count: 3,
|
||||
hasMoreItems: false,
|
||||
totalItems: 3,
|
||||
skipCount: 0,
|
||||
maxItems: 100
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
id: '1',
|
||||
auditApplicationId: 'alfresco-access',
|
||||
createdByUser: {
|
||||
displayName: 'admin',
|
||||
id: 'admin'
|
||||
},
|
||||
createdAt: '2020-08-11T13:11:59.141Z',
|
||||
values: {}
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
id: '2',
|
||||
auditApplicationId: 'alfresco-access',
|
||||
createdByUser: {
|
||||
displayName: 'admin',
|
||||
id: 'admin'
|
||||
},
|
||||
createdAt: '2020-08-11T13:11:59.141Z',
|
||||
values: {}
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
id: '3',
|
||||
auditApplicationId: 'alfresco-access',
|
||||
createdByUser: {
|
||||
displayName: 'admin',
|
||||
id: 'admin'
|
||||
},
|
||||
createdAt: '2020-08-11T13:11:59.141Z',
|
||||
values: {}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('Should get an Audit Entry', (done) => {
|
||||
service.getAuditEntry('alfresco-access', '1').subscribe((data) => {
|
||||
expect(data.entry.id).toBe('1');
|
||||
expect(data.entry.auditApplicationId).toBe('alfresco-access');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
entry: {
|
||||
id: '1',
|
||||
auditApplicationId: 'alfresco-access',
|
||||
createdByUser: {
|
||||
displayName: 'admin',
|
||||
id: 'admin'
|
||||
},
|
||||
createdAt: '2020-08-11T13:11:59.148Z',
|
||||
values: {}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
@@ -16,10 +16,9 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { AlfrescoApiService, LogService } from '@alfresco/adf-core';
|
||||
import { AuditApi, AuditAppPaging, AuditAppEntry, AuditApp, AuditBodyUpdate, AuditEntryPaging, AuditEntryEntry } from '@alfresco/js-api';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { AuditApi, AuditAppPaging, AuditApp, AuditBodyUpdate, AuditEntryPaging, AuditEntryEntry } from '@alfresco/js-api';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -31,7 +30,7 @@ export class AuditService {
|
||||
return this._auditApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService, private logService: LogService) {}
|
||||
constructor(private apiService: AlfrescoApiService) {}
|
||||
|
||||
/**
|
||||
* Gets a list of audit applications.
|
||||
@@ -44,7 +43,7 @@ export class AuditService {
|
||||
skipCount: 0
|
||||
};
|
||||
const queryOptions = Object.assign({}, defaultOptions, opts);
|
||||
return from(this.auditApi.listAuditApps(queryOptions)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
return from(this.auditApi.listAuditApps(queryOptions));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,12 +53,12 @@ export class AuditService {
|
||||
* @param opts Options.
|
||||
* @returns status of an audit application.
|
||||
*/
|
||||
getAuditApp(auditApplicationId: string, opts?: any): Observable<AuditAppEntry> {
|
||||
getAuditApp(auditApplicationId: string, opts?: any): Observable<AuditApp> {
|
||||
const defaultOptions = {
|
||||
auditApplicationId
|
||||
};
|
||||
const queryOptions = Object.assign({}, defaultOptions, opts);
|
||||
return from(this.auditApi.getAuditApp(queryOptions)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
return from(this.auditApi.getAuditApp(queryOptions));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,9 +72,7 @@ export class AuditService {
|
||||
updateAuditApp(auditApplicationId: string, auditAppBodyUpdate: boolean, opts?: any): Observable<AuditApp | any> {
|
||||
const defaultOptions = {};
|
||||
const queryOptions = Object.assign({}, defaultOptions, opts);
|
||||
return from(this.auditApi.updateAuditApp(auditApplicationId, new AuditBodyUpdate({ isEnabled: auditAppBodyUpdate }), queryOptions)).pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
return from(this.auditApi.updateAuditApp(auditApplicationId, new AuditBodyUpdate({ isEnabled: auditAppBodyUpdate }), queryOptions));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,9 +88,7 @@ export class AuditService {
|
||||
maxItems: 100
|
||||
};
|
||||
const queryOptions = Object.assign({}, defaultOptions, opts);
|
||||
return from(this.auditApi.listAuditEntriesForAuditApp(auditApplicationId, queryOptions)).pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
return from(this.auditApi.listAuditEntriesForAuditApp(auditApplicationId, queryOptions));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,9 +102,7 @@ export class AuditService {
|
||||
getAuditEntry(auditApplicationId: string, auditEntryId: string, opts?: any): Observable<AuditEntryEntry> {
|
||||
const defaultOptions = {};
|
||||
const queryOptions = Object.assign({}, defaultOptions, opts);
|
||||
return from(this.auditApi.getAuditEntry(auditApplicationId, auditEntryId, queryOptions)).pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
return from(this.auditApi.getAuditEntry(auditApplicationId, auditEntryId, queryOptions));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +117,7 @@ export class AuditService {
|
||||
nodeId
|
||||
};
|
||||
const queryOptions = Object.assign({}, defaultOptions, opts);
|
||||
return from(this.auditApi.listAuditEntriesForNode(queryOptions)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
return from(this.auditApi.listAuditEntriesForNode(queryOptions));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +128,7 @@ export class AuditService {
|
||||
* @returns void operation
|
||||
*/
|
||||
deleteAuditEntries(auditApplicationId: string, where: string): Observable<any> {
|
||||
return from(this.auditApi.deleteAuditEntriesForAuditApp(auditApplicationId, where)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
return from(this.auditApi.deleteAuditEntriesForAuditApp(auditApplicationId, where));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,11 +139,6 @@ export class AuditService {
|
||||
* @returns void operation
|
||||
*/
|
||||
deleteAuditEntry(auditApplicationId: string, auditEntryId: string): Observable<any> {
|
||||
return from(this.auditApi.deleteAuditEntry(auditApplicationId, auditEntryId)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
}
|
||||
|
||||
private handleError(error: any): any {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
return from(this.auditApi.deleteAuditEntry(auditApplicationId, auditEntryId));
|
||||
}
|
||||
}
|
||||
|
@@ -1,156 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* 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 { TestBed } from '@angular/core/testing';
|
||||
import { AppConfigService, CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { SitesService } from './sites.service';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('Sites service', () => {
|
||||
let service: SitesService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule
|
||||
]
|
||||
});
|
||||
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
|
||||
appConfig.config = {
|
||||
ecmHost: 'http://localhost:9876/ecm',
|
||||
files: {
|
||||
excluded: ['.DS_Store', 'desktop.ini', '.git', '*.git']
|
||||
}
|
||||
};
|
||||
|
||||
service = TestBed.inject(SitesService);
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('Should get a list of users sites', (done) => {
|
||||
service.getSites().subscribe((data) => {
|
||||
expect(data.list.entries[0].entry.title).toBe('FAKE');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
list: {
|
||||
pagination: {
|
||||
count: 1,
|
||||
hasMoreItems: false,
|
||||
totalItems: 1,
|
||||
skipCount: 0,
|
||||
maxItems: 100
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
role: 'SiteManager',
|
||||
visibility: 'PUBLIC',
|
||||
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||
description: 'This is a Sample Alfresco Team site.',
|
||||
id: 'swsdp',
|
||||
title: 'FAKE'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('Should get single sites via siteId', (done) => {
|
||||
service.getSite('fake-site-id').subscribe((data) => {
|
||||
expect(data.entry.title).toBe('FAKE-SINGLE-TITLE');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
entry: {
|
||||
role: 'SiteManager',
|
||||
visibility: 'PUBLIC',
|
||||
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||
description: 'This is a Sample Alfresco Team site.',
|
||||
id: 'swsdp',
|
||||
preset: 'site-dashboard',
|
||||
title: 'FAKE-SINGLE-TITLE'
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should get a list of membership requests', (done) => {
|
||||
service.getSiteMembershipRequests().subscribe((data) => {
|
||||
expect(data.list.entries[0].entry.site.id).toBe('site-id');
|
||||
expect(data.list.entries[0].entry.person.id).toBe('user-id');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
list: {
|
||||
pagination: {
|
||||
count: 1,
|
||||
hasMoreItems: false,
|
||||
totalItems: 1,
|
||||
skipCount: 0,
|
||||
maxItems: 100
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
id: 'site-id',
|
||||
createdAt: '2020-05-13T07:46:36.180Z',
|
||||
site: {
|
||||
id: 'site-id',
|
||||
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||
title: 'Sample Site',
|
||||
description: '',
|
||||
visibility: 'MODERATED',
|
||||
preset: 'preset',
|
||||
role: 'Manager'
|
||||
},
|
||||
person: {
|
||||
id: 'user-id',
|
||||
firstName: 'string',
|
||||
lastName: 'string',
|
||||
displayName: 'string'
|
||||
},
|
||||
message: 'message'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { from, Observable, throwError } from 'rxjs';
|
||||
import { AlfrescoApiService, LogService } from '@alfresco/adf-core';
|
||||
import { from, Observable } from 'rxjs';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import {
|
||||
Node,
|
||||
SiteBodyCreate,
|
||||
@@ -32,7 +32,6 @@ import {
|
||||
SitePaging,
|
||||
SitesApi
|
||||
} from '@alfresco/js-api';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -44,7 +43,7 @@ export class SitesService {
|
||||
return this._sitesApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService, private logService: LogService) {}
|
||||
constructor(private apiService: AlfrescoApiService) {}
|
||||
|
||||
/**
|
||||
* Create a site
|
||||
@@ -53,7 +52,7 @@ export class SitesService {
|
||||
* @returns site SiteEntry
|
||||
*/
|
||||
createSite(siteBody: SiteBodyCreate): Observable<SiteEntry> {
|
||||
return from(this.sitesApi.createSite(siteBody)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
return from(this.sitesApi.createSite(siteBody));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,7 +67,7 @@ export class SitesService {
|
||||
include: ['properties']
|
||||
};
|
||||
const queryOptions = Object.assign({}, defaultOptions, opts);
|
||||
return from(this.sitesApi.listSites(queryOptions)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
return from(this.sitesApi.listSites(queryOptions));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,7 +78,7 @@ export class SitesService {
|
||||
* @returns Information about the site
|
||||
*/
|
||||
getSite(siteId: string, opts?: any): Observable<SiteEntry | any> {
|
||||
return from(this.sitesApi.getSite(siteId, opts)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
return from(this.sitesApi.getSite(siteId, opts));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +91,7 @@ export class SitesService {
|
||||
deleteSite(siteId: string, permanentFlag: boolean = true): Observable<any> {
|
||||
const options: any = {};
|
||||
options.permanent = permanentFlag;
|
||||
return from(this.sitesApi.deleteSite(siteId, options)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
return from(this.sitesApi.deleteSite(siteId, options));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +148,7 @@ export class SitesService {
|
||||
* @returns Site membership requests
|
||||
*/
|
||||
getSiteMembershipRequests(opts?: any): Observable<SiteMembershipRequestWithPersonPaging> {
|
||||
return from(this.sitesApi.getSiteMembershipRequests(opts)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
return from(this.sitesApi.getSiteMembershipRequests(opts));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +160,7 @@ export class SitesService {
|
||||
* @returns Observable<SiteMemberEntry>
|
||||
*/
|
||||
createSiteMembership(siteId: string, siteMembershipBodyCreate: SiteMembershipBodyCreate, opts?: any): Observable<SiteMemberEntry> {
|
||||
return from(this.sitesApi.createSiteMembership(siteId, siteMembershipBodyCreate, opts)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
return from(this.sitesApi.createSiteMembership(siteId, siteMembershipBodyCreate, opts));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,9 +178,7 @@ export class SitesService {
|
||||
siteMembershipBodyUpdate: SiteMembershipBodyUpdate,
|
||||
opts?: any
|
||||
): Observable<SiteMemberEntry> {
|
||||
return from(this.sitesApi.updateSiteMembership(siteId, personId, siteMembershipBodyUpdate, opts)).pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
return from(this.sitesApi.updateSiteMembership(siteId, personId, siteMembershipBodyUpdate, opts));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,7 +189,7 @@ export class SitesService {
|
||||
* @returns Null response notifying when the operation is complete
|
||||
*/
|
||||
deleteSiteMembership(siteId: string, personId: string): Observable<void> {
|
||||
return from(this.sitesApi.deleteSiteMembership(siteId, personId)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
return from(this.sitesApi.deleteSiteMembership(siteId, personId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,7 +201,7 @@ export class SitesService {
|
||||
* @returns Null response notifying when the operation is complete
|
||||
*/
|
||||
approveSiteMembershipRequest(siteId: string, inviteeId: string, opts?: any): Observable<SiteMembershipRequestWithPersonPaging> {
|
||||
return from(this.sitesApi.approveSiteMembershipRequest(siteId, inviteeId, opts)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
return from(this.sitesApi.approveSiteMembershipRequest(siteId, inviteeId, opts));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,7 +213,7 @@ export class SitesService {
|
||||
* @returns Null response notifying when the operation is complete
|
||||
*/
|
||||
rejectSiteMembershipRequest(siteId: string, inviteeId: string, opts?: any): Observable<SiteMembershipRequestWithPersonPaging> {
|
||||
return from(this.sitesApi.rejectSiteMembershipRequest(siteId, inviteeId, opts)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
return from(this.sitesApi.rejectSiteMembershipRequest(siteId, inviteeId, opts));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,7 +224,7 @@ export class SitesService {
|
||||
* @returns Observable<SiteGroupPaging>
|
||||
*/
|
||||
listSiteGroups(siteId: string, opts?: any): Observable<SiteGroupPaging> {
|
||||
return from(this.sitesApi.listSiteGroups(siteId, opts)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
return from(this.sitesApi.listSiteGroups(siteId, opts));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,7 +235,7 @@ export class SitesService {
|
||||
* @returns Observable<SiteGroupEntry>
|
||||
*/
|
||||
createSiteGroupMembership(siteId: string, siteMembershipBodyCreate: SiteMembershipBodyCreate): Observable<SiteGroupEntry> {
|
||||
return from(this.sitesApi.createSiteGroupMembership(siteId, siteMembershipBodyCreate)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
return from(this.sitesApi.createSiteGroupMembership(siteId, siteMembershipBodyCreate));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,7 +246,7 @@ export class SitesService {
|
||||
* @returns Observable<SiteGroupEntry>
|
||||
*/
|
||||
getSiteGroupMembership(siteId: string, groupId: string): Observable<SiteGroupEntry> {
|
||||
return from(this.sitesApi.getSiteGroupMembership(siteId, groupId)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
return from(this.sitesApi.getSiteGroupMembership(siteId, groupId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,9 +258,7 @@ export class SitesService {
|
||||
* @returns Observable<SiteGroupEntry>
|
||||
*/
|
||||
updateSiteGroupMembership(siteId: string, groupId: string, siteMembershipBodyUpdate: SiteMembershipBodyUpdate): Observable<SiteGroupEntry> {
|
||||
return from(this.sitesApi.updateSiteGroupMembership(siteId, groupId, siteMembershipBodyUpdate)).pipe(
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
return from(this.sitesApi.updateSiteGroupMembership(siteId, groupId, siteMembershipBodyUpdate));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,11 +269,6 @@ export class SitesService {
|
||||
* @returns Observable<void>
|
||||
*/
|
||||
deleteSiteGroupMembership(siteId: string, groupId: string): Observable<void> {
|
||||
return from(this.sitesApi.deleteSiteGroupMembership(siteId, groupId)).pipe(catchError((err: any) => this.handleError(err)));
|
||||
}
|
||||
|
||||
private handleError(error: any): Observable<never> {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
return from(this.sitesApi.deleteSiteGroupMembership(siteId, groupId));
|
||||
}
|
||||
}
|
||||
|
@@ -17,9 +17,8 @@
|
||||
|
||||
import { DownloadEntry, DownloadBodyCreate, DownloadsApi } from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { AlfrescoApiService, LogService } from '@alfresco/adf-core';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -32,8 +31,7 @@ export class DownloadZipService {
|
||||
return this._downloadsApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService,
|
||||
private logService: LogService) {
|
||||
constructor(private apiService: AlfrescoApiService) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,9 +41,7 @@ export class DownloadZipService {
|
||||
* @returns Status object for the download
|
||||
*/
|
||||
createDownload(payload: DownloadBodyCreate): Observable<DownloadEntry> {
|
||||
return from(this.downloadsApi.createDownload(payload)).pipe(
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return from(this.downloadsApi.createDownload(payload));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,9 +62,4 @@ export class DownloadZipService {
|
||||
cancelDownload(downloadId: string) {
|
||||
this.downloadsApi.cancelDownload(downloadId);
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
||||
|
@@ -15,9 +15,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AlfrescoApiService, LogService, PaginationModel } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, PaginationModel } from '@alfresco/adf-core';
|
||||
import {
|
||||
NodePaging,
|
||||
DeletedNodesPaging,
|
||||
SearchRequest,
|
||||
SharedLinkPaging,
|
||||
@@ -30,11 +29,13 @@ import {
|
||||
FavoritesApi,
|
||||
SharedlinksApi,
|
||||
TrashcanApi,
|
||||
NodesApi
|
||||
NodesApi,
|
||||
SitePaging,
|
||||
ResultSetPaging
|
||||
} from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, from, of, throwError } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { Observable, from, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
const CREATE_PERMISSION: string = 'create';
|
||||
|
||||
@@ -83,7 +84,7 @@ export class CustomResourcesService {
|
||||
return this._nodesApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService, private logService: LogService) {
|
||||
constructor(private apiService: AlfrescoApiService) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +95,7 @@ export class CustomResourcesService {
|
||||
* @param filters Specifies additional filters to apply (joined with **AND**)
|
||||
* @returns List of nodes for the recently used files
|
||||
*/
|
||||
getRecentFiles(personId: string, pagination: PaginationModel, filters?: string[]): Observable<NodePaging> {
|
||||
getRecentFiles(personId: string, pagination: PaginationModel, filters?: string[]): Observable<ResultSetPaging> {
|
||||
const defaultFilter = [
|
||||
'TYPE:"content"',
|
||||
'-PNAME:"0/wiki"',
|
||||
@@ -165,7 +166,7 @@ export class CustomResourcesService {
|
||||
observer.error(err);
|
||||
observer.complete();
|
||||
});
|
||||
}).pipe(catchError((err) => this.handleError(err)));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,7 +177,7 @@ export class CustomResourcesService {
|
||||
* @param where A string to restrict the returned objects by using a predicate
|
||||
* @returns List of favorite files
|
||||
*/
|
||||
loadFavorites(pagination: PaginationModel, includeFields: string[] = [], where?: string): Observable<NodePaging> {
|
||||
loadFavorites(pagination: PaginationModel, includeFields: string[] = [], where?: string): Observable<FavoritePaging> {
|
||||
const includeFieldsRequest = this.getIncludesFields(includeFields);
|
||||
const defaultPredicate = '(EXISTS(target/file) OR EXISTS(target/folder))';
|
||||
|
||||
@@ -189,7 +190,7 @@ export class CustomResourcesService {
|
||||
|
||||
return new Observable((observer) => {
|
||||
this.favoritesApi.listFavorites('-me-', options)
|
||||
.then((result: FavoritePaging) => {
|
||||
.then((result) => {
|
||||
const page: FavoritePaging = {
|
||||
list: {
|
||||
entries: result.list.entries
|
||||
@@ -218,7 +219,7 @@ export class CustomResourcesService {
|
||||
observer.error(err);
|
||||
observer.complete();
|
||||
});
|
||||
}).pipe(catchError((err) => this.handleError(err)));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,7 +261,7 @@ export class CustomResourcesService {
|
||||
observer.error(err);
|
||||
observer.complete();
|
||||
});
|
||||
}).pipe(catchError((err) => this.handleError(err)));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,7 +271,7 @@ export class CustomResourcesService {
|
||||
* @param where A string to restrict the returned objects by using a predicate
|
||||
* @returns List of sites
|
||||
*/
|
||||
loadSites(pagination: PaginationModel, where?: string): Observable<NodePaging> {
|
||||
loadSites(pagination: PaginationModel, where?: string): Observable<SitePaging> {
|
||||
const options = {
|
||||
include: ['properties', 'aspectNames'],
|
||||
maxItems: pagination.maxItems,
|
||||
@@ -296,7 +297,7 @@ export class CustomResourcesService {
|
||||
observer.error(err);
|
||||
observer.complete();
|
||||
});
|
||||
}).pipe(catchError((err) => this.handleError(err)));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -315,9 +316,7 @@ export class CustomResourcesService {
|
||||
skipCount: pagination.skipCount
|
||||
};
|
||||
|
||||
return from(this.trashcanApi.listDeletedNodes(options))
|
||||
.pipe(catchError((err) => this.handleError(err)));
|
||||
|
||||
return from(this.trashcanApi.listDeletedNodes(options));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -338,8 +337,7 @@ export class CustomResourcesService {
|
||||
where
|
||||
};
|
||||
|
||||
return from(this.sharedLinksApi.listSharedLinks(options))
|
||||
.pipe(catchError((err) => this.handleError(err)));
|
||||
return from(this.sharedLinksApi.listSharedLinks(options));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -458,9 +456,4 @@ export class CustomResourcesService {
|
||||
return ['path', 'properties', 'allowableOperations', 'permissions', 'aspectNames', ...includeFields]
|
||||
.filter((element, index, array) => index === array.indexOf(element));
|
||||
}
|
||||
|
||||
private handleError(error: Response) {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
||||
|
@@ -15,14 +15,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AlfrescoApiService, LogService, PaginationModel } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, PaginationModel } from '@alfresco/adf-core';
|
||||
import { NodesApiService } from '../../common/services/nodes-api.service';
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Node, NodeEntry, NodePaging, NodesApi } from '@alfresco/js-api';
|
||||
import { DocumentLoaderNode } from '../models/document-folder.model';
|
||||
import { Observable, from, throwError, forkJoin } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { Observable, from, forkJoin } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { DocumentListLoader } from '../interfaces/document-list-loader.interface';
|
||||
import { CustomResourcesService } from './custom-resources.service';
|
||||
|
||||
@@ -41,7 +40,6 @@ export class DocumentListService implements DocumentListLoader {
|
||||
constructor(
|
||||
private nodesApiService: NodesApiService,
|
||||
private apiService: AlfrescoApiService,
|
||||
private logService: LogService,
|
||||
private customResourcesService: CustomResourcesService
|
||||
) {}
|
||||
|
||||
@@ -63,7 +61,7 @@ export class DocumentListService implements DocumentListLoader {
|
||||
* @returns NodeEntry for the copied node
|
||||
*/
|
||||
copyNode(nodeId: string, targetParentId: string): Observable<NodeEntry> {
|
||||
return from(this.nodes.copyNode(nodeId, { targetParentId })).pipe(catchError((err) => this.handleError(err)));
|
||||
return from(this.nodes.copyNode(nodeId, { targetParentId }));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +72,7 @@ export class DocumentListService implements DocumentListLoader {
|
||||
* @returns NodeEntry for the moved node
|
||||
*/
|
||||
moveNode(nodeId: string, targetParentId: string): Observable<NodeEntry> {
|
||||
return from(this.nodes.moveNode(nodeId, { targetParentId })).pipe(catchError((err) => this.handleError(err)));
|
||||
return from(this.nodes.moveNode(nodeId, { targetParentId }));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +117,7 @@ export class DocumentListService implements DocumentListLoader {
|
||||
}
|
||||
}
|
||||
|
||||
return from(this.nodes.listNodeChildren(rootNodeId, params)).pipe(catchError((err) => this.handleError(err)));
|
||||
return from(this.nodes.listNodeChildren(rootNodeId, params));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,10 +157,10 @@ export class DocumentListService implements DocumentListLoader {
|
||||
include: includeFieldsRequest
|
||||
};
|
||||
|
||||
return from(this.nodes.getNode(nodeId, opts)).pipe(catchError((err) => this.handleError(err)));
|
||||
return from(this.nodes.getNode(nodeId, opts));
|
||||
}
|
||||
|
||||
isCustomSourceService(nodeId): boolean {
|
||||
isCustomSourceService(nodeId: string): boolean {
|
||||
return this.customResourcesService.isCustomSource(nodeId);
|
||||
}
|
||||
|
||||
@@ -214,9 +212,4 @@ export class DocumentListService implements DocumentListLoader {
|
||||
)
|
||||
]).pipe(map((results) => new DocumentLoaderNode(results[0], results[1])));
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
||||
|
@@ -29,18 +29,13 @@ import { OverlayContainer } from '@angular/cdk/overlay';
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NewVersionUploaderService {
|
||||
|
||||
private _versionsApi: VersionsApi;
|
||||
get versionsApi(): VersionsApi {
|
||||
this._versionsApi = this._versionsApi ?? new VersionsApi(this.apiService.getInstance());
|
||||
return this._versionsApi;
|
||||
}
|
||||
|
||||
constructor(
|
||||
private apiService: AlfrescoApiService,
|
||||
private dialog: MatDialog,
|
||||
private overlayContainer: OverlayContainer
|
||||
) { }
|
||||
constructor(private apiService: AlfrescoApiService, private dialog: MatDialog, private overlayContainer: OverlayContainer) {}
|
||||
|
||||
/**
|
||||
* Open a dialog NewVersionUploaderDialogComponent to display:
|
||||
@@ -53,7 +48,11 @@ export class NewVersionUploaderService {
|
||||
* @param selectorAutoFocusedOnClose element's selector which should be autofocused after closing modal
|
||||
* @returns an Observable represents the triggered dialog action or an error in case of an error condition
|
||||
*/
|
||||
openUploadNewVersionDialog(data: NewVersionUploaderDialogData, config?: MatDialogConfig, selectorAutoFocusedOnClose?: string) {
|
||||
openUploadNewVersionDialog(
|
||||
data: NewVersionUploaderDialogData,
|
||||
config?: MatDialogConfig,
|
||||
selectorAutoFocusedOnClose?: string
|
||||
): Observable<NewVersionUploaderData> {
|
||||
const { file, node, showVersionsOnly } = data;
|
||||
const showComments = true;
|
||||
const allowDownload = true;
|
||||
@@ -66,11 +65,10 @@ export class NewVersionUploaderService {
|
||||
width: '630px',
|
||||
...(config && Object.keys(config).length > 0 && config)
|
||||
});
|
||||
dialogRef.componentInstance.dialogAction.asObservable()
|
||||
.subscribe((newVersionUploaderData: NewVersionUploaderData) => {
|
||||
observer.next(newVersionUploaderData);
|
||||
});
|
||||
dialogRef.componentInstance.uploadError.asObservable().subscribe(error => {
|
||||
dialogRef.componentInstance.dialogAction.asObservable().subscribe((newVersionUploaderData) => {
|
||||
observer.next(newVersionUploaderData);
|
||||
});
|
||||
dialogRef.componentInstance.uploadError.asObservable().subscribe((error) => {
|
||||
observer.error(error);
|
||||
});
|
||||
dialogRef.afterClosed().subscribe(() => {
|
||||
@@ -80,7 +78,6 @@ export class NewVersionUploaderService {
|
||||
this.overlayContainer.getContainerElement().setAttribute('role', 'main');
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private composePanelClass(showVersionsOnly: boolean): string | string[] {
|
||||
@@ -90,7 +87,7 @@ export class NewVersionUploaderService {
|
||||
|
||||
private static focusOnClose(selectorAutoFocusedOnClose: string): void {
|
||||
if (selectorAutoFocusedOnClose) {
|
||||
document.querySelector<HTMLElement>(selectorAutoFocusedOnClose).focus();
|
||||
document.querySelector<HTMLElement>(selectorAutoFocusedOnClose)?.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,100 +15,72 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
AlfrescoApiService,
|
||||
LogService,
|
||||
CommentModel,
|
||||
CommentsService,
|
||||
User
|
||||
} from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, CommentModel, CommentsService, User } from '@alfresco/adf-core';
|
||||
import { CommentEntry, CommentsApi, Comment } from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
import { ContentService } from '../../common/services/content.service';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ContentService } from '../../common/services/content.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NodeCommentsService implements CommentsService {
|
||||
private _commentsApi: CommentsApi;
|
||||
get commentsApi(): CommentsApi {
|
||||
this._commentsApi = this._commentsApi ?? new CommentsApi(this.apiService.getInstance());
|
||||
return this._commentsApi;
|
||||
}
|
||||
|
||||
private _commentsApi: CommentsApi;
|
||||
get commentsApi(): CommentsApi {
|
||||
this._commentsApi = this._commentsApi ?? new CommentsApi(this.apiService.getInstance());
|
||||
return this._commentsApi;
|
||||
}
|
||||
constructor(private apiService: AlfrescoApiService, private contentService: ContentService) {}
|
||||
|
||||
constructor(
|
||||
private apiService: AlfrescoApiService,
|
||||
private logService: LogService,
|
||||
private contentService: ContentService
|
||||
) {}
|
||||
/**
|
||||
* Gets all comments that have been added to a task.
|
||||
*
|
||||
* @param id ID of the target task
|
||||
* @returns Details for each comment
|
||||
*/
|
||||
get(id: string): Observable<CommentModel[]> {
|
||||
return from(this.commentsApi.listComments(id)).pipe(
|
||||
map((response) => {
|
||||
const comments: CommentModel[] = [];
|
||||
|
||||
/**
|
||||
* Gets all comments that have been added to a task.
|
||||
*
|
||||
* @param id ID of the target task
|
||||
* @returns Details for each comment
|
||||
*/
|
||||
get(id: string): Observable<CommentModel[]> {
|
||||
return from(this.commentsApi.listComments(id))
|
||||
.pipe(
|
||||
map((response) => {
|
||||
const comments: CommentModel[] = [];
|
||||
response.list.entries.forEach((comment: CommentEntry) => {
|
||||
this.addToComments(comments, comment);
|
||||
});
|
||||
|
||||
response.list.entries.forEach((comment: CommentEntry) => {
|
||||
this.addToComments(comments, comment);
|
||||
});
|
||||
return comments;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return comments;
|
||||
}),
|
||||
catchError(
|
||||
(err: any) => this.handleError(err)
|
||||
)
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Adds a comment to a task.
|
||||
*
|
||||
* @param id ID of the target task
|
||||
* @param message Text for the comment
|
||||
* @returns Details about the comment
|
||||
*/
|
||||
add(id: string, message: string): Observable<CommentModel> {
|
||||
return from(this.commentsApi.createComment(id, { content: message })).pipe(map((response) => this.newCommentModel(response.entry)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a comment to a task.
|
||||
*
|
||||
* @param id ID of the target task
|
||||
* @param message Text for the comment
|
||||
* @returns Details about the comment
|
||||
*/
|
||||
add(id: string, message: string): Observable<CommentModel> {
|
||||
return from(this.commentsApi.createComment(id, { content: message }))
|
||||
.pipe(
|
||||
map(
|
||||
(response: CommentEntry) => this.newCommentModel(response.entry)
|
||||
),
|
||||
catchError(
|
||||
(err: any) => this.handleError(err)
|
||||
)
|
||||
);
|
||||
}
|
||||
private addToComments(comments: CommentModel[], comment: CommentEntry): void {
|
||||
const newComment: Comment = comment.entry;
|
||||
|
||||
private addToComments(comments: CommentModel[], comment: CommentEntry): void {
|
||||
const newComment: Comment = comment.entry;
|
||||
comments.push(this.newCommentModel(newComment));
|
||||
}
|
||||
|
||||
comments.push(this.newCommentModel(newComment));
|
||||
}
|
||||
private newCommentModel(comment: Comment): CommentModel {
|
||||
return new CommentModel({
|
||||
id: comment.id,
|
||||
message: comment.content,
|
||||
created: comment.createdAt,
|
||||
createdBy: new User(comment.createdBy)
|
||||
});
|
||||
}
|
||||
|
||||
private newCommentModel(comment: Comment): CommentModel {
|
||||
return new CommentModel({
|
||||
id: comment.id,
|
||||
message: comment.content,
|
||||
created: comment.createdAt,
|
||||
createdBy: new User(comment.createdBy)
|
||||
});
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
|
||||
getUserImage(avatarId: string): string {
|
||||
return this.contentService.getContentUrl(avatarId);
|
||||
}
|
||||
getUserImage(avatarId: string): string {
|
||||
return this.contentService.getContentUrl(avatarId);
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NodePaging, QueriesApi, SearchRequest, ResultSetPaging, SearchApi } from '@alfresco/js-api';
|
||||
import { Observable, Subject, from, throwError } from 'rxjs';
|
||||
import { Observable, Subject, from } from 'rxjs';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { SearchConfigurationService } from './search-configuration.service';
|
||||
|
||||
@@ -25,7 +25,7 @@ import { SearchConfigurationService } from './search-configuration.service';
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SearchService {
|
||||
dataLoaded: Subject<ResultSetPaging> = new Subject();
|
||||
dataLoaded = new Subject<ResultSetPaging>();
|
||||
|
||||
private _queriesApi: QueriesApi;
|
||||
get queriesApi(): QueriesApi {
|
||||
@@ -54,8 +54,7 @@ export class SearchService {
|
||||
promise
|
||||
.then((nodePaging) => {
|
||||
this.dataLoaded.next(nodePaging);
|
||||
})
|
||||
.catch((err) => this.handleError(err));
|
||||
});
|
||||
|
||||
return from(promise);
|
||||
}
|
||||
@@ -75,8 +74,7 @@ export class SearchService {
|
||||
promise
|
||||
.then((nodePaging) => {
|
||||
this.dataLoaded.next(nodePaging);
|
||||
})
|
||||
.catch((err) => this.handleError(err));
|
||||
});
|
||||
|
||||
return from(promise);
|
||||
}
|
||||
@@ -93,15 +91,10 @@ export class SearchService {
|
||||
promise
|
||||
.then((nodePaging) => {
|
||||
this.dataLoaded.next(nodePaging);
|
||||
})
|
||||
.catch((err) => this.handleError(err));
|
||||
});
|
||||
|
||||
return from(promise);
|
||||
}
|
||||
|
||||
private handleError(error: any): Observable<any> {
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
||||
|
||||
export interface SearchOptions {
|
||||
|
@@ -15,11 +15,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AlfrescoApiService, LogService } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { RatingEntry, RatingBody, RatingsApi } from '@alfresco/js-api';
|
||||
import { from, throwError, Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { from, Observable } from 'rxjs';
|
||||
import { RatingServiceInterface } from './rating.service.interface';
|
||||
|
||||
@Injectable({
|
||||
@@ -33,7 +32,7 @@ export class RatingService implements RatingServiceInterface {
|
||||
return this._ratingsApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService, private logService: LogService) {
|
||||
constructor(private apiService: AlfrescoApiService) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,10 +43,7 @@ export class RatingService implements RatingServiceInterface {
|
||||
* @returns The rating value
|
||||
*/
|
||||
getRating(nodeId: string, ratingType: any): Observable<RatingEntry | any> {
|
||||
return from(this.ratingsApi.getRating(nodeId, ratingType))
|
||||
.pipe(
|
||||
catchError(this.handleError)
|
||||
);
|
||||
return from(this.ratingsApi.getRating(nodeId, ratingType));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,10 +59,7 @@ export class RatingService implements RatingServiceInterface {
|
||||
id: ratingType,
|
||||
myRating: vote
|
||||
});
|
||||
return from(this.ratingsApi.createRating(nodeId, ratingBody))
|
||||
.pipe(
|
||||
catchError(this.handleError)
|
||||
);
|
||||
return from(this.ratingsApi.createRating(nodeId, ratingBody));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,14 +70,6 @@ export class RatingService implements RatingServiceInterface {
|
||||
* @returns Null response indicating that the operation is complete
|
||||
*/
|
||||
deleteRating(nodeId: string, ratingType: any): Observable<any> {
|
||||
return from(this.ratingsApi.deleteRating(nodeId, ratingType))
|
||||
.pipe(
|
||||
catchError(this.handleError)
|
||||
);
|
||||
}
|
||||
|
||||
private handleError(error: any): any {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
return from(this.ratingsApi.deleteRating(nodeId, ratingType));
|
||||
}
|
||||
}
|
||||
|
@@ -15,41 +15,26 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AlfrescoApiService, LogService } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { ModelJsonBpmnApi } from '@alfresco/js-api';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class DiagramsService {
|
||||
|
||||
private _modelJsonBpmnApi: ModelJsonBpmnApi;
|
||||
get modelJsonBpmnApi(): ModelJsonBpmnApi {
|
||||
this._modelJsonBpmnApi = this._modelJsonBpmnApi ?? new ModelJsonBpmnApi(this.apiService.getInstance());
|
||||
return this._modelJsonBpmnApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService,
|
||||
private logService: LogService) {
|
||||
}
|
||||
constructor(private apiService: AlfrescoApiService) {}
|
||||
|
||||
getProcessDefinitionModel(processDefinitionId: string): Observable<any> {
|
||||
return from(this.modelJsonBpmnApi.getModelJSON(processDefinitionId))
|
||||
.pipe(
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return from(this.modelJsonBpmnApi.getModelJSON(processDefinitionId));
|
||||
}
|
||||
|
||||
getRunningProcessDefinitionModel(processInstanceId: string): Observable<any> {
|
||||
return from(this.modelJsonBpmnApi.getModelJSONForProcessDefinition(processInstanceId))
|
||||
.pipe(
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
return from(this.modelJsonBpmnApi.getModelJSONForProcessDefinition(processInstanceId));
|
||||
}
|
||||
}
|
||||
|
@@ -16,9 +16,9 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, from, throwError, of } from 'rxjs';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
import { AppConfigService, LogService } from '@alfresco/adf-core';
|
||||
import { Observable, from, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
import { ApplicationInstanceModel } from '../models/application-instance.model';
|
||||
import { Environment } from '../../common/interface/environment.interface';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
@@ -26,13 +26,9 @@ import { RequestOptions } from '@alfresco/js-api';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AppsProcessCloudService {
|
||||
|
||||
deployedApps: ApplicationInstanceModel[];
|
||||
|
||||
constructor(
|
||||
private adfHttpClient: AdfHttpClient,
|
||||
private logService: LogService,
|
||||
private appConfigService: AppConfigService) {
|
||||
constructor(private adfHttpClient: AdfHttpClient, private appConfigService: AppConfigService) {
|
||||
this.loadApps();
|
||||
}
|
||||
|
||||
@@ -76,7 +72,7 @@ export class AppsProcessCloudService {
|
||||
}
|
||||
const path = this.getApplicationUrl();
|
||||
const pathParams = {};
|
||||
const queryParams = { status, roles : role, sort: 'name' };
|
||||
const queryParams = { status, roles: role, sort: 'name' };
|
||||
const httpMethod = 'GET';
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
@@ -95,19 +91,12 @@ export class AppsProcessCloudService {
|
||||
httpMethod
|
||||
};
|
||||
|
||||
return from(this.adfHttpClient.request(path, requestOptions))
|
||||
.pipe(
|
||||
map((applications: any) => applications.list.entries.map((application) => application.entry)),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return from(this.adfHttpClient.request(path, requestOptions)).pipe(
|
||||
map((applications) => applications.list.entries.map((application) => application.entry))
|
||||
);
|
||||
}
|
||||
|
||||
private getApplicationUrl(): string {
|
||||
return `${this.appConfigService.get('bpmHost')}/deployment-service/v1/applications`;
|
||||
}
|
||||
|
||||
private handleError(error?: any) {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
||||
|
@@ -877,7 +877,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
notificationService = TestBed.inject(NotificationService);
|
||||
newVersionUploaderService = TestBed.inject(NewVersionUploaderService);
|
||||
spyOnOpenUploadNewVersionDialog = spyOn(newVersionUploaderService, 'openUploadNewVersionDialog').and.returnValue(
|
||||
of({ action: NewVersionUploaderDataAction.refresh })
|
||||
of({ action: NewVersionUploaderDataAction.refresh } as any)
|
||||
);
|
||||
spyOnReplaceOldFileVersionWithNew = spyOn(widget, 'replaceOldFileVersionWithNew');
|
||||
spyOnShowError = spyOn(notificationService, 'showError');
|
||||
|
@@ -35,7 +35,7 @@ import { ContentCloudNodeSelectorService } from '../../../services/content-cloud
|
||||
import { ProcessCloudContentService } from '../../../services/process-cloud-content.service';
|
||||
import { UploadCloudWidgetComponent } from './upload-cloud.widget';
|
||||
import { DestinationFolderPathModel, DestinationFolderPathType } from '../../../models/form-cloud-representation.model';
|
||||
import { ContentNodeSelectorPanelService, NewVersionUploaderData, NewVersionUploaderDataAction, NewVersionUploaderDialogData, NewVersionUploaderService, VersionManagerUploadData } from '@alfresco/adf-content-services';
|
||||
import { ContentNodeSelectorPanelService, NewVersionUploaderDataAction, NewVersionUploaderDialogData, NewVersionUploaderService, VersionManagerUploadData } from '@alfresco/adf-content-services';
|
||||
|
||||
export const RETRIEVE_METADATA_OPTION = 'retrieveMetadata';
|
||||
export const ALIAS_ROOT_FOLDER = '-root-';
|
||||
@@ -65,7 +65,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
|
||||
rootNodeId = ALIAS_USER_FOLDER;
|
||||
selectedNode: Node;
|
||||
|
||||
_nodesApi: NodesApi;
|
||||
private _nodesApi: NodesApi;
|
||||
get nodesApi(): NodesApi {
|
||||
this._nodesApi = this._nodesApi ?? new NodesApi(this.apiService.getInstance());
|
||||
return this._nodesApi;
|
||||
@@ -214,7 +214,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
|
||||
}
|
||||
|
||||
onUploadNewFileVersion(node: NewVersionUploaderDialogData): void {
|
||||
this.newVersionUploaderService.openUploadNewVersionDialog(node).subscribe((newVersionUploaderData: NewVersionUploaderData) => {
|
||||
this.newVersionUploaderService.openUploadNewVersionDialog(node).subscribe((newVersionUploaderData) => {
|
||||
if (newVersionUploaderData.action === NewVersionUploaderDataAction.upload) {
|
||||
this.replaceOldFileVersionWithNew(newVersionUploaderData as VersionManagerUploadData);
|
||||
}
|
||||
|
@@ -16,9 +16,9 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { throwError, Observable, from } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { AlfrescoApiService, LogService, DownloadService } from '@alfresco/adf-core';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { AlfrescoApiService, DownloadService } from '@alfresco/adf-core';
|
||||
import { ContentService, NodesApiService } from '@alfresco/adf-content-services';
|
||||
import { AuthenticationApi, Node, UploadApi } from '@alfresco/js-api';
|
||||
|
||||
@@ -40,7 +40,6 @@ export class ProcessCloudContentService {
|
||||
|
||||
constructor(
|
||||
private apiService: AlfrescoApiService,
|
||||
private logService: LogService,
|
||||
private nodesApiService: NodesApiService,
|
||||
private contentService: ContentService,
|
||||
private downloadService: DownloadService
|
||||
@@ -51,8 +50,7 @@ export class ProcessCloudContentService {
|
||||
map((res: any) => ({
|
||||
...res.entry,
|
||||
nodeId: res.entry.id
|
||||
})),
|
||||
catchError((err) => this.handleError(err))
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -75,9 +73,4 @@ export class ProcessCloudContentService {
|
||||
const ticket = await this.authenticationApi.getTicket();
|
||||
return ticket?.entry?.id || '';
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
||||
|
@@ -17,8 +17,7 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AppConfigService, OAuth2Service } from '@alfresco/adf-core';
|
||||
import { EMPTY, Observable, throwError } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { EMPTY, Observable } from 'rxjs';
|
||||
import { IdentityGroupServiceInterface } from './identity-group.service.interface';
|
||||
import { IdentityGroupFilterInterface } from './identity-group-filter.interface';
|
||||
import { IdentityGroupModel } from '../models/identity-group.model';
|
||||
@@ -50,25 +49,19 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
|
||||
private searchGroupsByName(name: string): Observable<IdentityGroupModel[]> {
|
||||
this.buildQueryParam(name);
|
||||
|
||||
return this.invokeIdentityGroupApi().pipe(
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return this.invokeIdentityGroupApi();
|
||||
}
|
||||
|
||||
private searchGroupsWithGlobalRoles(name: string, roles: string []): Observable<IdentityGroupModel[]> {
|
||||
this.buildQueryParam(name, roles);
|
||||
|
||||
return this.invokeIdentityGroupApi().pipe(
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return this.invokeIdentityGroupApi();
|
||||
}
|
||||
|
||||
private searchGroupsWithinApp(name: string, applicationName: string, roles?: string []): Observable<IdentityGroupModel[]> {
|
||||
this.buildQueryParam(name, roles, applicationName);
|
||||
|
||||
return this.invokeIdentityGroupApi().pipe(
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return this.invokeIdentityGroupApi();
|
||||
}
|
||||
|
||||
private invokeIdentityGroupApi(): Observable<IdentityGroupModel[]> {
|
||||
@@ -101,10 +94,6 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
|
||||
return roles.filter( role => role.trim() ? true : false);
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
|
||||
private get identityHost(): string {
|
||||
return `${this.appConfigService.get('bpmHost')}`;
|
||||
}
|
||||
|
@@ -16,13 +16,8 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
AppConfigService,
|
||||
JwtHelperService,
|
||||
OAuth2Service
|
||||
} from '@alfresco/adf-core';
|
||||
import { EMPTY, Observable, throwError } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { AppConfigService, JwtHelperService, OAuth2Service } from '@alfresco/adf-core';
|
||||
import { EMPTY, Observable } from 'rxjs';
|
||||
import { IdentityUserServiceInterface } from './identity-user.service.interface';
|
||||
import { IdentityUserModel } from '../models/identity-user.model';
|
||||
import { IdentityUserFilterInterface } from './identity-user-filter.interface';
|
||||
@@ -33,15 +28,9 @@ const IDENTITY_MICRO_SERVICE_INGRESS = 'identity-adapter-service';
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
queryParams: { search: string; application?: string; roles?: string[]; groups?: string[] };
|
||||
|
||||
constructor(
|
||||
private jwtHelperService: JwtHelperService,
|
||||
private oAuth2Service: OAuth2Service,
|
||||
private appConfigService: AppConfigService) {
|
||||
|
||||
}
|
||||
constructor(private jwtHelperService: JwtHelperService, private oAuth2Service: OAuth2Service, private appConfigService: AppConfigService) {}
|
||||
|
||||
/**
|
||||
* Gets the name and other basic details of the current user.
|
||||
@@ -80,33 +69,25 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
private searchUsersByName(name: string): Observable<IdentityUserModel[]> {
|
||||
this.buildQueryParam(name);
|
||||
|
||||
return this.invokeIdentityUserApi().pipe(
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return this.invokeIdentityUserApi();
|
||||
}
|
||||
|
||||
private searchUsersWithGlobalRoles(name: string, roles: string []): Observable<IdentityUserModel[]> {
|
||||
this.buildQueryParam(name, {roles});
|
||||
private searchUsersWithGlobalRoles(name: string, roles: string[]): Observable<IdentityUserModel[]> {
|
||||
this.buildQueryParam(name, { roles });
|
||||
|
||||
return this.invokeIdentityUserApi().pipe(
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return this.invokeIdentityUserApi();
|
||||
}
|
||||
|
||||
private searchUsersWithinApp(name: string, withinApplication: string, roles?: string []): Observable<IdentityUserModel[]> {
|
||||
this.buildQueryParam(name, {roles, withinApplication});
|
||||
private searchUsersWithinApp(name: string, withinApplication: string, roles?: string[]): Observable<IdentityUserModel[]> {
|
||||
this.buildQueryParam(name, { roles, withinApplication });
|
||||
|
||||
return this.invokeIdentityUserApi().pipe(
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return this.invokeIdentityUserApi();
|
||||
}
|
||||
|
||||
private searchUsersWithGroups(name: string, filters: IdentityUserFilterInterface): Observable<IdentityUserModel[]> {
|
||||
this.buildQueryParam(name, filters);
|
||||
|
||||
return this.invokeIdentityUserApi().pipe(
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return this.invokeIdentityUserApi();
|
||||
}
|
||||
|
||||
private invokeIdentityUserApi(): Observable<any> {
|
||||
@@ -121,7 +102,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
this.addOptionalCommaValueToQueryParam('group', filters?.groups);
|
||||
}
|
||||
|
||||
private addOptionalCommaValueToQueryParam(key: string, values: string []) {
|
||||
private addOptionalCommaValueToQueryParam(key: string, values: string[]) {
|
||||
if (values?.length > 0) {
|
||||
const valuesNotEmpty = this.filterOutEmptyValue(values);
|
||||
if (valuesNotEmpty?.length > 0) {
|
||||
@@ -136,15 +117,11 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
}
|
||||
}
|
||||
|
||||
private filterOutEmptyValue(values: string []): string [] {
|
||||
return values.filter( value => value.trim() ? true : false);
|
||||
private filterOutEmptyValue(values: string[]): string[] {
|
||||
return values.filter((value) => value.trim());
|
||||
}
|
||||
|
||||
private get identityHost(): string {
|
||||
return `${this.appConfigService.get('bpmHost')}`;
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
||||
|
@@ -17,24 +17,21 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { RuntimeAppDefinitionsApi, AppDefinitionRepresentation } from '@alfresco/js-api';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { AlfrescoApiService, LogService } from '@alfresco/adf-core';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AppsProcessService {
|
||||
|
||||
private _appsApi: RuntimeAppDefinitionsApi;
|
||||
get appsApi(): RuntimeAppDefinitionsApi {
|
||||
this._appsApi = this._appsApi ?? new RuntimeAppDefinitionsApi(this.apiService.getInstance());
|
||||
return this._appsApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService,
|
||||
private logService: LogService) {
|
||||
}
|
||||
constructor(private apiService: AlfrescoApiService) {}
|
||||
|
||||
/**
|
||||
* Gets a list of deployed apps for this user.
|
||||
@@ -42,11 +39,7 @@ export class AppsProcessService {
|
||||
* @returns The list of deployed apps
|
||||
*/
|
||||
getDeployedApplications(): Observable<AppDefinitionRepresentation[]> {
|
||||
return from(this.appsApi.getAppDefinitions())
|
||||
.pipe(
|
||||
map((response: any) => response.data),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return from(this.appsApi.getAppDefinitions()).pipe(map((response) => response.data));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,11 +49,7 @@ export class AppsProcessService {
|
||||
* @returns The list of deployed apps
|
||||
*/
|
||||
getDeployedApplicationsByName(name: string): Observable<AppDefinitionRepresentation> {
|
||||
return from(this.appsApi.getAppDefinitions())
|
||||
.pipe(
|
||||
map((response: any) => response.data.find((app) => app.name === name)),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return from(this.appsApi.getAppDefinitions()).pipe(map((response) => response.data.find((app) => app.name === name)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,16 +59,6 @@ export class AppsProcessService {
|
||||
* @returns Details of the app
|
||||
*/
|
||||
getApplicationDetailsById(appId: number): Observable<AppDefinitionRepresentation> {
|
||||
return from(this.appsApi.getAppDefinitions())
|
||||
.pipe(
|
||||
map((response: any) => response.data.find((app) => app.id === appId)),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return from(this.appsApi.getAppDefinitions()).pipe(map((response) => response.data.find((app) => app.id === appId)));
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -16,9 +16,9 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { CommentModel, AlfrescoApiService, LogService, CommentsService, User } from '@alfresco/adf-core';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { CommentModel, AlfrescoApiService, CommentsService, User } from '@alfresco/adf-core';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ActivitiCommentsApi } from '@alfresco/js-api';
|
||||
import { PeopleProcessService } from '../../common/services/people-process.service';
|
||||
import { UserProcessModel } from '../../common/models/user-process.model';
|
||||
@@ -27,18 +27,13 @@ import { UserProcessModel } from '../../common/models/user-process.model';
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CommentProcessService implements CommentsService {
|
||||
|
||||
private _commentsApi: ActivitiCommentsApi;
|
||||
get commentsApi(): ActivitiCommentsApi {
|
||||
this._commentsApi = this._commentsApi ?? new ActivitiCommentsApi(this.apiService.getInstance());
|
||||
return this._commentsApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService,
|
||||
private logService: LogService,
|
||||
private peopleProcessService: PeopleProcessService
|
||||
) {
|
||||
}
|
||||
constructor(private apiService: AlfrescoApiService, private peopleProcessService: PeopleProcessService) {}
|
||||
|
||||
/**
|
||||
* Gets all comments that have been added to a process instance.
|
||||
@@ -47,23 +42,23 @@ export class CommentProcessService implements CommentsService {
|
||||
* @returns Details for each comment
|
||||
*/
|
||||
get(id: string): Observable<CommentModel[]> {
|
||||
return from(this.commentsApi.getProcessInstanceComments(id))
|
||||
.pipe(
|
||||
map((response) => {
|
||||
const comments: CommentModel[] = [];
|
||||
response.data.forEach((comment) => {
|
||||
const user = new UserProcessModel(comment.createdBy);
|
||||
comments.push(new CommentModel({
|
||||
return from(this.commentsApi.getProcessInstanceComments(id)).pipe(
|
||||
map((response) => {
|
||||
const comments: CommentModel[] = [];
|
||||
response.data.forEach((comment) => {
|
||||
const user = new UserProcessModel(comment.createdBy);
|
||||
comments.push(
|
||||
new CommentModel({
|
||||
id: comment.id,
|
||||
message: comment.message,
|
||||
created: comment.created,
|
||||
createdBy: new User(user)
|
||||
}));
|
||||
});
|
||||
return comments;
|
||||
}),
|
||||
catchError((err: any) => this.handleError(err))
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
return comments;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,24 +69,19 @@ export class CommentProcessService implements CommentsService {
|
||||
* @returns Details of the comment added
|
||||
*/
|
||||
add(id: string, message: string): Observable<CommentModel> {
|
||||
return from(
|
||||
this.commentsApi.addProcessInstanceComment({ message }, id)
|
||||
).pipe(
|
||||
map((response) => new CommentModel({
|
||||
id: response.id,
|
||||
message: response.message,
|
||||
created: response.created,
|
||||
createdBy: new User(response.createdBy)
|
||||
})),
|
||||
catchError((err: any) => this.handleError(err))
|
||||
return from(this.commentsApi.addProcessInstanceComment({ message }, id)).pipe(
|
||||
map(
|
||||
(response) =>
|
||||
new CommentModel({
|
||||
id: response.id,
|
||||
message: response.message,
|
||||
created: response.created,
|
||||
createdBy: new User(response.createdBy)
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
|
||||
getUserImage(user: UserProcessModel): string {
|
||||
return this.peopleProcessService.getUserImage(user);
|
||||
}
|
||||
|
@@ -18,97 +18,77 @@
|
||||
import { AlfrescoApiService, CommentModel, CommentsService, User } from '@alfresco/adf-core';
|
||||
import { ActivitiCommentsApi, CommentRepresentation } from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { from, Observable, throwError } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { from, Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { UserProcessModel } from '../../common/models/user-process.model';
|
||||
import { PeopleProcessService } from '../../common/services/people-process.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class TaskCommentsService implements CommentsService {
|
||||
private _commentsApi: ActivitiCommentsApi;
|
||||
get commentsApi(): ActivitiCommentsApi {
|
||||
this._commentsApi = this._commentsApi ?? new ActivitiCommentsApi(this.apiService.getInstance());
|
||||
return this._commentsApi;
|
||||
}
|
||||
|
||||
private _commentsApi: ActivitiCommentsApi;
|
||||
get commentsApi(): ActivitiCommentsApi {
|
||||
this._commentsApi = this._commentsApi ?? new ActivitiCommentsApi(this.apiService.getInstance());
|
||||
return this._commentsApi;
|
||||
}
|
||||
constructor(private apiService: AlfrescoApiService, private peopleProcessService: PeopleProcessService) {}
|
||||
|
||||
constructor(
|
||||
private apiService: AlfrescoApiService,
|
||||
private peopleProcessService: PeopleProcessService
|
||||
) {}
|
||||
/**
|
||||
* Gets all comments that have been added to a task.
|
||||
*
|
||||
* @param id ID of the target task
|
||||
* @returns Details for each comment
|
||||
*/
|
||||
get(id: string): Observable<CommentModel[]> {
|
||||
return from(this.commentsApi.getTaskComments(id)).pipe(
|
||||
map((response) => {
|
||||
const comments: CommentModel[] = [];
|
||||
|
||||
/**
|
||||
* Gets all comments that have been added to a task.
|
||||
*
|
||||
* @param id ID of the target task
|
||||
* @returns Details for each comment
|
||||
*/
|
||||
get(id: string): Observable<CommentModel[]> {
|
||||
return from(this.commentsApi.getTaskComments(id))
|
||||
.pipe(
|
||||
map((response) => {
|
||||
const comments: CommentModel[] = [];
|
||||
response.data.forEach((comment) => {
|
||||
this.addToComments(comments, comment);
|
||||
});
|
||||
|
||||
response.data.forEach((comment: CommentRepresentation) => {
|
||||
this.addToComments(comments, comment);
|
||||
});
|
||||
return comments;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return comments;
|
||||
}),
|
||||
catchError(
|
||||
(err: any) => this.handleError(err)
|
||||
)
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Adds a comment to a task.
|
||||
*
|
||||
* @param id ID of the target task
|
||||
* @param message Text for the comment
|
||||
* @returns Details about the comment
|
||||
*/
|
||||
add(id: string, message: string): Observable<CommentModel> {
|
||||
return from(this.commentsApi.addTaskComment({ message }, id)).pipe(map((response) => this.newCommentModel(response)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a comment to a task.
|
||||
*
|
||||
* @param id ID of the target task
|
||||
* @param message Text for the comment
|
||||
* @returns Details about the comment
|
||||
*/
|
||||
add(id: string, message: string): Observable<CommentModel> {
|
||||
return from(this.commentsApi.addTaskComment({ message }, id))
|
||||
.pipe(
|
||||
map(
|
||||
(response: CommentRepresentation) => this.newCommentModel(response)
|
||||
),
|
||||
catchError(
|
||||
(err: any) => this.handleError(err)
|
||||
)
|
||||
);
|
||||
}
|
||||
private addToComments(comments: CommentModel[], comment: CommentRepresentation): void {
|
||||
const user = new UserProcessModel(comment.createdBy);
|
||||
|
||||
private addToComments(comments: CommentModel[], comment: CommentRepresentation): void {
|
||||
const user = new UserProcessModel(comment.createdBy);
|
||||
const newComment: CommentRepresentation = {
|
||||
id: comment.id,
|
||||
message: comment.message,
|
||||
created: comment.created,
|
||||
createdBy: user
|
||||
};
|
||||
|
||||
const newComment: CommentRepresentation = {
|
||||
id: comment.id,
|
||||
message: comment.message,
|
||||
created: comment.created,
|
||||
createdBy: user
|
||||
};
|
||||
comments.push(this.newCommentModel(newComment));
|
||||
}
|
||||
|
||||
comments.push(this.newCommentModel(newComment));
|
||||
}
|
||||
private newCommentModel(representation: CommentRepresentation): CommentModel {
|
||||
return new CommentModel({
|
||||
id: representation.id,
|
||||
message: representation.message,
|
||||
created: representation.created,
|
||||
createdBy: new User(representation.createdBy)
|
||||
});
|
||||
}
|
||||
|
||||
private newCommentModel(representation: CommentRepresentation): CommentModel {
|
||||
return new CommentModel({
|
||||
id: representation.id,
|
||||
message: representation.message,
|
||||
created: representation.created,
|
||||
createdBy: new User(representation.createdBy)
|
||||
});
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
|
||||
getUserImage(user: UserProcessModel): string {
|
||||
return this.peopleProcessService.getUserImage(user);
|
||||
}
|
||||
getUserImage(user: UserProcessModel): string {
|
||||
return this.peopleProcessService.getUserImage(user);
|
||||
}
|
||||
}
|
||||
|
@@ -15,17 +15,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AlfrescoApiService, AppConfigService} from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, AppConfigService } from '@alfresco/adf-core';
|
||||
import { DiscoveryApiService, UploadService } from '@alfresco/adf-content-services';
|
||||
import { ActivitiContentApi } from '@alfresco/js-api';
|
||||
import { ActivitiContentApi, RelatedContentRepresentation } from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { throwError } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ProcessUploadService extends UploadService {
|
||||
|
||||
private _contentApi: ActivitiContentApi;
|
||||
get contentApi(): ActivitiContentApi {
|
||||
this._contentApi = this._contentApi ?? new ActivitiContentApi(this.apiService.getInstance());
|
||||
@@ -36,20 +34,11 @@ export class ProcessUploadService extends UploadService {
|
||||
super(apiService, appConfigService, discoveryApiService);
|
||||
}
|
||||
|
||||
getUploadPromise(file: any): any {
|
||||
getUploadPromise(file: any): Promise<RelatedContentRepresentation> {
|
||||
const opts = {
|
||||
isRelatedContent: true
|
||||
};
|
||||
const processInstanceId = file.options.parentId;
|
||||
const promise = this.contentApi.createRelatedContentOnProcessInstance(processInstanceId, file.file, opts);
|
||||
|
||||
promise.catch((err) => this.handleError(err));
|
||||
|
||||
return promise;
|
||||
return this.contentApi.createRelatedContentOnProcessInstance(processInstanceId, file.file, opts);
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -15,27 +15,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AlfrescoApiService, LogService } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, forkJoin, from, throwError } from 'rxjs';
|
||||
import { Observable, forkJoin, from } from 'rxjs';
|
||||
import { FilterRepresentationModel } from '../models/filter.model';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { UserFiltersApi } from '@alfresco/js-api';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class TaskFilterService {
|
||||
|
||||
private _userFiltersApi: UserFiltersApi;
|
||||
get userFiltersApi(): UserFiltersApi {
|
||||
this._userFiltersApi = this._userFiltersApi ?? new UserFiltersApi(this.apiService.getInstance());
|
||||
return this._userFiltersApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService,
|
||||
private logService: LogService) {
|
||||
}
|
||||
constructor(private apiService: AlfrescoApiService) {}
|
||||
|
||||
/**
|
||||
* Creates and returns the default filters for a process app.
|
||||
@@ -57,50 +54,48 @@ export class TaskFilterService {
|
||||
const completeObservable = this.addFilter(completedTasksFilter);
|
||||
|
||||
return new Observable((observer) => {
|
||||
forkJoin([
|
||||
myTaskObservable,
|
||||
involvedObservable,
|
||||
queuedObservable,
|
||||
completeObservable
|
||||
]
|
||||
).subscribe(
|
||||
(res) => {
|
||||
const filters: FilterRepresentationModel[] = [];
|
||||
res.forEach((filter) => {
|
||||
if (!this.isFilterAlreadyExisting(filters, filter.name)) {
|
||||
if (filter.name === involvedTasksFilter.name) {
|
||||
filters.push(new FilterRepresentationModel({
|
||||
forkJoin([myTaskObservable, involvedObservable, queuedObservable, completeObservable]).subscribe((res) => {
|
||||
const filters: FilterRepresentationModel[] = [];
|
||||
res.forEach((filter) => {
|
||||
if (!this.isFilterAlreadyExisting(filters, filter.name)) {
|
||||
if (filter.name === involvedTasksFilter.name) {
|
||||
filters.push(
|
||||
new FilterRepresentationModel({
|
||||
...filter,
|
||||
filter: involvedTasksFilter.filter,
|
||||
appId
|
||||
}));
|
||||
} else if (filter.name === myTasksFilter.name) {
|
||||
filters.push(new FilterRepresentationModel({
|
||||
})
|
||||
);
|
||||
} else if (filter.name === myTasksFilter.name) {
|
||||
filters.push(
|
||||
new FilterRepresentationModel({
|
||||
...filter,
|
||||
filter: myTasksFilter.filter,
|
||||
appId
|
||||
}));
|
||||
} else if (filter.name === queuedTasksFilter.name) {
|
||||
filters.push(new FilterRepresentationModel({
|
||||
})
|
||||
);
|
||||
} else if (filter.name === queuedTasksFilter.name) {
|
||||
filters.push(
|
||||
new FilterRepresentationModel({
|
||||
...filter,
|
||||
filter: queuedTasksFilter.filter,
|
||||
appId
|
||||
}));
|
||||
} else if (filter.name === completedTasksFilter.name) {
|
||||
filters.push(new FilterRepresentationModel({
|
||||
})
|
||||
);
|
||||
} else if (filter.name === completedTasksFilter.name) {
|
||||
filters.push(
|
||||
new FilterRepresentationModel({
|
||||
...filter,
|
||||
filter: completedTasksFilter.filter,
|
||||
appId
|
||||
}));
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
observer.next(filters);
|
||||
observer.complete();
|
||||
},
|
||||
(err: any) => {
|
||||
this.logService.error(err);
|
||||
}
|
||||
});
|
||||
observer.next(filters);
|
||||
observer.complete();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -111,20 +106,18 @@ export class TaskFilterService {
|
||||
* @returns Array of task filter details
|
||||
*/
|
||||
getTaskListFilters(appId?: number): Observable<FilterRepresentationModel[]> {
|
||||
return from(this.callApiTaskFilters(appId))
|
||||
.pipe(
|
||||
map((response: any) => {
|
||||
const filters: FilterRepresentationModel[] = [];
|
||||
response.data.forEach((filter: FilterRepresentationModel) => {
|
||||
if (!this.isFilterAlreadyExisting(filters, filter.name)) {
|
||||
const filterModel = new FilterRepresentationModel(filter);
|
||||
filters.push(filterModel);
|
||||
}
|
||||
});
|
||||
return filters;
|
||||
}),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return from(this.callApiTaskFilters(appId)).pipe(
|
||||
map((response) => {
|
||||
const filters: FilterRepresentationModel[] = [];
|
||||
response.data.forEach((filter: FilterRepresentationModel) => {
|
||||
if (!this.isFilterAlreadyExisting(filters, filter.name)) {
|
||||
const filterModel = new FilterRepresentationModel(filter);
|
||||
filters.push(filterModel);
|
||||
}
|
||||
});
|
||||
return filters;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,10 +139,7 @@ export class TaskFilterService {
|
||||
* @returns Details of task filter
|
||||
*/
|
||||
getTaskFilterById(filterId: number, appId?: number): Observable<FilterRepresentationModel> {
|
||||
return from(this.callApiTaskFilters(appId)).pipe(
|
||||
map((response) => response.data.find((filter) => filter.id === filterId)),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return from(this.callApiTaskFilters(appId)).pipe(map((response) => response.data.find((filter) => filter.id === filterId)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,10 +150,7 @@ export class TaskFilterService {
|
||||
* @returns Details of task filter
|
||||
*/
|
||||
getTaskFilterByName(taskName: string, appId?: number): Observable<FilterRepresentationModel> {
|
||||
return from(this.callApiTaskFilters(appId)).pipe(
|
||||
map((response) => response.data.find((filter) => filter.name === taskName)),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return from(this.callApiTaskFilters(appId)).pipe(map((response) => response.data.find((filter) => filter.name === taskName)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,11 +160,7 @@ export class TaskFilterService {
|
||||
* @returns Details of task filter just added
|
||||
*/
|
||||
addFilter(filter: FilterRepresentationModel): Observable<FilterRepresentationModel> {
|
||||
return from(this.userFiltersApi.createUserTaskFilter(filter))
|
||||
.pipe(
|
||||
map((response: FilterRepresentationModel) => response),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
return from(this.userFiltersApi.createUserTaskFilter(filter)).pipe(map((response: FilterRepresentationModel) => response));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,9 +253,4 @@ export class TaskFilterService {
|
||||
index
|
||||
});
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
||||
|
@@ -18,14 +18,12 @@
|
||||
import { AlfrescoApiService, AppConfigService } from '@alfresco/adf-core';
|
||||
import { DiscoveryApiService, UploadService } from '@alfresco/adf-content-services';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { throwError } from 'rxjs';
|
||||
import { ActivitiContentApi } from '@alfresco/js-api';
|
||||
import { ActivitiContentApi, RelatedContentRepresentation } from '@alfresco/js-api';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class TaskUploadService extends UploadService {
|
||||
|
||||
private _contentApi: ActivitiContentApi;
|
||||
get contentApi(): ActivitiContentApi {
|
||||
this._contentApi = this._contentApi ?? new ActivitiContentApi(this.apiService.getInstance());
|
||||
@@ -36,20 +34,11 @@ export class TaskUploadService extends UploadService {
|
||||
super(apiService, appConfigService, discoveryApiService);
|
||||
}
|
||||
|
||||
getUploadPromise(file: any): any {
|
||||
getUploadPromise(file: any): Promise<RelatedContentRepresentation> {
|
||||
const opts = {
|
||||
isRelatedContent: true
|
||||
};
|
||||
const taskId = file.options.parentId;
|
||||
const promise = this.contentApi.createRelatedContentOnTask(taskId, file.file, opts);
|
||||
|
||||
promise.catch((err) => this.handleError(err));
|
||||
|
||||
return promise;
|
||||
return this.contentApi.createRelatedContentOnTask(taskId, file.file, opts);
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user