Commit f2e29f98 authored by Florent POITTEVIN's avatar Florent POITTEVIN
Browse files

feat: 1324 in monitoring page display json result of service and resources

parent 3b50f046
......@@ -14150,9 +14150,9 @@
}
},
"solidify-frontend": {
"version": "0.5.0",
"resolved": "https://nexus.unige.ch/repository/npm-all/solidify-frontend/-/solidify-frontend-0.5.0.tgz",
"integrity": "sha512-bXYs+EM7p2hJzl4BJ5YFCp93av8gZUE1JVZBKYROI8v+m1L5D4HC9MnA8ode48hF4KSzFYmnV8I7JnL4vIETeA=="
"version": "0.5.1",
"resolved": "https://nexus.unige.ch/repository/npm-all/solidify-frontend/-/solidify-frontend-0.5.1.tgz",
"integrity": "sha512-xZlRvIFp7Lh5yzUxFRZd2R8JC4D5fXwajN1A2G6jZazWU5VxhG/L/RA0aU29Z9q2Rg9VRGDJZfASnvkdysEUDg=="
},
"sort-keys": {
"version": "1.1.2",
......
<dlcm-shared-base-info-dialog [titleToTranslate]="('monitoring.modal.webservice.title' | translate) + ' : ' + getTitle()">
<code [dlcmSpinner]="isLoadingObs | async"
[highlight]="resultObs | async | json"
class="code"
></code>
</dlcm-shared-base-info-dialog>
\ No newline at end of file
@import "../sass/abstracts/variables";
@import "../sass/abstracts/mixins";
:host {
.code {
min-height: 300px;
white-space: pre-wrap;
}
}
import {
ChangeDetectionStrategy,
Component,
Inject,
OnInit,
} from "@angular/core";
import {FormBuilder} from "@angular/forms";
import {
MAT_DIALOG_DATA,
MatDialogRef,
} from "@angular/material/dialog";
import {
Actions,
Store,
} from "@ngxs/store";
import {PreservationMonitoringWebServiceAction} from "@preservation/monitoring/stores/web-service/preservation-monitoring-web-service.action";
import {PreservationMonitoringWebServiceState} from "@preservation/monitoring/stores/web-service/preservation-monitoring-web-service.state";
import {SharedAbstractContainer} from "@shared/components/containers/shared-abstract/shared-abstract.container";
import {Observable} from "rxjs";
import {
isNullOrUndefined,
MemoizedUtil,
StringUtil,
} from "solidify-frontend";
@Component({
selector: "dlcm-monitoring-web-service-dialog",
templateUrl: "./monitoring-web-service.dialog.html",
styleUrls: ["./monitoring-web-service.dialog.scss"],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MonitoringWebServiceDialog extends SharedAbstractContainer implements OnInit {
isLoadingObs: Observable<boolean> = MemoizedUtil.isLoading(this._store, PreservationMonitoringWebServiceState);
resultObs: Observable<object> = MemoizedUtil.select(this._store, PreservationMonitoringWebServiceState, state => state.result);
constructor(private readonly _store: Store,
private readonly _actions$: Actions,
private readonly _dialogRef: MatDialogRef<MonitoringWebServiceDialog>,
@Inject(MAT_DIALOG_DATA) public data: MonitoringWebServiceDialogData,
private readonly _fb: FormBuilder) {
super();
}
ngOnInit(): void {
super.ngOnInit();
this._store.dispatch(new PreservationMonitoringWebServiceAction.Get(this.data.apiUrl));
}
getTitle(): string {
return StringUtil.capitalize(this.data.serviceName) + (isNullOrUndefined(this.data.resourceName) ? "" : " > " + StringUtil.capitalize(this.data.resourceName));
}
}
export interface MonitoringWebServiceDialogData {
apiUrl: string;
serviceName: string;
resourceName: string | undefined;
}
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
<a [href]="service.status === 'UP' ? service._links.self.href : '#'">
<a (click)="service.status === 'UP' ? open(service._links.self.href, service.name) : null"
class="link"
>
{{service.name}}
</a>
</mat-panel-title>
......@@ -15,7 +17,9 @@
<ul class="resource">
<li *ngFor="let resource of getResources()">
<a [href]="resource.href">{{getResourceName(resource.href)}}</a>
<a (click)="open(resource.href, service.name, getResourceName(resource.href))"
class="link"
>{{getResourceName(resource.href)}}</a>
</li>
</ul>
</mat-expansion-panel>
......@@ -28,4 +28,8 @@
background-color: $extra-ultra-light-grey;
}
}
.link {
text-transform: capitalize;
}
}
......@@ -3,8 +3,17 @@ import {
Component,
Input,
} from "@angular/core";
import {MatDialog} from "@angular/material/dialog";
import {SharedAbstractPresentational} from "@app/shared/components/presentationals/shared-abstract/shared-abstract.presentational";
import {
MonitoringWebServiceDialog,
MonitoringWebServiceDialogData,
} from "@preservation/monitoring/components/dialogs/monitoring-web-service/monitoring-web-service.dialog";
import {PreservationPlanningMonitorService} from "@shared/models/business/preservation-planning-monitor.model";
import {
take,
tap,
} from "rxjs/operators";
import {
HateOASLink,
isArray,
......@@ -25,6 +34,10 @@ export class MonitoringServicePresentational extends SharedAbstractPresentationa
@Input()
index: number | undefined;
constructor(private readonly _dialog: MatDialog) {
super();
}
getResourceName(url: string): string {
return url.substring(url.lastIndexOf(urlSeparator) + 1, url.length);
}
......@@ -40,4 +53,21 @@ export class MonitoringServicePresentational extends SharedAbstractPresentationa
}
return [resources];
}
open(apiUrl: string, serviceName: string, resourceName: string = undefined): void {
this.subscribe(this._dialog.open(MonitoringWebServiceDialog, {
data: {
apiUrl: apiUrl,
serviceName: serviceName,
resourceName: resourceName,
} as MonitoringWebServiceDialogData,
}).afterClosed().pipe(
take(1),
tap((message: string | undefined) => {
if (isNullOrUndefined(message)) {
return;
}
}),
));
}
}
......@@ -6,12 +6,16 @@ import {PreservationMonitoringState} from "@app/features/preservation/monitoring
import {SharedModule} from "@app/shared/shared.module";
import {TranslateModule} from "@ngx-translate/core";
import {NgxsModule} from "@ngxs/store";
import {MonitoringWebServiceDialog} from "@preservation/monitoring/components/dialogs/monitoring-web-service/monitoring-web-service.dialog";
import {PreservationMonitoringWebServiceState} from "@preservation/monitoring/stores/web-service/preservation-monitoring-web-service.state";
const routables = [
MonitoringHomeRoutable,
];
const containers = [];
const dialogs = [];
const dialogs = [
MonitoringWebServiceDialog,
];
const presentationals = [
MonitoringServicePresentational,
];
......@@ -29,6 +33,7 @@ const presentationals = [
TranslateModule.forChild({}),
NgxsModule.forFeature([
PreservationMonitoringState,
PreservationMonitoringWebServiceState,
]),
],
entryComponents: [
......
......@@ -12,6 +12,10 @@ import {
StateContext,
Store,
} from "@ngxs/store";
import {
PreservationMonitoringWebServiceState,
PreservationMonitoringWebServiceStateModel,
} from "@preservation/monitoring/stores/web-service/preservation-monitoring-web-service.state";
import {PreservationPlanningResourceApiEnum} from "@shared/enums/api.enum";
import {PreservationPlanningMonitor} from "@shared/models/business/preservation-planning-monitor.model";
import {Observable} from "rxjs";
......@@ -31,6 +35,7 @@ import {
export interface PreservationMonitoringStateModel extends BaseStateModel {
preservationPlanningMonitor: PreservationPlanningMonitor | undefined;
preservation_monitoring_webService: PreservationMonitoringWebServiceStateModel | undefined;
}
@Injectable()
......@@ -39,8 +44,11 @@ export interface PreservationMonitoringStateModel extends BaseStateModel {
defaults: {
...defaultBaseStateInitValue(),
preservationPlanningMonitor: undefined,
preservation_monitoring_webService: undefined,
},
children: [],
children: [
PreservationMonitoringWebServiceState,
],
})
export class PreservationMonitoringState extends BaseState<PreservationMonitoringStateModel> {
constructor(protected apiService: ApiService,
......
import {LocalStateEnum} from "@shared/enums/local-state.enum";
import {
BaseAction,
BaseSubAction,
} from "solidify-frontend";
const state = LocalStateEnum.preservation_monitoring_webService;
export namespace PreservationMonitoringWebServiceAction {
export class Get extends BaseAction {
static readonly type: string = `[${state}] Get`;
constructor(public apiUrl: string, public keepCurrentContext: boolean = false) {
super();
}
}
export class GetSuccess extends BaseSubAction<Get> {
static readonly type: string = `[${state}] Get Success`;
constructor(public parent: Get, public result: object) {
super(parent);
}
}
export class GetFail extends BaseSubAction<Get> {
static readonly type: string = `[${state}] Get Fail`;
constructor(public parent: Get) {
super(parent);
}
}
}
export const preservationMonitorWebServiceActionNameSpace = PreservationMonitoringWebServiceAction;
import {HttpClient} from "@angular/common/http";
import {Injectable} from "@angular/core";
import {LocalStateEnum} from "@app/shared/enums/local-state.enum";
import {Navigate} from "@ngxs/router-plugin";
import {
Action,
Actions,
State,
StateContext,
Store,
} from "@ngxs/store";
import {
PreservationMonitoringWebServiceAction,
preservationMonitorWebServiceActionNameSpace,
} from "@preservation/monitoring/stores/web-service/preservation-monitoring-web-service.action";
import {Observable} from "rxjs";
import {
catchError,
tap,
} from "rxjs/operators";
import {
ApiService,
BaseState,
BaseStateModel,
defaultBaseStateInitValue,
NotificationService,
SolidifyStateError,
StoreUtil,
} from "solidify-frontend";
export interface PreservationMonitoringWebServiceStateModel extends BaseStateModel {
result: object | undefined;
}
@Injectable()
@State<PreservationMonitoringWebServiceStateModel>({
name: LocalStateEnum.preservation_monitoring_webService,
defaults: {
...defaultBaseStateInitValue(),
result: undefined,
},
children: [],
})
export class PreservationMonitoringWebServiceState extends BaseState<PreservationMonitoringWebServiceStateModel> {
constructor(protected apiService: ApiService,
protected store: Store,
protected notificationService: NotificationService,
protected actions$: Actions,
private readonly _httpClient: HttpClient) {
super(apiService, store, notificationService, actions$, {
nameSpace: preservationMonitorWebServiceActionNameSpace,
}, PreservationMonitoringWebServiceState);
}
protected get _urlResource(): string {
return undefined;
}
@Action(PreservationMonitoringWebServiceAction.Get)
get(ctx: StateContext<PreservationMonitoringWebServiceStateModel>, action: PreservationMonitoringWebServiceAction.Get): Observable<object> {
let reset = {};
if (!action.keepCurrentContext) {
reset = {
result: undefined,
};
}
ctx.patchState({
isLoadingCounter: ctx.getState().isLoadingCounter + 1,
...reset,
});
return this.apiService.getByIdInPath(action.apiUrl).pipe(
StoreUtil.cancelUncompleted(ctx, this.actions$, [PreservationMonitoringWebServiceAction.Get, Navigate]),
tap((result: object) => {
ctx.dispatch(new PreservationMonitoringWebServiceAction.GetSuccess(action, result));
}),
catchError(error => {
ctx.dispatch(new PreservationMonitoringWebServiceAction.GetFail(action));
throw new SolidifyStateError(this, error);
}),
);
}
@Action(PreservationMonitoringWebServiceAction.GetSuccess)
getAllSuccess(ctx: StateContext<PreservationMonitoringWebServiceStateModel>, action: PreservationMonitoringWebServiceAction.GetSuccess): void {
ctx.patchState({
result: action.result,
isLoadingCounter: ctx.getState().isLoadingCounter - 1,
});
}
@Action(PreservationMonitoringWebServiceAction.GetFail)
getAllFail(ctx: StateContext<PreservationMonitoringWebServiceStateModel>, action: PreservationMonitoringWebServiceAction.GetFail): void {
ctx.patchState({
isLoadingCounter: ctx.getState().isLoadingCounter - 1,
});
}
}
......@@ -19,6 +19,7 @@ import {DipDataFileStatusHistoryState} from "@preservation/dip/stores/data-file/
import {DipState} from "@preservation/dip/stores/dip.state";
import {DipStatusHistoryState} from "@preservation/dip/stores/status-history/dip-status-history.state";
import {PreservationJobExecutionReportState} from "@preservation/job/stores/preservation-job-execution/preservation-job-execution-report/preservation-job-execution-report.state";
import {PreservationMonitoringWebServiceState} from "@preservation/monitoring/stores/web-service/preservation-monitoring-web-service.state";
import {SipDataFileState} from "@preservation/sip/stores/data-file/sip-data-file.state";
import {SipDataFileStatusHistoryState} from "@preservation/sip/stores/data-file/status-history/sip-data-file-status-history.state";
import {SipState} from "@preservation/sip/stores/sip.state";
......@@ -45,6 +46,7 @@ const presentationals = [];
NgxsModule.forFeature([
PreservationState,
PreservationMonitoringState,
PreservationMonitoringWebServiceState,
PreservationAipStatusState,
PreservationJobState,
PreservationJobExecutionState,
......
......@@ -104,6 +104,7 @@ export enum LocalStateEnum {
preservation = "preservation",
preservation_monitoring = "preservation_monitoring",
preservation_monitoring_webService = "preservation_monitoring_webService",
preservation_aipStatus = "preservation_aipStatus",
preservation_job = "preservation_job",
preservation_job_execution = "preservation_job_execution",
......
......@@ -1796,6 +1796,13 @@
"french": "French",
"german": "German"
},
"monitoring": {
"modal": {
"webservice": {
"title": "WebService"
}
}
},
"notification": {
"aip": {
"action": {
......
......@@ -1796,6 +1796,13 @@
"french": "French",
"german": "German"
},
"monitoring": {
"modal": {
"webservice": {
"title": "WebService"
}
}
},
"notification": {
"aip": {
"action": {
......
......@@ -1796,6 +1796,13 @@
"french": "Français",
"german": "Allemand"
},
"monitoring": {
"modal": {
"webservice": {
"title": "WebService"
}
}
},
"notification": {
"aip": {
"action": {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment