Improve app search in query editor - return only unique app names and search by app name in multiple hosts.

This commit is contained in:
Alexander Zobnin
2015-05-31 09:25:07 +03:00
parent 4ab1fb4568
commit c71ad03cf5

View File

@@ -159,12 +159,15 @@ function (angular, _) {
var hostid = $scope.target.host ? $scope.target.host.hostid : null;
var groupid = $scope.target.hostGroup ? $scope.target.hostGroup.groupid: null;
$scope.datasource.performAppSuggestQuery(hostid, groupid).then(function (series) {
$scope.metric.applicationList = $scope.metric.applicationList.concat(series);
var apps = _.map(_.uniq(_.map(series, 'name')), function (appname) {
return {name: appname};
});
$scope.metric.applicationList = $scope.metric.applicationList.concat(apps);
if ($scope.target.application) {
$scope.target.application = $scope.metric.applicationList.filter(function (item, index, array) {
$scope.target.application = $scope.metric.applicationList.filter(function (app) {
// Find selected application in metric.hostList
return item.name == $scope.target.application.name;
return app.name == $scope.target.application.name;
}).pop();
}
});
@@ -180,8 +183,11 @@ function (angular, _) {
var groupids = $scope.target.hostGroup ? $scope.target.hostGroup.groupid: null;
var hostids = $scope.target.host ? $scope.target.host.hostid : null;
var applicationids = $scope.target.application ? $scope.target.application.applicationid : null;
var application = $scope.target.application || null;
// Get application ids from name
$scope.datasource.findZabbixApp(application).then(function (result) {
var applicationids = _.map(result, 'applicationid');
$scope.datasource.performItemSuggestQuery(hostids, applicationids, groupids).then(function (series) {
$scope.metric.itemList = $scope.metric.itemList.concat(series);
@@ -198,6 +204,7 @@ function (angular, _) {
}).pop();
}
});
});
};