import { Component, Inject, OnInit, TemplateRef, ViewChild } from '@angular/core';
+import { ActivatedRoute } from '@angular/router';
import { PrometheusService } from '~/app/shared/api/prometheus.service';
import { CellTemplate } from '~/app/shared/enum/cell-template.enum';
const BASE_URL = 'silences'; // as only silence actions can be used
+const SeverityMap = {
+ critical: $localize`Critical`,
+ warning: $localize`Warning`,
+ all: $localize`All`
+};
+
@Component({
selector: 'cd-active-alert-list',
providers: [{ provide: URLBuilderService, useValue: new URLBuilderService(BASE_URL) }],
if (value === 'All') return true;
return false;
}
+ },
+ {
+ name: $localize`Severity`,
+ prop: 'labels.severity',
+ filterOptions: [SeverityMap['all'], SeverityMap['warning'], SeverityMap['critical']],
+ filterInitValue: SeverityMap['all'],
+ filterPredicate: (row, value) => {
+ if (value === SeverityMap['critical']) return row.labels?.severity === 'critical';
+ else if (value === SeverityMap['warning']) return row.labels?.severity === 'warning';
+ if (value === SeverityMap['all']) return true;
+ return false;
+ }
}
];
private authStorageService: AuthStorageService,
public prometheusAlertService: PrometheusAlertService,
private urlBuilder: URLBuilderService,
+ private route: ActivatedRoute,
@Inject(PrometheusService) prometheusService: PrometheusService
) {
super(prometheusService);
}
];
this.prometheusAlertService.getGroupedAlerts(true);
+ this.route.queryParams.subscribe((params) => {
+ const severity = params['severity'];
+ this.filters[1].filterInitValue = SeverityMap[severity];
+ });
}
setExpandedInnerRow(row: any) {
class="overview-alerts-card-badge"
[class.overview-alerts-card-badge-with-border--right]="!last && compact"
[class.overview-alerts-card-badge-with-border--bottom]="!compact">
- <cd-icon [type]="b.icon"></cd-icon>
<a
cdsLink
- class="cds-ml-3"
[routerLink]="['/monitoring/active-alerts']"
[queryParams]="{ severity: b.key }">
+ <cd-icon [type]="b.icon"></cd-icon>
+ <span class="cds-ml-3">
@if(compact) {
{{ b.count }}
} @else {
{{b.key | upperFirst}} ({{ b.count }})
}
+ </span>
</a>
</span>
}