Triggers Panel: allow to hide hosts in maintenance, closes #186

This commit is contained in:
Alexander Zobnin
2017-02-10 16:57:13 +03:00
parent a68548ddbb
commit 5d33462d8e
14 changed files with 49 additions and 19 deletions

View File

@@ -154,7 +154,7 @@ System.register(['angular', 'lodash', './utils', './zabbixAPI.service.js', './za
}
}, {
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)];
@@ -177,7 +177,7 @@ System.register(['angular', 'lodash', './utils', './zabbixAPI.service.js', './za
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);
});
}
}]);

File diff suppressed because one or more lines are too long

View File

@@ -286,7 +286,7 @@ System.register(['angular', 'lodash', './utils', './zabbixAPICore.service'], fun
}
}, {
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,
@@ -311,6 +311,10 @@ System.register(['angular', 'lodash', './utils', './zabbixAPICore.service'], fun
params.filter.value = showTriggers;
}
if (hideHostsInMaintenance) {
params.maintenance = false;
}
if (timeFrom || timeTo) {
params.lastChangeSince = timeFrom;
params.lastChangeTill = timeTo;

File diff suppressed because one or more lines are too long

View File

@@ -138,15 +138,21 @@
</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>

View File

@@ -97,6 +97,7 @@ System.register(['lodash', 'jquery', 'moment', '../datasource-zabbix/utils', 'ap
infoField: true,
limit: 10,
showTriggers: 'all triggers',
hideHostsInMaintenance: false,
sortTriggersBy: { text: 'last change', value: 'lastchange' },
showEvents: { text: 'Problems', value: '1' },
triggerSeverity: defaultSeverity,
@@ -181,13 +182,14 @@ System.register(['lodash', 'jquery', 'moment', '../datasource-zabbix/utils', 'ap
_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 _.map(triggers, _this3.formatTrigger.bind(_this3));
});

File diff suppressed because one or more lines are too long

View File

@@ -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)];
@@ -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);
});
}
}]);

View File

@@ -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,
@@ -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;

View File

@@ -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,
@@ -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));
});