unos/unos-fe/src/app/watchdog/watchdog-top/watchdog-top.component.ts

66 lines
1.6 KiB
TypeScript

import {Component, OnInit} from '@angular/core';
import {FetchMetricsService} from "../services/fetch-metrics.service";
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";
import {MetricListItemComponent} from "../metric-list-item/metric-list-item.component";
@Component({
selector: 'app-watchdog-top',
standalone: true,
imports: [
NgForOf,
RouterOutlet,
HttpClientModule,
MetricListItemComponent,
],
providers:[
FetchMetricsService
],
templateUrl: './watchdog-top.component.html',
styleUrl: './watchdog-top.component.css'
})
export class WatchdogTopComponent implements OnInit{
deads: Metric[] = []
ok: Metric[] = [];
unknown:Metric[] = [];
notGood:Metric[] = [];
count: StatusIntMap = <StatusIntMap>{};
constructor(private fetchMetricsService: FetchMetricsService) {
}
ngOnInit(): void {
this.getDead()
this.getOk()
this.getCount()
}
getDead(): void {
this.fetchMetricsService.getDead().subscribe(res => {
this.deads = res
})
}
getOk():void{
this.fetchMetricsService.getOk().subscribe(res =>{this.ok = res})
}
getCount():void{
this.fetchMetricsService.getCount().subscribe(res => (this.count = res))
}
getUnknown(){
this.fetchMetricsService.getUnknown().subscribe(res => this.unknown = res)
}
getNotGood(){
this.fetchMetricsService.getNotGood().subscribe(res => this.notGood = res)
}
}