|
|
@@ -9,17 +9,44 @@ import alertDef from './alert_def';
|
|
|
export class AlertPageCtrl {
|
|
|
|
|
|
alerts: any;
|
|
|
- stateFilters = [ 'Ok', 'Warn', 'Critical', 'Acknowledged' ];
|
|
|
- stateFilter = 'Warn';
|
|
|
+ filter = {
|
|
|
+ ok: false,
|
|
|
+ warn: false,
|
|
|
+ critical: false,
|
|
|
+ acknowleged: false
|
|
|
+ };
|
|
|
|
|
|
/** @ngInject */
|
|
|
- constructor(private backendSrv) {
|
|
|
+ constructor(private backendSrv, private $route) {
|
|
|
+ _.each($route.current.params.state, state => {
|
|
|
+ this.filter[state.toLowerCase()] = true;
|
|
|
+ });
|
|
|
+
|
|
|
this.loadAlerts();
|
|
|
}
|
|
|
|
|
|
+ updateFilter() {
|
|
|
+ var stats = [];
|
|
|
+
|
|
|
+ this.filter.ok && stats.push('Ok');
|
|
|
+ this.filter.warn && stats.push('Warn');
|
|
|
+ this.filter.critical && stats.push('critical');
|
|
|
+ this.filter.acknowleged && stats.push('acknowleged');
|
|
|
+
|
|
|
+ this.$route.current.params.state = stats;
|
|
|
+ this.$route.updateParams();
|
|
|
+ }
|
|
|
+
|
|
|
loadAlerts() {
|
|
|
+ var stats = [];
|
|
|
+
|
|
|
+ this.filter.ok && stats.push('Ok');
|
|
|
+ this.filter.warn && stats.push('Warn');
|
|
|
+ this.filter.critical && stats.push('critical');
|
|
|
+ this.filter.acknowleged && stats.push('acknowleged');
|
|
|
+
|
|
|
var params = {
|
|
|
- state: this.stateFilter
|
|
|
+ state: stats
|
|
|
};
|
|
|
|
|
|
this.backendSrv.get('/api/alerts/rules', params).then(result => {
|