]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/rules-list/rules-list.component.ts
cc4ee511156d648978c6e3ab90416f93c785ca2b
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / prometheus / rules-list / rules-list.component.ts
1 import { Component, Inject, OnInit } from '@angular/core';
2
3 import _ from 'lodash';
4
5 import { PrometheusService } from '~/app/shared/api/prometheus.service';
6 import { CellTemplate } from '~/app/shared/enum/cell-template.enum';
7 import { CdTableColumn } from '~/app/shared/models/cd-table-column';
8 import { CdTableSelection } from '~/app/shared/models/cd-table-selection';
9 import { PrometheusRule } from '~/app/shared/models/prometheus-alerts';
10 import { DurationPipe } from '~/app/shared/pipes/duration.pipe';
11 import { PrometheusAlertService } from '~/app/shared/services/prometheus-alert.service';
12 import { PrometheusListHelper } from '../prometheus-list-helper';
13
14 @Component({
15 selector: 'cd-rules-list',
16 templateUrl: './rules-list.component.html',
17 styleUrls: ['./rules-list.component.scss']
18 })
19 export class RulesListComponent extends PrometheusListHelper implements OnInit {
20 columns: CdTableColumn[];
21 expandedRow: PrometheusRule;
22 selection = new CdTableSelection();
23
24 /**
25 * Hide active alerts in details of alerting rules as they are already shown
26 * in the 'active alerts' table. Also hide the 'type' column as the type is
27 * always supposed to be 'alerting'.
28 */
29 hideKeys = ['alerts', 'type'];
30
31 constructor(
32 public prometheusAlertService: PrometheusAlertService,
33 @Inject(PrometheusService) prometheusService: PrometheusService
34 ) {
35 super(prometheusService);
36 }
37
38 ngOnInit() {
39 super.ngOnInit();
40 this.columns = [
41 { prop: 'name', name: $localize`Name`, cellClass: 'font-weight-bold', flexGrow: 2 },
42 {
43 prop: 'labels.severity',
44 name: $localize`Severity`,
45 flexGrow: 1,
46 cellTransformation: CellTemplate.badge,
47 customTemplateConfig: {
48 map: {
49 critical: { class: 'badge-danger' },
50 warning: { class: 'badge-warning' }
51 }
52 }
53 },
54 {
55 prop: 'group',
56 name: $localize`Group`,
57 flexGrow: 1,
58 cellTransformation: CellTemplate.badge
59 },
60 { prop: 'duration', name: $localize`Duration`, pipe: new DurationPipe(), flexGrow: 1 },
61 { prop: 'query', name: $localize`Query`, isHidden: true, flexGrow: 1 },
62 { prop: 'annotations.summary', name: $localize`Summary`, flexGrow: 3 }
63 ];
64 }
65
66 updateSelection(selection: CdTableSelection) {
67 this.selection = selection;
68 }
69 }