From ae47b2921628197226c1408e3057cfa299c86bf5 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Wed, 13 Mar 2024 16:19:13 +0900 Subject: [PATCH] =?UTF-8?q?unos-fe:=20=E5=90=84=E7=8A=B6=E6=85=8B=E3=81=AE?= =?UTF-8?q?=E3=82=AA=E3=83=96=E3=82=B8=E3=82=A7=E3=82=AF=E3=83=88=E3=81=AE?= =?UTF-8?q?=E6=95=B0=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unos-fe/src/app/watchdog/models/StatusIntMap.ts | 3 +++ .../app/watchdog/services/fetch-metrics.service.ts | 13 +++++++++++++ .../watchdog-top/watchdog-top.component.html | 7 +++++++ .../watchdog/watchdog-top/watchdog-top.component.ts | 7 +++++++ 4 files changed, 30 insertions(+) create mode 100644 unos-fe/src/app/watchdog/models/StatusIntMap.ts diff --git a/unos-fe/src/app/watchdog/models/StatusIntMap.ts b/unos-fe/src/app/watchdog/models/StatusIntMap.ts new file mode 100644 index 0000000..936cac5 --- /dev/null +++ b/unos-fe/src/app/watchdog/models/StatusIntMap.ts @@ -0,0 +1,3 @@ +import {Status} from "./Status"; + +export type StatusIntMap = Record diff --git a/unos-fe/src/app/watchdog/services/fetch-metrics.service.ts b/unos-fe/src/app/watchdog/services/fetch-metrics.service.ts index 9f2ff02..0e0db47 100644 --- a/unos-fe/src/app/watchdog/services/fetch-metrics.service.ts +++ b/unos-fe/src/app/watchdog/services/fetch-metrics.service.ts @@ -3,6 +3,7 @@ import {Observable} from "rxjs"; import {HttpClient} from "@angular/common/http"; import {Metric} from "../models/Metric"; import {map} from 'rxjs/operators'; +import {StatusIntMap} from "../models/StatusIntMap"; @Injectable({ providedIn: 'root' @@ -31,4 +32,16 @@ export class FetchMetricsService { getOk():Observable{ return this.fetchMetrics("http://localhost:4200/api/v1/metrics/ok") } + + getUnknown():Observable { + return this.fetchMetrics("http://localhost:4200/api/v1/metrics/unknown") + } + + getNotGood():Observable { + return this.fetchMetrics("http://localhost:4200/api/v1/metrics/not-good") + } + + getCount():Observable{ + return this.http.get("http://localhost:4200/api/v1/metrics") + } } diff --git a/unos-fe/src/app/watchdog/watchdog-top/watchdog-top.component.html b/unos-fe/src/app/watchdog/watchdog-top/watchdog-top.component.html index 36c3e88..c5a25c2 100644 --- a/unos-fe/src/app/watchdog/watchdog-top/watchdog-top.component.html +++ b/unos-fe/src/app/watchdog/watchdog-top/watchdog-top.component.html @@ -1,5 +1,12 @@

Watch Dog

+
+

OK {{count.OK || 0}}

+

NOT GOOD {{count.NOT_GOOD || 0 }}

+

DEAD {{count.DEAD || 0 }}

+

UNKNOWN {{count.UNKNOWN || 0}}

+
+

{{ metric.name }}

diff --git a/unos-fe/src/app/watchdog/watchdog-top/watchdog-top.component.ts b/unos-fe/src/app/watchdog/watchdog-top/watchdog-top.component.ts index 5c2256f..d66b93b 100644 --- a/unos-fe/src/app/watchdog/watchdog-top/watchdog-top.component.ts +++ b/unos-fe/src/app/watchdog/watchdog-top/watchdog-top.component.ts @@ -4,6 +4,7 @@ import {Metric} from "../models/Metric"; import {NgForOf} from "@angular/common"; import {RouterOutlet} from "@angular/router"; import {HttpClientModule} from "@angular/common/http"; +import {StatusIntMap} from "../models/StatusIntMap"; @Component({ selector: 'app-watchdog-top', @@ -23,6 +24,7 @@ export class WatchdogTopComponent implements OnInit{ deads: Metric[] = [] ok: Metric[] = []; + count: StatusIntMap = {}; constructor(private fetchMetricsService: FetchMetricsService) { } @@ -30,6 +32,7 @@ export class WatchdogTopComponent implements OnInit{ ngOnInit(): void { this.getDead() this.getOk() + this.getCount() } @@ -43,4 +46,8 @@ export class WatchdogTopComponent implements OnInit{ getOk():void{ this.fetchMetricsService.getOk().subscribe(res =>{this.ok = res}) } + + getCount():void{ + this.fetchMetricsService.getCount().subscribe(res => (this.count = res)) + } }