You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ak...@apache.org on 2016/02/03 21:14:19 UTC

ambari git commit: AMBARI-14904. Disable base URL inputs for all OS except one that the cluster is running (akovalenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk 424cca6c3 -> 5833aabd8


AMBARI-14904. Disable base URL inputs for all OS except one that the cluster is running (akovalenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/5833aabd
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/5833aabd
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/5833aabd

Branch: refs/heads/trunk
Commit: 5833aabd811f726d328d5b2ddd565e45cbd48a15
Parents: 424cca6
Author: Aleksandr Kovalenko <ak...@hortonworks.com>
Authored: Wed Feb 3 20:13:51 2016 +0200
Committer: Aleksandr Kovalenko <ak...@hortonworks.com>
Committed: Wed Feb 3 22:13:43 2016 +0200

----------------------------------------------------------------------
 .../stackVersions/StackVersionsCreateCtrl.js      | 18 +++++++++++++++---
 .../stackVersions/StackVersionsEditCtrl.js        | 16 ++++++++++++++--
 .../ui/admin-web/app/scripts/services/Cluster.js  | 15 ++++++++++++++-
 .../ui/admin-web/app/scripts/services/Stack.js    |  2 +-
 .../app/views/stackVersions/stackVersionPage.html |  4 ++--
 5 files changed, 46 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5833aabd/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js
index a817d88..fc4bee9 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js
@@ -18,7 +18,7 @@
 'use strict';
 
 angular.module('ambariAdminConsole')
-.controller('StackVersionsCreateCtrl', ['$scope', 'Stack', '$routeParams', '$location', 'Alert', '$translate', function($scope, Stack, $routeParams, $location, Alert, $translate) {
+.controller('StackVersionsCreateCtrl', ['$scope', 'Stack', '$routeParams', '$location', 'Alert', '$translate', 'Cluster', function($scope, Stack, $routeParams, $location, Alert, $translate, Cluster) {
   var $t = $translate.instant;
   $scope.createController = true;
   $scope.osList = [];
@@ -43,7 +43,9 @@ angular.module('ambariAdminConsole')
       });
       $scope.upgradeStack.options = versions;
       $scope.upgradeStack.selected = versions[versions.length - 1];
-      $scope.afterStackVersionChange();
+      $scope.afterStackVersionChange().then(function(){
+        $scope.disableUnusedOS();
+      });
     })
     .catch(function (data) {
       Alert.error($t('versions.alerts.filterListError'), data.message);
@@ -71,7 +73,7 @@ angular.module('ambariAdminConsole')
   };
 
   $scope.afterStackVersionChange = function () {
-    Stack.getSupportedOSList($scope.upgradeStack.selected.stack_name, $scope.upgradeStack.selected.stack_version)
+    return Stack.getSupportedOSList($scope.upgradeStack.selected.stack_name, $scope.upgradeStack.selected.stack_version)
     .then(function (data) {
       var operatingSystems = data.operating_systems;
         $scope.osList = operatingSystems.map(function (os) {
@@ -87,6 +89,16 @@ angular.module('ambariAdminConsole')
     });
   };
 
+  $scope.disableUnusedOS = function() {
+    Cluster.getClusterOS().then(function(usedOS){
+      angular.forEach($scope.osList, function (os) {
+        if (os.OperatingSystems.os_type !== usedOS) {
+          os.disabled = true;
+        }
+      });
+    });
+  };
+
   $scope.updateCurrentVersionInput = function () {
     $scope.currentVersionInput = $scope.upgradeStack.selected.displayName + '.' + angular.element('[name="version"]')[0].value;
   };

http://git-wip-us.apache.org/repos/asf/ambari/blob/5833aabd/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsEditCtrl.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsEditCtrl.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsEditCtrl.js
index 0763726..39a6700 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsEditCtrl.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsEditCtrl.js
@@ -63,7 +63,9 @@ angular.module('ambariAdminConsole')
       } else {
         $scope.deleteEnabled = $scope.isDeletable();
       }
-      $scope.addMissingOSList();
+      $scope.addMissingOSList().then(function(){
+        $scope.disableUnusedOS();
+      });
     });
   };
 
@@ -72,7 +74,7 @@ angular.module('ambariAdminConsole')
   };
 
   $scope.addMissingOSList = function() {
-    Stack.getSupportedOSList($scope.stackName, $scope.stackVersion)
+    return Stack.getSupportedOSList($scope.stackName, $scope.stackVersion)
     .then(function (data) {
       var existingOSHash = {};
       angular.forEach($scope.osList, function (os) {
@@ -109,6 +111,16 @@ angular.module('ambariAdminConsole')
     });
   };
 
+  $scope.disableUnusedOS = function() {
+    Cluster.getClusterOS().then(function(usedOS){
+      angular.forEach($scope.osList, function (os) {
+        if (os.OperatingSystems.os_type !== usedOS) {
+          os.disabled = true;
+        }
+      });
+    });
+  };
+
   $scope.defaulfOSRepos = {};
 
   $scope.save = function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/5833aabd/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Cluster.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Cluster.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Cluster.js
index a758c88..af77596 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Cluster.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Cluster.js
@@ -60,9 +60,22 @@ angular.module('ambariAdminConsole')
 
       return deferred.promise;
     },
+    getClusterOS: function() {
+      var deferred = $q.defer();
+
+      $http.get(Settings.baseUrl + '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/properties/server.os_family&minimal_response=true', {mock: 'redhat6'})
+      .then(function(data) {
+        deferred.resolve(data.data.RootServiceComponents.properties['server.os_family']);
+      })
+      .catch(function(data) {
+        deferred.reject(data);
+      });
+
+      return deferred.promise;
+    },
     getAmbariTimeout: function() {
       var deferred = $q.defer();
-      var url = '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/properties/user.inactivity.timeout.default'
+      var url = '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/properties/user.inactivity.timeout.default';
       $http.get(Settings.baseUrl + url)
       .then(function(data) {
         var properties = data.data.RootServiceComponents.properties;

http://git-wip-us.apache.org/repos/asf/ambari/blob/5833aabd/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Stack.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Stack.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Stack.js
index ffed3cc..4c55967 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Stack.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Stack.js
@@ -222,7 +222,7 @@ angular.module('ambariAdminConsole')
         deferred.resolve(invalidUrls);
       } else {
         osList.forEach(function (os) {
-          if (os.selected) {
+          if (os.selected && !os.disabled) {
             os.repositories.forEach(function (repo) {
               totalCalls++;
               $http.post(url + '/operating_systems/' + os.OperatingSystems.os_type + '/repositories/' + repo.Repositories.repo_id + '?validate_only=true',

http://git-wip-us.apache.org/repos/asf/ambari/blob/5833aabd/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/stackVersionPage.html
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/stackVersionPage.html b/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/stackVersionPage.html
index 9b7e032..449d743 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/stackVersionPage.html
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/stackVersionPage.html
@@ -71,7 +71,7 @@
         <div class="col-sm-2 os-checkbox">
           <div class="checkbox">
             <label>
-              <input type="checkbox" ng-model="os.selected" ng-change="toggleOSSelect()"> {{os.OperatingSystems.os_type}}
+              <input type="checkbox" ng-model="os.selected" ng-change="toggleOSSelect()" ng-disabled="os.disabled"> {{os.OperatingSystems.os_type}}
             </label>
           </div>
         </div>
@@ -79,7 +79,7 @@
           <div class="form-group {{repository.Repositories.repo_name}}" ng-class="{'has-error': repository.hasError }" ng-repeat="repository in os.repositories">
             <div class="col-sm-3"><label class="control-label">{{repository.Repositories.repo_name}}</label></div>
             <div class="col-sm-9"><input type="text" class="form-control" ng-model="repository.Repositories.base_url"
-                                         ng-change="clearError()" ng-disabled="!os.selected"></div>
+                                         ng-change="clearError()" ng-disabled="os.disabled"></div>
           </div>
         </div>
       </div>