Skip to content

Commit

Permalink
Triggers Panel: allow to hide hosts in maintenance, closes #186
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderzobnin committed Feb 10, 2017
1 parent a68548d commit 5d33462
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 19 deletions.
4 changes: 2 additions & 2 deletions dist/datasource-zabbix/zabbix.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/datasource-zabbix/zabbix.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion dist/datasource-zabbix/zabbixAPI.service.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/datasource-zabbix/zabbixAPI.service.js.map

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions dist/panel-triggers/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,21 @@ <h5 class="section-heading">Options</h5>
</div>
</div>
<div class="gf-form-inline">
<div class="gf-form max-width-17">
<div class="gf-form max-width-12">
<label class="gf-form-label width-6">Font size</label>
<div class="gf-form-select-wrapper max-width-15">
<div class="gf-form-select-wrapper max-width-8">
<select class="gf-form-input"
ng-model="editor.panel.fontSize"
ng-options="f for f in editor.fontSizes"
ng-change="editor.panelCtrl.render()"></select>
</div>
</div>
<gf-form-switch class="gf-form"
label-class="width-14"
label="Hide hosts in maintenance"
checked="editor.panel.hideHostsInMaintenance"
on-change="ctrl.refresh()">
</gf-form-switch>
</div>
</div>

Expand Down
4 changes: 3 additions & 1 deletion dist/panel-triggers/module.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/panel-triggers/module.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/test/datasource-zabbix/zabbix.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function ZabbixFactory(zabbixAPIService, ZabbixCachingProxy) {

}, {
key: 'getTriggers',
value: function getTriggers(groupFilter, hostFilter, appFilter, showTriggers) {
value: function getTriggers(groupFilter, hostFilter, appFilter, showTriggers, hideHostsInMaintenance) {
var _this5 = this;

var promises = [this.getGroups(groupFilter), this.getHosts(groupFilter, hostFilter), this.getApps(groupFilter, hostFilter, appFilter)];
Expand All @@ -195,7 +195,7 @@ function ZabbixFactory(zabbixAPIService, ZabbixCachingProxy) {

return query;
}).then(function (query) {
return _this5.zabbixAPI.getTriggers(query.groupids, query.hostids, query.applicationids, showTriggers);
return _this5.zabbixAPI.getTriggers(query.groupids, query.hostids, query.applicationids, showTriggers, hideHostsInMaintenance);
});
}
}]);
Expand Down
6 changes: 5 additions & 1 deletion dist/test/datasource-zabbix/zabbixAPI.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
}
}, {
key: 'getTriggers',
value: function getTriggers(groupids, hostids, applicationids, showTriggers, timeFrom, timeTo) {
value: function getTriggers(groupids, hostids, applicationids, showTriggers, hideHostsInMaintenance, timeFrom, timeTo) {
var params = {
output: 'extend',
groupids: groupids,
Expand All @@ -381,6 +381,10 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
params.filter.value = showTriggers;
}

if (hideHostsInMaintenance) {
params.maintenance = false;
}

if (timeFrom || timeTo) {
params.lastChangeSince = timeFrom;
params.lastChangeTill = timeTo;
Expand Down
4 changes: 3 additions & 1 deletion dist/test/panel-triggers/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var panelDefaults = {
infoField: true,
limit: 10,
showTriggers: 'all triggers',
hideHostsInMaintenance: false,
sortTriggersBy: { text: 'last change', value: 'lastchange' },
showEvents: { text: 'Problems', value: '1' },
triggerSeverity: defaultSeverity,
Expand Down Expand Up @@ -156,13 +157,14 @@ var TriggerPanelCtrl = function (_PanelCtrl) {
_this3.zabbix = zabbix;
var showEvents = _this3.panel.showEvents.value;
var triggerFilter = _this3.panel.triggers;
var hideHostsInMaintenance = _this3.panel.hideHostsInMaintenance;

// Replace template variables
var groupFilter = datasource.replaceTemplateVars(triggerFilter.group.filter);
var hostFilter = datasource.replaceTemplateVars(triggerFilter.host.filter);
var appFilter = datasource.replaceTemplateVars(triggerFilter.application.filter);

var getTriggers = zabbix.getTriggers(groupFilter, hostFilter, appFilter, showEvents);
var getTriggers = zabbix.getTriggers(groupFilter, hostFilter, appFilter, showEvents, hideHostsInMaintenance);
return getTriggers.then(function (triggers) {
return _lodash2.default.map(triggers, _this3.formatTrigger.bind(_this3));
});
Expand Down
4 changes: 2 additions & 2 deletions src/datasource-zabbix/zabbix.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function ZabbixFactory(zabbixAPIService, ZabbixCachingProxy) {
/**
* Build query - convert target filters to array of Zabbix items
*/
getTriggers(groupFilter, hostFilter, appFilter, showTriggers) {
getTriggers(groupFilter, hostFilter, appFilter, showTriggers, hideHostsInMaintenance) {
let promises = [
this.getGroups(groupFilter),
this.getHosts(groupFilter, hostFilter),
Expand All @@ -147,7 +147,7 @@ function ZabbixFactory(zabbixAPIService, ZabbixCachingProxy) {
return query;
}).then(query => {
return this.zabbixAPI
.getTriggers(query.groupids, query.hostids, query.applicationids, showTriggers);
.getTriggers(query.groupids, query.hostids, query.applicationids, showTriggers, hideHostsInMaintenance);
});
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/datasource-zabbix/zabbixAPI.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
return this.request('service.getsla', params);
}

getTriggers(groupids, hostids, applicationids, showTriggers, timeFrom, timeTo) {
getTriggers(groupids, hostids, applicationids, showTriggers, hideHostsInMaintenance, timeFrom, timeTo) {
var params = {
output: 'extend',
groupids: groupids,
Expand All @@ -341,6 +341,10 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
params.filter.value = showTriggers;
}

if (hideHostsInMaintenance) {
params.maintenance = false;
}

if (timeFrom || timeTo) {
params.lastChangeSince = timeFrom;
params.lastChangeTill = timeTo;
Expand Down
10 changes: 8 additions & 2 deletions src/panel-triggers/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,21 @@ <h5 class="section-heading">Options</h5>
</div>
</div>
<div class="gf-form-inline">
<div class="gf-form max-width-17">
<div class="gf-form max-width-12">
<label class="gf-form-label width-6">Font size</label>
<div class="gf-form-select-wrapper max-width-15">
<div class="gf-form-select-wrapper max-width-8">
<select class="gf-form-input"
ng-model="editor.panel.fontSize"
ng-options="f for f in editor.fontSizes"
ng-change="editor.panelCtrl.render()"></select>
</div>
</div>
<gf-form-switch class="gf-form"
label-class="width-14"
label="Hide hosts in maintenance"
checked="editor.panel.hideHostsInMaintenance"
on-change="ctrl.refresh()">
</gf-form-switch>
</div>
</div>

Expand Down
4 changes: 3 additions & 1 deletion src/panel-triggers/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var panelDefaults = {
infoField: true,
limit: 10,
showTriggers: 'all triggers',
hideHostsInMaintenance: false,
sortTriggersBy: { text: 'last change', value: 'lastchange' },
showEvents: { text: 'Problems', value: '1' },
triggerSeverity: defaultSeverity,
Expand Down Expand Up @@ -121,13 +122,14 @@ class TriggerPanelCtrl extends PanelCtrl {
this.zabbix = zabbix;
var showEvents = this.panel.showEvents.value;
var triggerFilter = this.panel.triggers;
var hideHostsInMaintenance = this.panel.hideHostsInMaintenance;

// Replace template variables
var groupFilter = datasource.replaceTemplateVars(triggerFilter.group.filter);
var hostFilter = datasource.replaceTemplateVars(triggerFilter.host.filter);
var appFilter = datasource.replaceTemplateVars(triggerFilter.application.filter);

var getTriggers = zabbix.getTriggers(groupFilter, hostFilter, appFilter, showEvents);
var getTriggers = zabbix.getTriggers(groupFilter, hostFilter, appFilter, showEvents, hideHostsInMaintenance);
return getTriggers.then(triggers => {
return _.map(triggers, this.formatTrigger.bind(this));
});
Expand Down

0 comments on commit 5d33462

Please sign in to comment.