refactor: collapse options in getTriggers()
This commit is contained in:
7
dist/datasource-zabbix/datasource.js
vendored
7
dist/datasource-zabbix/datasource.js
vendored
@@ -520,9 +520,12 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
|
||||
var showOkEvents = annotation.showOkEvents ? c.SHOW_ALL_EVENTS : c.SHOW_OK_EVENTS;
|
||||
|
||||
// Show all triggers
|
||||
var showTriggers = c.SHOW_ALL_TRIGGERS;
|
||||
var 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(function (triggers) {
|
||||
|
||||
|
||||
2
dist/datasource-zabbix/datasource.js.map
vendored
2
dist/datasource-zabbix/datasource.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/datasource-zabbix/zabbix.js
vendored
4
dist/datasource-zabbix/zabbix.js
vendored
@@ -170,7 +170,7 @@ System.register(['angular', 'lodash', './utils', './zabbixAPI.service.js', './za
|
||||
}
|
||||
}, {
|
||||
key: 'getTriggers',
|
||||
value: function getTriggers(groupFilter, hostFilter, appFilter, showTriggers, hideHostsInMaintenance) {
|
||||
value: function getTriggers(groupFilter, hostFilter, appFilter, options) {
|
||||
var _this5 = this;
|
||||
|
||||
var promises = [this.getGroups(groupFilter), this.getHosts(groupFilter, hostFilter), this.getApps(groupFilter, hostFilter, appFilter)];
|
||||
@@ -193,7 +193,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, hideHostsInMaintenance);
|
||||
return _this5.zabbixAPI.getTriggers(query.groupids, query.hostids, query.applicationids, options);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
2
dist/datasource-zabbix/zabbix.js.map
vendored
2
dist/datasource-zabbix/zabbix.js.map
vendored
File diff suppressed because one or more lines are too long
8
dist/datasource-zabbix/zabbixAPI.service.js
vendored
8
dist/datasource-zabbix/zabbixAPI.service.js
vendored
@@ -306,7 +306,13 @@ System.register(['angular', 'lodash', './utils', './zabbixAPICore.service'], fun
|
||||
}
|
||||
}, {
|
||||
key: 'getTriggers',
|
||||
value: function getTriggers(groupids, hostids, applicationids, showTriggers, hideHostsInMaintenance, timeFrom, timeTo) {
|
||||
value: function getTriggers(groupids, hostids, applicationids, options) {
|
||||
var showTriggers = options.showTriggers,
|
||||
hideHostsInMaintenance = options.hideHostsInMaintenance,
|
||||
timeFrom = options.timeFrom,
|
||||
timeTo = options.timeTo;
|
||||
|
||||
|
||||
var params = {
|
||||
output: 'extend',
|
||||
groupids: groupids,
|
||||
|
||||
File diff suppressed because one or more lines are too long
6
dist/panel-triggers/module.js
vendored
6
dist/panel-triggers/module.js
vendored
@@ -196,7 +196,11 @@ System.register(['lodash', 'jquery', 'moment', '../datasource-zabbix/utils', 'ap
|
||||
var hostFilter = datasource.replaceTemplateVars(triggerFilter.host.filter);
|
||||
var appFilter = datasource.replaceTemplateVars(triggerFilter.application.filter);
|
||||
|
||||
var getTriggers = zabbix.getTriggers(groupFilter, hostFilter, appFilter, showEvents, hideHostsInMaintenance);
|
||||
var triggersOptions = {
|
||||
showTriggers: showEvents,
|
||||
hideHostsInMaintenance: hideHostsInMaintenance
|
||||
};
|
||||
var getTriggers = zabbix.getTriggers(groupFilter, hostFilter, appFilter, triggersOptions);
|
||||
return getTriggers.then(function (triggers) {
|
||||
return _.map(triggers, _this3.formatTrigger.bind(_this3));
|
||||
});
|
||||
|
||||
2
dist/panel-triggers/module.js.map
vendored
2
dist/panel-triggers/module.js.map
vendored
File diff suppressed because one or more lines are too long
7
dist/test/datasource-zabbix/datasource.js
vendored
7
dist/test/datasource-zabbix/datasource.js
vendored
@@ -417,9 +417,12 @@ var ZabbixAPIDatasource = function () {
|
||||
var showOkEvents = annotation.showOkEvents ? c.SHOW_ALL_EVENTS : c.SHOW_OK_EVENTS;
|
||||
|
||||
// Show all triggers
|
||||
var showTriggers = c.SHOW_ALL_TRIGGERS;
|
||||
var 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(function (triggers) {
|
||||
|
||||
|
||||
4
dist/test/datasource-zabbix/zabbix.js
vendored
4
dist/test/datasource-zabbix/zabbix.js
vendored
@@ -188,7 +188,7 @@ function ZabbixFactory(zabbixAPIService, ZabbixCachingProxy) {
|
||||
|
||||
}, {
|
||||
key: 'getTriggers',
|
||||
value: function getTriggers(groupFilter, hostFilter, appFilter, showTriggers, hideHostsInMaintenance) {
|
||||
value: function getTriggers(groupFilter, hostFilter, appFilter, options) {
|
||||
var _this5 = this;
|
||||
|
||||
var promises = [this.getGroups(groupFilter), this.getHosts(groupFilter, hostFilter), this.getApps(groupFilter, hostFilter, appFilter)];
|
||||
@@ -211,7 +211,7 @@ function ZabbixFactory(zabbixAPIService, ZabbixCachingProxy) {
|
||||
|
||||
return query;
|
||||
}).then(function (query) {
|
||||
return _this5.zabbixAPI.getTriggers(query.groupids, query.hostids, query.applicationids, showTriggers, hideHostsInMaintenance);
|
||||
return _this5.zabbixAPI.getTriggers(query.groupids, query.hostids, query.applicationids, options);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
@@ -376,7 +376,13 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
|
||||
}
|
||||
}, {
|
||||
key: 'getTriggers',
|
||||
value: function getTriggers(groupids, hostids, applicationids, showTriggers, hideHostsInMaintenance, timeFrom, timeTo) {
|
||||
value: function getTriggers(groupids, hostids, applicationids, options) {
|
||||
var showTriggers = options.showTriggers,
|
||||
hideHostsInMaintenance = options.hideHostsInMaintenance,
|
||||
timeFrom = options.timeFrom,
|
||||
timeTo = options.timeTo;
|
||||
|
||||
|
||||
var params = {
|
||||
output: 'extend',
|
||||
groupids: groupids,
|
||||
|
||||
6
dist/test/panel-triggers/module.js
vendored
6
dist/test/panel-triggers/module.js
vendored
@@ -171,7 +171,11 @@ var TriggerPanelCtrl = function (_PanelCtrl) {
|
||||
var hostFilter = datasource.replaceTemplateVars(triggerFilter.host.filter);
|
||||
var appFilter = datasource.replaceTemplateVars(triggerFilter.application.filter);
|
||||
|
||||
var getTriggers = zabbix.getTriggers(groupFilter, hostFilter, appFilter, showEvents, hideHostsInMaintenance);
|
||||
var triggersOptions = {
|
||||
showTriggers: showEvents,
|
||||
hideHostsInMaintenance: hideHostsInMaintenance
|
||||
};
|
||||
var getTriggers = zabbix.getTriggers(groupFilter, hostFilter, appFilter, triggersOptions);
|
||||
return getTriggers.then(function (triggers) {
|
||||
return _lodash2.default.map(triggers, _this3.formatTrigger.bind(_this3));
|
||||
});
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -134,7 +134,11 @@ class TriggerPanelCtrl extends PanelCtrl {
|
||||
var hostFilter = datasource.replaceTemplateVars(triggerFilter.host.filter);
|
||||
var appFilter = datasource.replaceTemplateVars(triggerFilter.application.filter);
|
||||
|
||||
var getTriggers = zabbix.getTriggers(groupFilter, hostFilter, appFilter, showEvents, hideHostsInMaintenance);
|
||||
let triggersOptions = {
|
||||
showTriggers: showEvents,
|
||||
hideHostsInMaintenance: hideHostsInMaintenance
|
||||
};
|
||||
let getTriggers = zabbix.getTriggers(groupFilter, hostFilter, appFilter, triggersOptions);
|
||||
return getTriggers.then(triggers => {
|
||||
return _.map(triggers, this.formatTrigger.bind(this));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user