diff --git a/zabbix/queryCtrl.js b/zabbix/queryCtrl.js index e367f4937..e64432c2a 100644 --- a/zabbix/queryCtrl.js +++ b/zabbix/queryCtrl.js @@ -65,17 +65,18 @@ function (angular, _) { // Call when host selected $scope.selectHost = function() { + if ($scope.target.host) { + // Update item list + if ($scope.target.application) { + $scope.updateItemList($scope.target.host.hostid, $scope.target.application.applicationid); + } else { + $scope.updateItemList($scope.target.host.hostid, null); + } - // Update item list - if ($scope.target.application) { - $scope.updateItemList($scope.target.host.hostid, $scope.target.application.applicationid); - } else { - $scope.updateItemList($scope.target.host.hostid, null); + // Update application list + $scope.updateAppList($scope.target.host.hostid); } - // Update application list - $scope.updateAppList($scope.target.host.hostid); - $scope.target.errors = validateTarget($scope.target); if (!_.isEqual($scope.oldTarget, $scope.target) && _.isEmpty($scope.target.errors)) { $scope.oldTarget = angular.copy($scope.target);