[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:
Denys Vuika
2023-10-27 13:51:28 +01:00
committed by GitHub
parent 53ad9f729b
commit 2d3175ef4a
24 changed files with 319 additions and 937 deletions

View File

@@ -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');
}
}