1 import { Component, Inject, OnInit } from '@angular/core';
3 import _ from 'lodash';
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';
15 selector: 'cd-rules-list',
16 templateUrl: './rules-list.component.html',
17 styleUrls: ['./rules-list.component.scss']
19 export class RulesListComponent extends PrometheusListHelper implements OnInit {
20 columns: CdTableColumn[];
21 expandedRow: PrometheusRule;
22 selection = new CdTableSelection();
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'.
29 hideKeys = ['alerts', 'type'];
32 public prometheusAlertService: PrometheusAlertService,
33 @Inject(PrometheusService) prometheusService: PrometheusService
35 super(prometheusService);
41 { prop: 'name', name: $localize`Name`, cellClass: 'font-weight-bold', flexGrow: 2 },
43 prop: 'labels.severity',
44 name: $localize`Severity`,
46 cellTransformation: CellTemplate.badge,
47 customTemplateConfig: {
49 critical: { class: 'badge-danger' },
50 warning: { class: 'badge-warning' }
56 name: $localize`Group`,
58 cellTransformation: CellTemplate.badge
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 }
66 updateSelection(selection: CdTableSelection) {
67 this.selection = selection;