1 import { Component, Inject, OnInit, TemplateRef, ViewChild } from '@angular/core';
3 import { PrometheusService } from '../../../../shared/api/prometheus.service';
4 import { CellTemplate } from '../../../../shared/enum/cell-template.enum';
5 import { Icons } from '../../../../shared/enum/icons.enum';
6 import { CdTableAction } from '../../../../shared/models/cd-table-action';
7 import { CdTableColumn } from '../../../../shared/models/cd-table-column';
8 import { CdTableSelection } from '../../../../shared/models/cd-table-selection';
9 import { Permission } from '../../../../shared/models/permissions';
10 import { CdDatePipe } from '../../../../shared/pipes/cd-date.pipe';
11 import { CephReleaseNamePipe } from '../../../../shared/pipes/ceph-release-name.pipe';
12 import { AuthStorageService } from '../../../../shared/services/auth-storage.service';
13 import { PrometheusAlertService } from '../../../../shared/services/prometheus-alert.service';
14 import { SummaryService } from '../../../../shared/services/summary.service';
15 import { URLBuilderService } from '../../../../shared/services/url-builder.service';
16 import { PrometheusListHelper } from '../prometheus-list-helper';
18 const BASE_URL = 'silences'; // as only silence actions can be used
21 selector: 'cd-active-alert-list',
22 providers: [{ provide: URLBuilderService, useValue: new URLBuilderService(BASE_URL) }],
23 templateUrl: './active-alert-list.component.html',
24 styleUrls: ['./active-alert-list.component.scss']
26 export class ActiveAlertListComponent extends PrometheusListHelper implements OnInit {
27 @ViewChild('externalLinkTpl', { static: true })
28 externalLinkTpl: TemplateRef<any>;
29 columns: CdTableColumn[];
30 tableActions: CdTableAction[];
31 permission: Permission;
32 selection = new CdTableSelection();
35 'badge badge-danger': 'active',
36 'badge badge-warning': 'unprocessed',
37 'badge badge-info': 'suppressed'
41 // NotificationsComponent will refresh all alerts every 5s (No need to do it here as well)
42 private authStorageService: AuthStorageService,
43 public prometheusAlertService: PrometheusAlertService,
44 private urlBuilder: URLBuilderService,
45 private cdDatePipe: CdDatePipe,
46 @Inject(PrometheusService) prometheusService: PrometheusService,
47 @Inject(SummaryService) summaryService: SummaryService,
48 @Inject(CephReleaseNamePipe) cephReleaseNamePipe: CephReleaseNamePipe
50 super(prometheusService, summaryService, cephReleaseNamePipe);
51 this.permission = this.authStorageService.getPermissions().prometheus;
55 canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection,
56 disable: (selection: CdTableSelection) =>
57 !selection.hasSingleSelection || selection.first().cdExecuting,
60 '/monitoring' + this.urlBuilder.getCreateFrom(this.selection.first().fingerprint),
61 name: $localize`Create Silence`
70 name: $localize`Name`,
71 prop: 'labels.alertname',
80 name: $localize`Severity`,
81 prop: 'labels.severity'
84 name: $localize`State`,
86 cellTransformation: CellTemplate.classAdding
89 name: $localize`Started`,
97 cellTemplate: this.externalLinkTpl
102 updateSelection(selection: CdTableSelection) {
103 this.selection = selection;