health.component.ts 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { Component, OnInit } from '@angular/core';
  2. import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
  3. import { JhiHealthService } from './health.service';
  4. import { JhiHealthModalComponent } from './health-modal.component';
  5. @Component({
  6. selector: 'jhi-health',
  7. templateUrl: './health.component.html'
  8. })
  9. export class JhiHealthCheckComponent implements OnInit {
  10. healthData: any;
  11. updatingHealth: boolean;
  12. constructor(private modalService: NgbModal, private healthService: JhiHealthService) {}
  13. ngOnInit() {
  14. this.refresh();
  15. }
  16. baseName(name: string) {
  17. return this.healthService.getBaseName(name);
  18. }
  19. getBadgeClass(statusState) {
  20. if (statusState === 'UP') {
  21. return 'badge-success';
  22. } else {
  23. return 'badge-danger';
  24. }
  25. }
  26. refresh() {
  27. this.updatingHealth = true;
  28. this.healthService.checkHealth().subscribe(
  29. health => {
  30. this.healthData = this.healthService.transformHealthData(health);
  31. this.updatingHealth = false;
  32. },
  33. error => {
  34. if (error.status === 503) {
  35. this.healthData = this.healthService.transformHealthData(error.error);
  36. this.updatingHealth = false;
  37. }
  38. }
  39. );
  40. }
  41. showHealth(health: any) {
  42. const modalRef = this.modalService.open(JhiHealthModalComponent);
  43. modalRef.componentInstance.currentHealth = health;
  44. modalRef.result.then(
  45. result => {
  46. // Left blank intentionally, nothing to do here
  47. },
  48. reason => {
  49. // Left blank intentionally, nothing to do here
  50. }
  51. );
  52. }
  53. subSystemName(name: string) {
  54. return this.healthService.getSubSystemName(name);
  55. }
  56. }