]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/prometheus/alert-list/alert-list.component.ts
update download target update for octopus release
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / prometheus / alert-list / alert-list.component.ts
1 import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
2 import { I18n } from '@ngx-translate/i18n-polyfill';
3 import { CellTemplate } from '../../../../shared/enum/cell-template.enum';
4 import { Icons } from '../../../../shared/enum/icons.enum';
5 import { CdTableAction } from '../../../../shared/models/cd-table-action';
6 import { CdTableColumn } from '../../../../shared/models/cd-table-column';
7 import { CdTableSelection } from '../../../../shared/models/cd-table-selection';
8 import { Permission } from '../../../../shared/models/permissions';
9 import { CdDatePipe } from '../../../../shared/pipes/cd-date.pipe';
10 import { AuthStorageService } from '../../../../shared/services/auth-storage.service';
11 import { PrometheusAlertService } from '../../../../shared/services/prometheus-alert.service';
12 import { URLBuilderService } from '../../../../shared/services/url-builder.service';
13
14 const BASE_URL = 'silence'; // as only silence actions can be used
15
16 @Component({
17 selector: 'cd-prometheus-list',
18 providers: [{ provide: URLBuilderService, useValue: new URLBuilderService(BASE_URL) }],
19 templateUrl: './alert-list.component.html',
20 styleUrls: ['./alert-list.component.scss']
21 })
22 export class AlertListComponent implements OnInit {
23 @ViewChild('externalLinkTpl')
24 externalLinkTpl: TemplateRef<any>;
25 columns: CdTableColumn[];
26 tableActions: CdTableAction[];
27 permission: Permission;
28 selection = new CdTableSelection();
29 icons = Icons;
30 customCss = {
31 'label label-danger': 'active',
32 'label label-warning': 'unprocessed',
33 'label label-info': 'suppressed'
34 };
35
36 constructor(
37 // NotificationsComponent will refresh all alerts every 5s (No need to do it here as well)
38 private authStorageService: AuthStorageService,
39 public prometheusAlertService: PrometheusAlertService,
40 private urlBuilder: URLBuilderService,
41 private i18n: I18n,
42 private cdDatePipe: CdDatePipe
43 ) {
44 this.permission = this.authStorageService.getPermissions().prometheus;
45 this.tableActions = [
46 {
47 permission: 'create',
48 canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection,
49 disable: (selection: CdTableSelection) =>
50 !selection.hasSingleSelection || selection.first().cdExecuting,
51 icon: Icons.add,
52 routerLink: () => this.urlBuilder.getCreateFrom(this.selection.first().fingerprint),
53 name: this.i18n('Create silence')
54 }
55 ];
56 }
57
58 ngOnInit() {
59 this.columns = [
60 {
61 name: this.i18n('Name'),
62 prop: 'labels.alertname',
63 flexGrow: 2
64 },
65 {
66 name: this.i18n('Job'),
67 prop: 'labels.job',
68 flexGrow: 2
69 },
70 {
71 name: this.i18n('Severity'),
72 prop: 'labels.severity'
73 },
74 {
75 name: this.i18n('State'),
76 prop: 'status.state',
77 cellTransformation: CellTemplate.classAdding
78 },
79 {
80 name: this.i18n('Started'),
81 prop: 'startsAt',
82 pipe: this.cdDatePipe
83 },
84 {
85 name: this.i18n('URL'),
86 prop: 'generatorURL',
87 sortable: false,
88 cellTemplate: this.externalLinkTpl
89 }
90 ];
91 }
92
93 updateSelection(selection: CdTableSelection) {
94 this.selection = selection;
95 }
96 }