watchdog-fe #5

Merged
usbharu merged 6 commits from watchdog-fe into master 2024-03-13 07:54:25 +00:00
4 changed files with 30 additions and 0 deletions
Showing only changes of commit ae47b29216 - Show all commits

View File

@ -0,0 +1,3 @@
import {Status} from "./Status";
export type StatusIntMap = Record<Status, number>

View File

@ -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<Metric[]>{
return this.fetchMetrics("http://localhost:4200/api/v1/metrics/ok")
}
getUnknown():Observable<Metric[]> {
return this.fetchMetrics("http://localhost:4200/api/v1/metrics/unknown")
}
getNotGood():Observable<Metric[]> {
return this.fetchMetrics("http://localhost:4200/api/v1/metrics/not-good")
}
getCount():Observable<StatusIntMap>{
return this.http.get<StatusIntMap>("http://localhost:4200/api/v1/metrics")
}
}

View File

@ -1,5 +1,12 @@
<h1>Watch Dog</h1>
<div class="watchdog-count">
<p>OK {{count.OK || 0}}</p>
<p>NOT GOOD {{count.NOT_GOOD || 0 }}</p>
<p>DEAD {{count.DEAD || 0 }}</p>
<p>UNKNOWN {{count.UNKNOWN || 0}}</p>
</div>
<div class="watchdog-dead" *ngFor="let metric of deads">
<p class="metric-name">{{ metric.name }}</p>
</div>

View File

@ -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 = <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))
}
}