refactor: collapse options in getTriggers()

This commit is contained in:
Alexander Zobnin
2017-06-08 14:44:41 +03:00
parent 5de016dd80
commit 889f33f45f
16 changed files with 61 additions and 28 deletions

View File

@@ -346,13 +346,15 @@ class ZabbixAPIDatasource {
var showOkEvents = annotation.showOkEvents ? c.SHOW_ALL_EVENTS : c.SHOW_OK_EVENTS;
// Show all triggers
var showTriggers = c.SHOW_ALL_TRIGGERS;
let triggersOptions = {
showTriggers: c.SHOW_ALL_TRIGGERS,
hideHostsInMaintenance: false
};
var getTriggers = this.zabbix
.getTriggers(this.replaceTemplateVars(annotation.group, {}),
this.replaceTemplateVars(annotation.host, {}),
this.replaceTemplateVars(annotation.application, {}),
showTriggers);
var getTriggers = this.zabbix.getTriggers(this.replaceTemplateVars(annotation.group, {}),
this.replaceTemplateVars(annotation.host, {}),
this.replaceTemplateVars(annotation.application, {}),
triggersOptions);
return getTriggers.then(triggers => {

View File

@@ -137,7 +137,7 @@ function ZabbixFactory(zabbixAPIService, ZabbixCachingProxy) {
/**
* Build query - convert target filters to array of Zabbix items
*/
getTriggers(groupFilter, hostFilter, appFilter, showTriggers, hideHostsInMaintenance) {
getTriggers(groupFilter, hostFilter, appFilter, options) {
let promises = [
this.getGroups(groupFilter),
this.getHosts(groupFilter, hostFilter),
@@ -163,8 +163,7 @@ function ZabbixFactory(zabbixAPIService, ZabbixCachingProxy) {
return query;
}).then(query => {
return this.zabbixAPI
.getTriggers(query.groupids, query.hostids, query.applicationids, showTriggers, hideHostsInMaintenance);
return this.zabbixAPI.getTriggers(query.groupids, query.hostids, query.applicationids, options);
});
}
}

View File

@@ -334,8 +334,10 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
return this.request('service.getsla', params);
}
getTriggers(groupids, hostids, applicationids, showTriggers, hideHostsInMaintenance, timeFrom, timeTo) {
var params = {
getTriggers(groupids, hostids, applicationids, options) {
let {showTriggers, hideHostsInMaintenance, timeFrom, timeTo} = options;
let params = {
output: 'extend',
groupids: groupids,
hostids: hostids,