From abb8f33d77c394ed257d10dea3351949943b23ba Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 10 Nov 2016 16:07:13 +0100 Subject: [PATCH] feat(alertlist): make it possible to filter on alerts from current dashboard --- public/app/plugins/panel/alertlist/editor.html | 1 + public/app/plugins/panel/alertlist/module.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/panel/alertlist/editor.html b/public/app/plugins/panel/alertlist/editor.html index b2038df34b8..344af7408fc 100644 --- a/public/app/plugins/panel/alertlist/editor.html +++ b/public/app/plugins/panel/alertlist/editor.html @@ -11,6 +11,7 @@ Max items +
State filter
diff --git a/public/app/plugins/panel/alertlist/module.ts b/public/app/plugins/panel/alertlist/module.ts index 543c5f04833..d03fad49073 100644 --- a/public/app/plugins/panel/alertlist/module.ts +++ b/public/app/plugins/panel/alertlist/module.ts @@ -25,7 +25,8 @@ class AlertListPanel extends PanelCtrl { panelDefaults = { show: 'current', limit: 10, - stateFilter: [] + stateFilter: [], + onlyAlertsOnDashboard: false }; @@ -71,9 +72,13 @@ class AlertListPanel extends PanelCtrl { var params: any = { limit: this.panel.limit, type: 'alert', - newState: this.panel.stateFilter + newState: this.panel.stateFilter, }; + if (this.panel.onlyAlertsOnDashboard) { + params.dashboardId = this.dashboard.id; + } + params.from = dateMath.parse(this.dashboard.time.from).unix() * 1000; params.to = dateMath.parse(this.dashboard.time.to).unix() * 1000; @@ -93,6 +98,10 @@ class AlertListPanel extends PanelCtrl { state: this.panel.stateFilter }; + if (this.panel.onlyAlertsOnDashboard) { + params.dashboardId = this.dashboard.id; + } + this.backendSrv.get(`/api/alerts`, params) .then(res => { this.currentAlerts = _.map(res, al => {