Refoctoring of metricFindQuery().
This commit is contained in:
@@ -223,9 +223,9 @@ function (angular, _, kbn) {
|
|||||||
else if (response.data.error) {
|
else if (response.data.error) {
|
||||||
// Handle Zabbix API errors
|
// Handle Zabbix API errors
|
||||||
|
|
||||||
|
// Handle auth errors
|
||||||
if (response.data.error.data == "Session terminated, re-login, please." ||
|
if (response.data.error.data == "Session terminated, re-login, please." ||
|
||||||
response.data.error.data == 'Not authorised.') {
|
response.data.error.data == 'Not authorised.') {
|
||||||
// Handle auth errors
|
|
||||||
return self.performZabbixAPILogin().then(function (response) {
|
return self.performZabbixAPILogin().then(function (response) {
|
||||||
self.auth = response;
|
self.auth = response;
|
||||||
return self.performZabbixAPIRequest(method, params);
|
return self.performZabbixAPIRequest(method, params);
|
||||||
@@ -427,19 +427,49 @@ function (angular, _, kbn) {
|
|||||||
|
|
||||||
// Get items
|
// Get items
|
||||||
if (parts.length === 4) {
|
if (parts.length === 4) {
|
||||||
return this.itemFindQuery(template);
|
return this.itemFindQuery(template).then(function (result) {
|
||||||
|
return _.map(result, function (item) {
|
||||||
|
var itemname = expandItemName(item)
|
||||||
|
return {
|
||||||
|
// TODO: select only unique names
|
||||||
|
text: itemname,
|
||||||
|
expandable: false
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Get applications
|
// Get applications
|
||||||
else if (parts.length === 3) {
|
else if (parts.length === 3) {
|
||||||
return this.appFindQuery(template);
|
return this.appFindQuery(template).then(function (result) {
|
||||||
|
return _.map(result, function (app) {
|
||||||
|
return {
|
||||||
|
text: app.name,
|
||||||
|
expandable: false
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Get hosts
|
// Get hosts
|
||||||
else if (parts.length === 2) {
|
else if (parts.length === 2) {
|
||||||
return this.hostFindQuery(template);
|
return this.hostFindQuery(template).then(function (result) {
|
||||||
|
return _.map(result, function (host) {
|
||||||
|
return {
|
||||||
|
text: host.name,
|
||||||
|
expandable: false
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Get groups
|
// Get groups
|
||||||
else if (parts.length === 1) {
|
else if (parts.length === 1) {
|
||||||
return this.groupFindQuery(template);
|
return this.performHostGroupSuggestQuery().then(function (result) {
|
||||||
|
return _.map(result, function (hostgroup) {
|
||||||
|
return {
|
||||||
|
text: hostgroup.name,
|
||||||
|
expandable: false
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Return empty object
|
// Return empty object
|
||||||
else {
|
else {
|
||||||
@@ -479,17 +509,7 @@ function (angular, _, kbn) {
|
|||||||
return object.applicationid;
|
return object.applicationid;
|
||||||
}), 'applicationid');
|
}), 'applicationid');
|
||||||
|
|
||||||
return self.performItemSuggestQuery(hostids, applicationids, groupids)
|
return self.performItemSuggestQuery(hostids, applicationids, groupids);
|
||||||
.then(function (result) {
|
|
||||||
return _.map(result, function (item) {
|
|
||||||
var itemname = expandItemName(item)
|
|
||||||
return {
|
|
||||||
// TODO: select only unique names
|
|
||||||
text: itemname,
|
|
||||||
expandable: false
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -516,15 +536,7 @@ function (angular, _, kbn) {
|
|||||||
return object.hostid;
|
return object.hostid;
|
||||||
}), 'hostid');
|
}), 'hostid');
|
||||||
|
|
||||||
return self.performAppSuggestQuery(hostids, groupids)
|
return self.performAppSuggestQuery(hostids, groupids);
|
||||||
.then(function (result) {
|
|
||||||
return _.map(result, function (app) {
|
|
||||||
return {
|
|
||||||
text: app.name,
|
|
||||||
expandable: false
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -537,26 +549,7 @@ function (angular, _, kbn) {
|
|||||||
return object.groupid;
|
return object.groupid;
|
||||||
}), 'groupid');
|
}), 'groupid');
|
||||||
|
|
||||||
return self.performHostSuggestQuery(groupids).then(function (result) {
|
return self.performHostSuggestQuery(groupids);
|
||||||
return _.map(result, function (host) {
|
|
||||||
return {
|
|
||||||
text: host.name,
|
|
||||||
expandable: false
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
ZabbixAPIDatasource.prototype.groupFindQuery = function(template) {
|
|
||||||
return this.performHostGroupSuggestQuery().then(function (result) {
|
|
||||||
return _.map(result, function (hostgroup) {
|
|
||||||
return {
|
|
||||||
text: hostgroup.name,
|
|
||||||
expandable: false
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user