iss #43 - Some refactoring fixes.
This commit is contained in:
@@ -239,8 +239,11 @@ function (angular, _, kbn) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
////////////////
|
||||||
|
// Templating //
|
||||||
|
////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For templated query.
|
|
||||||
* Find metrics from templated request.
|
* Find metrics from templated request.
|
||||||
*
|
*
|
||||||
* @param {string} query Query from Templating
|
* @param {string} query Query from Templating
|
||||||
@@ -264,10 +267,12 @@ function (angular, _, kbn) {
|
|||||||
var template = _.object(['group', 'host', 'app', 'item'], parts);
|
var template = _.object(['group', 'host', 'app', 'item'], parts);
|
||||||
|
|
||||||
// Get items
|
// Get items
|
||||||
|
var self = this;
|
||||||
if (parts.length === 4) {
|
if (parts.length === 4) {
|
||||||
return this.zabbixAPI.itemFindQuery(template.group, template.host, template.app).then(function (result) {
|
return this.zabbixAPI.itemFindQuery(template.group, template.host, template.app)
|
||||||
|
.then(function (result) {
|
||||||
return _.map(result, function (item) {
|
return _.map(result, function (item) {
|
||||||
var itemname = this.zabbixAPI.expandItemName(item);
|
var itemname = self.zabbixAPI.expandItemName(item);
|
||||||
return {
|
return {
|
||||||
text: itemname,
|
text: itemname,
|
||||||
expandable: false
|
expandable: false
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ function (angular, _) {
|
|||||||
var params = {
|
var params = {
|
||||||
output: ['name']
|
output: ['name']
|
||||||
};
|
};
|
||||||
if (group !== '*') {
|
if (group[0] !== '*') {
|
||||||
params.filter = {
|
params.filter = {
|
||||||
name: group
|
name: group
|
||||||
};
|
};
|
||||||
@@ -321,7 +321,7 @@ function (angular, _) {
|
|||||||
var params = {
|
var params = {
|
||||||
output: ['host', 'name']
|
output: ['host', 'name']
|
||||||
};
|
};
|
||||||
if (hostnames !== '*') {
|
if (hostnames[0] !== '*') {
|
||||||
params.filter = {
|
params.filter = {
|
||||||
name: hostnames
|
name: hostnames
|
||||||
};
|
};
|
||||||
@@ -339,7 +339,7 @@ function (angular, _) {
|
|||||||
var params = {
|
var params = {
|
||||||
output: ['name']
|
output: ['name']
|
||||||
};
|
};
|
||||||
if (application !== '*') {
|
if (application[0] !== '*') {
|
||||||
params.filter = {
|
params.filter = {
|
||||||
name: application
|
name: application
|
||||||
};
|
};
|
||||||
@@ -360,7 +360,7 @@ function (angular, _) {
|
|||||||
var promises = [];
|
var promises = [];
|
||||||
|
|
||||||
// Get hostids from names
|
// Get hostids from names
|
||||||
if (hosts && hosts !== '*') {
|
if (hosts && hosts[0] !== '*') {
|
||||||
promises.push(this.getHostByName(hosts));
|
promises.push(this.getHostByName(hosts));
|
||||||
}
|
}
|
||||||
// Get groupids from names
|
// Get groupids from names
|
||||||
@@ -383,7 +383,7 @@ function (angular, _) {
|
|||||||
return object.groupid;
|
return object.groupid;
|
||||||
}), 'groupid');
|
}), 'groupid');
|
||||||
}
|
}
|
||||||
if (hosts && hosts !== '*') {
|
if (hosts && hosts[0] !== '*') {
|
||||||
hostids = _.map(_.filter(results, function (object) {
|
hostids = _.map(_.filter(results, function (object) {
|
||||||
return object.hostid;
|
return object.hostid;
|
||||||
}), 'hostid');
|
}), 'hostid');
|
||||||
@@ -409,7 +409,7 @@ function (angular, _) {
|
|||||||
var promises = [];
|
var promises = [];
|
||||||
|
|
||||||
// Get hostids from names
|
// Get hostids from names
|
||||||
if (hosts && hosts !== '*') {
|
if (hosts && hosts[0] !== '*') {
|
||||||
promises.push(this.getHostByName(hosts));
|
promises.push(this.getHostByName(hosts));
|
||||||
}
|
}
|
||||||
// Get groupids from names
|
// Get groupids from names
|
||||||
@@ -427,7 +427,7 @@ function (angular, _) {
|
|||||||
return object.groupid;
|
return object.groupid;
|
||||||
}), 'groupid');
|
}), 'groupid');
|
||||||
}
|
}
|
||||||
if (hosts && hosts !== '*') {
|
if (hosts && hosts[0] !== '*') {
|
||||||
hostids = _.map(_.filter(results, function (object) {
|
hostids = _.map(_.filter(results, function (object) {
|
||||||
return object.hostid;
|
return object.hostid;
|
||||||
}), 'hostid');
|
}), 'hostid');
|
||||||
|
|||||||
Reference in New Issue
Block a user