[CST-5535] Fix issue with error notice message on health page loading

This commit is contained in:
Giuseppe Digilio
2022-05-18 13:31:09 +02:00
parent d4dc176870
commit ef332af17e
2 changed files with 27 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
<div class="container"> <div class="container" *ngIf="(healthResponseInitialised | async) && (healthInfoResponseInitialised | async)">
<div *ngIf="(healthResponse | async) && (healthInfoResponse | async)"> <div *ngIf="(healthResponse | async) && (healthInfoResponse | async)">
<ul ngbNav #nav="ngbNav" [activeId]="'health'" class="nav-tabs"> <ul ngbNav #nav="ngbNav" [activeId]="'health'" class="nav-tabs">
<li [ngbNavItem]="'health'"> <li [ngbNavItem]="'health'">

View File

@@ -23,6 +23,16 @@ export class HealthPageComponent implements OnInit {
*/ */
healthResponse: BehaviorSubject<HealthResponse> = new BehaviorSubject<HealthResponse>(null); healthResponse: BehaviorSubject<HealthResponse> = new BehaviorSubject<HealthResponse>(null);
/**
* Represent if the response from health status endpoint is already retrieved or not
*/
healthResponseInitialised: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
/**
* Represent if the response from health info endpoint is already retrieved or not
*/
healthInfoResponseInitialised: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
constructor(private healthDataService: HealthService) { constructor(private healthDataService: HealthService) {
} }
@@ -31,13 +41,25 @@ export class HealthPageComponent implements OnInit {
*/ */
ngOnInit(): void { ngOnInit(): void {
this.healthDataService.getHealth().pipe(take(1)).subscribe({ this.healthDataService.getHealth().pipe(take(1)).subscribe({
next: (data: any) => { this.healthResponse.next(data.payload); }, next: (data: any) => {
error: () => { this.healthResponse.next(null); } this.healthResponse.next(data.payload);
this.healthResponseInitialised.next(true);
},
error: () => {
this.healthResponse.next(null);
this.healthResponseInitialised.next(true);
}
}); });
this.healthDataService.getInfo().pipe(take(1)).subscribe({ this.healthDataService.getInfo().pipe(take(1)).subscribe({
next: (data: any) => { this.healthInfoResponse.next(data.payload); }, next: (data: any) => {
error: () => { this.healthInfoResponse.next(null); } this.healthInfoResponse.next(data.payload);
this.healthInfoResponseInitialised.next(true);
},
error: () => {
this.healthInfoResponse.next(null);
this.healthInfoResponseInitialised.next(true);
}
}); });
} }