Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame^] | 1 | import { Component, OnInit } from '@angular/core'; |
| 2 | import {ExternalComponentStatus} from "../shared/models/externalComponentStatus"; |
| 3 | import {HealthStatusService} from "../shared/server/healthStatusService/health-status.service"; |
| 4 | |
| 5 | @Component({ |
| 6 | selector: 'app-health-status', |
| 7 | templateUrl: './health-status.component.html', |
| 8 | styleUrls: ['./health-status.component.scss'] |
| 9 | }) |
| 10 | export class HealthStatusComponent implements OnInit { |
| 11 | private componentStatuses: Array<ExternalComponentStatus> = []; |
| 12 | private dataIsReady: boolean; |
| 13 | private lastUpdatedDate: Date; |
| 14 | |
| 15 | constructor(private _healthStatusService: HealthStatusService) { |
| 16 | } |
| 17 | |
| 18 | |
| 19 | ngOnInit() { |
| 20 | this.refreshData(); |
| 21 | } |
| 22 | |
| 23 | refreshData(): void { |
| 24 | this.dataIsReady = false; |
| 25 | this._healthStatusService.getProbe() |
| 26 | .subscribe((res: Array<ExternalComponentStatus>) => { |
| 27 | this.componentStatuses = res; |
| 28 | this.dataIsReady = true; |
| 29 | this.lastUpdatedDate = new Date(); |
| 30 | }) |
| 31 | } |
| 32 | |
| 33 | getMetadata(status : ExternalComponentStatus):string { |
| 34 | let metadata = status.metadata; |
| 35 | delete metadata.rawData; |
| 36 | return metadata; |
| 37 | } |
| 38 | |
| 39 | isAvailable(componentStatus: ExternalComponentStatus) { |
| 40 | return componentStatus.available; |
| 41 | } |
| 42 | } |