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:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user