Refactoring of query() method.

This commit is contained in:
Alexander Zobnin
2015-05-27 17:00:25 +03:00
parent 974d49b0b9
commit dace394060

View File

@@ -51,18 +51,13 @@ function (angular, _, kbn) {
var pattern = /([\w.]+(?:\[[^\[]*\])|[\w.]+)/g; var pattern = /([\w.]+(?:\[[^\[]*\])|[\w.]+)/g;
var keys = item_key.match(pattern); var keys = item_key.match(pattern);
var self = this;
return _.map(keys, function (key) { return _.map(keys, function (key) {
var self = this;
return this.findZabbixItem(hostname, key).then(function (items) { return this.findZabbixItem(hostname, key).then(function (items) {
if (items.length) { return $q.all(_.map(items, function (item) {
var item = items[0];
var itemname = expandItemName(item);
return self.performTimeSeriesQuery(item, from, to).then(_.partial( return self.performTimeSeriesQuery(item, from, to).then(_.partial(
self.handleZabbixAPIResponse, itemname)); self.handleZabbixAPIResponse, expandItemName(item)));
} else { }, this));
return [];
}
}); });
}, this); }, this);
} }