Browse Source

AMBARI-9290 Delete repo version not available when there is no cluster. (ababiichuk)

aBabiichuk 10 years ago
parent
commit
7a75ff614c

+ 5 - 1
ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsEditCtrl.js

@@ -158,7 +158,11 @@ angular.module('ambariAdminConsole')
   };
 
   $scope.fetchRepoClusterStatus = function () {
-    var clusterName = $scope.clusters[0].Clusters.cluster_name; // only support one cluster at the moment
+    var clusterName = ($scope.clusters && $scope.clusters.length > 0)
+      ? $scope.clusters[0].Clusters.cluster_name : null; // only support one cluster at the moment
+    if (!clusterName) {
+      return null;
+    }
     return Cluster.getRepoVersionStatus(clusterName, $scope.id).then(function (response) {
       $scope.repoStatus = response.status;
     });

+ 16 - 12
ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsListCtrl.js

@@ -65,17 +65,19 @@ angular.module('ambariAdminConsole')
   };
 
   $scope.fetchRepoClusterStatus = function () {
-    var clusterName = $scope.clusters[0].Clusters.cluster_name; // only support one cluster at the moment
-    angular.forEach($scope.repos, function (repo) {
-      Cluster.getRepoVersionStatus(clusterName, repo.id).then(function (response) {
-        repo.status = response.status;
-        repo.totalHosts = response.totalHosts;
-        repo.currentHosts = response.currentHosts;
-        repo.installedHosts = response.installedHosts;
-        repo.stackVersionId = response.stackVersionId;
-        repo.cluster = (repo.status == 'current' || repo.status == 'installed')? clusterName : '';
+    var clusterName = ($scope.clusters && $scope.clusters.length > 0) ? $scope.clusters[0].Clusters.cluster_name : null; // only support one cluster at the moment
+    if (clusterName) {
+      angular.forEach($scope.repos, function (repo) {
+        Cluster.getRepoVersionStatus(clusterName, repo.id).then(function (response) {
+          repo.status = response.status;
+          repo.totalHosts = response.totalHosts;
+          repo.currentHosts = response.currentHosts;
+          repo.installedHosts = response.installedHosts;
+          repo.stackVersionId = response.stackVersionId;
+          repo.cluster = (repo.status == 'current' || repo.status == 'installed')? clusterName : '';
+        });
       });
-    });
+    }
   };
 
   $scope.fetchRepos = function () {
@@ -105,8 +107,10 @@ angular.module('ambariAdminConsole')
 
   $scope.fetchClusters = function () {
     return Cluster.getAllClusters().then(function (clusters) {
-      $scope.clusters = clusters;
-      $scope.fillClusters(clusters);
+      if (clusters && clusters.length > 0) {
+        $scope.clusters = clusters;
+        $scope.fillClusters(clusters);
+      }
     });
   };