mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #6538 from grafana/alertlist_only_from_dashboard
feat(alertlist): make it possible to filter on alerts from current da…
This commit is contained in:
commit
b824fa1916
@ -11,6 +11,7 @@
|
|||||||
<span class="gf-form-label width-8">Max items</span>
|
<span class="gf-form-label width-8">Max items</span>
|
||||||
<input type="text" class="gf-form-input max-width-15" ng-model="ctrl.panel.limit" ng-change="ctrl.onRender()" />
|
<input type="text" class="gf-form-input max-width-15" ng-model="ctrl.panel.limit" ng-change="ctrl.onRender()" />
|
||||||
</div>
|
</div>
|
||||||
|
<gf-form-switch class="gf-form" label="Alerts from this dashboard" label-class="width-18" checked="ctrl.panel.onlyAlertsOnDashboard" on-change="ctrl.updateStateFilter()"></gf-form-switch>
|
||||||
</div>
|
</div>
|
||||||
<div class="section gf-form-group">
|
<div class="section gf-form-group">
|
||||||
<h5 class="section-heading">State filter</h5>
|
<h5 class="section-heading">State filter</h5>
|
||||||
|
@ -25,7 +25,8 @@ class AlertListPanel extends PanelCtrl {
|
|||||||
panelDefaults = {
|
panelDefaults = {
|
||||||
show: 'current',
|
show: 'current',
|
||||||
limit: 10,
|
limit: 10,
|
||||||
stateFilter: []
|
stateFilter: [],
|
||||||
|
onlyAlertsOnDashboard: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -71,9 +72,13 @@ class AlertListPanel extends PanelCtrl {
|
|||||||
var params: any = {
|
var params: any = {
|
||||||
limit: this.panel.limit,
|
limit: this.panel.limit,
|
||||||
type: 'alert',
|
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.from = dateMath.parse(this.dashboard.time.from).unix() * 1000;
|
||||||
params.to = dateMath.parse(this.dashboard.time.to).unix() * 1000;
|
params.to = dateMath.parse(this.dashboard.time.to).unix() * 1000;
|
||||||
|
|
||||||
@ -93,6 +98,10 @@ class AlertListPanel extends PanelCtrl {
|
|||||||
state: this.panel.stateFilter
|
state: this.panel.stateFilter
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (this.panel.onlyAlertsOnDashboard) {
|
||||||
|
params.dashboardId = this.dashboard.id;
|
||||||
|
}
|
||||||
|
|
||||||
this.backendSrv.get(`/api/alerts`, params)
|
this.backendSrv.get(`/api/alerts`, params)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
this.currentAlerts = _.map(res, al => {
|
this.currentAlerts = _.map(res, al => {
|
||||||
|
Loading…
Reference in New Issue
Block a user