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