]>
Commit | Line | Data |
---|---|---|
f67539c2 | 1 | import { Component, Inject, OnInit } from '@angular/core'; |
9f95a23c | 2 | |
2a845540 TL |
3 | import _ from 'lodash'; |
4 | ||
f67539c2 | 5 | import { PrometheusService } from '~/app/shared/api/prometheus.service'; |
2a845540 | 6 | import { CellTemplate } from '~/app/shared/enum/cell-template.enum'; |
f67539c2 | 7 | import { CdTableColumn } from '~/app/shared/models/cd-table-column'; |
2a845540 | 8 | import { CdTableSelection } from '~/app/shared/models/cd-table-selection'; |
f67539c2 TL |
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'; | |
9f95a23c TL |
13 | |
14 | @Component({ | |
15 | selector: 'cd-rules-list', | |
16 | templateUrl: './rules-list.component.html', | |
17 | styleUrls: ['./rules-list.component.scss'] | |
18 | }) | |
f67539c2 | 19 | export class RulesListComponent extends PrometheusListHelper implements OnInit { |
9f95a23c | 20 | columns: CdTableColumn[]; |
e306af50 | 21 | expandedRow: PrometheusRule; |
2a845540 | 22 | selection = new CdTableSelection(); |
9f95a23c TL |
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 | ||
f67539c2 TL |
31 | constructor( |
32 | public prometheusAlertService: PrometheusAlertService, | |
33 | @Inject(PrometheusService) prometheusService: PrometheusService | |
34 | ) { | |
35 | super(prometheusService); | |
e306af50 | 36 | } |
9f95a23c TL |
37 | |
38 | ngOnInit() { | |
f67539c2 | 39 | super.ngOnInit(); |
9f95a23c | 40 | this.columns = [ |
2a845540 TL |
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 } | |
9f95a23c TL |
63 | ]; |
64 | } | |
2a845540 TL |
65 | |
66 | updateSelection(selection: CdTableSelection) { | |
67 | this.selection = selection; | |
68 | } | |
9f95a23c | 69 | } |