Fixed update of host list and item list when host or item not selected.

This commit is contained in:
Alexander Zobnin
2015-05-08 22:55:05 +03:00
parent 4b44329230
commit 6ea38462f6

View File

@@ -135,7 +135,6 @@ function (angular, _) {
$scope.metric.hostGroupList = series; $scope.metric.hostGroupList = series;
if ($scope.target.hostGroup) { if ($scope.target.hostGroup) {
$scope.target.hostGroup = $scope.metric.hostGroupList.filter(function (item, index, array) { $scope.target.hostGroup = $scope.metric.hostGroupList.filter(function (item, index, array) {
// Find selected host in metric.hostList // Find selected host in metric.hostList
return (item.groupid == $scope.target.hostGroup.groupid); return (item.groupid == $scope.target.hostGroup.groupid);
}).pop(); }).pop();
@@ -150,11 +149,13 @@ function (angular, _) {
$scope.updateHostList = function(groupid) { $scope.updateHostList = function(groupid) {
$scope.datasource.performHostSuggestQuery(groupid).then(function (series) { $scope.datasource.performHostSuggestQuery(groupid).then(function (series) {
$scope.metric.hostList = series; $scope.metric.hostList = series;
$scope.target.host = $scope.metric.hostList.filter(function (item, index, array) {
// Find selected host in metric.hostList if ($scope.target.host) {
return (item.hostid == $scope.target.host.hostid); $scope.target.host = $scope.metric.hostList.filter(function (item, index, array) {
}).pop(); // Find selected host in metric.hostList
return (item.hostid == $scope.target.host.hostid);
}).pop();
}
}); });
}; };
@@ -167,7 +168,6 @@ function (angular, _) {
$scope.metric.applicationList = series; $scope.metric.applicationList = series;
if ($scope.target.application) { if ($scope.target.application) {
$scope.target.application = $scope.metric.applicationList.filter(function (item, index, array) { $scope.target.application = $scope.metric.applicationList.filter(function (item, index, array) {
// Find selected application in metric.hostList // Find selected application in metric.hostList
return (item.applicationid == $scope.target.application.applicationid); return (item.applicationid == $scope.target.application.applicationid);
}).pop(); }).pop();
@@ -192,11 +192,12 @@ function (angular, _) {
item.expandedName = expandItemName(item); item.expandedName = expandItemName(item);
} }
}); });
$scope.target.item = $scope.metric.itemList.filter(function (item, index, array) { if ($scope.target.item) {
$scope.target.item = $scope.metric.itemList.filter(function (item, index, array) {
// Find selected item in metric.hostList // Find selected item in metric.hostList
return (item.itemid == $scope.target.item.itemid); return (item.itemid == $scope.target.item.itemid);
}).pop(); }).pop();
}
}); });
} else { } else {
$scope.metric.itemList = []; $scope.metric.itemList = [];