import { Component , OnInit } from '@angular/core' ; import { NgbModal } from '@ng-bootstrap/ng-bootstrap' ; import { JhiHealthService } from './health.service' ; import { JhiHealthModalComponent } from './health-modal.component' ; @ Component ( { selector : 'jhi-health' , templateUrl : './health.component.html' } ) export class JhiHealthCheckComponent implements OnInit { healthData : any ; updatingHealth : boolean ; constructor ( private modalService , private healthService ) { } ngOnInit ( ) { this . refresh ( ) ; } baseName ( name ) { return this . healthService . getBaseName ( name ) ; } getBadgeClass ( statusState ) { if ( statusState === 'UP' ) { return 'badge-success' ; } else { return 'badge-danger' ; } } refresh ( ) { this . updatingHealth = true ; this . healthService . checkHealth ( ) . subscribe ( health => { this . healthData = this . healthService . transformHealthData ( health ) ; this . updatingHealth = false ; } , error => { if ( error . status === 503 ) { this . healthData = this . healthService . transformHealthData ( error . error ) ; this . updatingHealth = false ; } } ) ; } showHealth ( health ) { const modalRef = this . modalService . open ( JhiHealthModalComponent ) ; modalRef . componentInstance . currentHealth = health ; modalRef . result . then ( result => { } , reason => { } ) ; } subSystemName ( name ) { return this . healthService . getSubSystemName ( name ) ; } }