From fba21c45c9320468d0c66c5e02c27ea9765479c1 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 9 Jun 2015 17:25:34 +0300 Subject: [PATCH] datasource.js refactoring. --- zabbix/datasource.js | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/zabbix/datasource.js b/zabbix/datasource.js index b8055bc..7e487a5 100644 --- a/zabbix/datasource.js +++ b/zabbix/datasource.js @@ -415,7 +415,8 @@ function (angular, _, kbn) { /** - * For templated query + * For templated query. + * Find metrics from templated request. * * @param {string} query Query from Templating * @return {string} Metric name - group, host, app or item or list @@ -443,7 +444,6 @@ function (angular, _, kbn) { return _.map(result, function (item) { var itemname = expandItemName(item) return { - // TODO: select only unique names text: itemname, expandable: false }; @@ -483,7 +483,7 @@ function (angular, _, kbn) { }); }); } - // Return empty object + // Return empty object for invalid request else { var d = $q.defer(); d.resolve([]); @@ -493,17 +493,14 @@ function (angular, _, kbn) { /** - * Find items from templated request + * Find items belongs to passed groups, hosts and + * applications * - * @param {object} template Template object in format: - * { - * group: [groupnames], - * host: [hostnames], - * app: [appnames], - * item: [itemnames] - * } + * @param {string or array} groups + * @param {string or array} hosts + * @param {string or array} apps * - * @return {Array} Array of Zabbix API item objects + * @return {array} array of Zabbix API item objects */ ZabbixAPIDatasource.prototype.itemFindQuery = function(groups, hosts, apps) { var promises = []; @@ -545,6 +542,14 @@ function (angular, _, kbn) { }; + /** + * Find applications belongs to passed groups and hosts + * + * @param {string or array} hosts + * @param {string or array} groups + * + * @return {array} array of Zabbix API application objects + */ ZabbixAPIDatasource.prototype.appFindQuery = function(hosts, groups) { var promises = []; @@ -576,6 +581,12 @@ function (angular, _, kbn) { }; + /** + * Find hosts belongs to passed groups + * + * @param {string or array} groups + * @return {array} array of Zabbix API host objects + */ ZabbixAPIDatasource.prototype.hostFindQuery = function(groups) { var self = this; return this.findZabbixGroup(groups).then(function (results) {