]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/monitoring-list/monitoring-list.component.ts
import 15.2.5
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / prometheus / monitoring-list / monitoring-list.component.ts
1 import { Component, OnInit, ViewChild } from '@angular/core';
2 import { ActivatedRoute, Router } from '@angular/router';
3
4 import { TabDirective, TabsetComponent } from 'ngx-bootstrap/tabs';
5
6 import { PrometheusService } from '../../../../shared/api/prometheus.service';
7 import { PrometheusAlertService } from '../../../../shared/services/prometheus-alert.service';
8
9 @Component({
10 selector: 'cd-monitoring-list',
11 templateUrl: './monitoring-list.component.html',
12 styleUrls: ['./monitoring-list.component.scss']
13 })
14 export class MonitoringListComponent implements OnInit {
15 constructor(
16 public prometheusAlertService: PrometheusAlertService,
17 private prometheusService: PrometheusService,
18 private route: ActivatedRoute,
19 private router: Router
20 ) {}
21 @ViewChild('tabs', { static: true })
22 tabs: TabsetComponent;
23
24 isPrometheusConfigured = false;
25 isAlertmanagerConfigured = false;
26
27 ngOnInit() {
28 this.prometheusService.ifAlertmanagerConfigured(() => {
29 this.isAlertmanagerConfigured = true;
30 });
31 this.prometheusService.ifPrometheusConfigured(() => {
32 this.isPrometheusConfigured = true;
33 });
34
35 // Activate tab according to given fragment
36 if (this.route.snapshot.fragment) {
37 const tab = this.tabs.tabs.find(
38 (t) => t.elementRef.nativeElement.id === this.route.snapshot.fragment
39 );
40 if (tab) {
41 tab.active = true;
42 }
43 // Ensure fragment is not removed, so page can always be reloaded with the same tab open.
44 this.router.navigate([], { fragment: this.route.snapshot.fragment });
45 }
46 }
47
48 setFragment(element: TabDirective) {
49 this.router.navigate([], { fragment: element.id });
50 }
51 }