From 2ddffc8234c3dea73d234e0dbe68a9ae4f2d71e9 Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 9 May 2016 16:32:35 +0200 Subject: [PATCH] feat(alerting): add support for multiple state in ui --- public/app/features/alerts/alerts_ctrl.ts | 35 ++++++++++++++++--- .../features/alerts/partials/alerts_page.html | 7 ++-- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/public/app/features/alerts/alerts_ctrl.ts b/public/app/features/alerts/alerts_ctrl.ts index e07a074433a..4320485282e 100644 --- a/public/app/features/alerts/alerts_ctrl.ts +++ b/public/app/features/alerts/alerts_ctrl.ts @@ -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 => { diff --git a/public/app/features/alerts/partials/alerts_page.html b/public/app/features/alerts/partials/alerts_page.html index bf0b8b4f3ab..27401233e76 100644 --- a/public/app/features/alerts/partials/alerts_page.html +++ b/public/app/features/alerts/partials/alerts_page.html @@ -4,8 +4,11 @@