You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ja...@apache.org on 2014/07/18 01:42:41 UTC

git commit: AMBARI-6532. Error message appears after last step of Enable security, NameNode HA and Add Service wizard. (jaimin)

Repository: ambari
Updated Branches:
  refs/heads/trunk a09565cff -> 24225fd0b


AMBARI-6532. Error message appears after last step of Enable security, NameNode HA and Add Service wizard. (jaimin)


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

Branch: refs/heads/trunk
Commit: 24225fd0bd662ffd15c3b9a103ca24342f373eec
Parents: a09565c
Author: Jaimin Jetly <ja...@hortonworks.com>
Authored: Thu Jul 17 16:42:07 2014 -0700
Committer: Jaimin Jetly <ja...@hortonworks.com>
Committed: Thu Jul 17 16:42:07 2014 -0700

----------------------------------------------------------------------
 ambari-web/app/mixins/common/userPref.js        |  2 +-
 ambari-web/app/models/cluster_states.js         | 36 +++++++++-----------
 ambari-web/app/routes/add_security.js           |  4 +--
 ambari-web/app/routes/add_service_routes.js     | 13 +++----
 .../app/routes/high_availability_routes.js      |  5 +--
 5 files changed, 24 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/24225fd0/ambari-web/app/mixins/common/userPref.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/userPref.js b/ambari-web/app/mixins/common/userPref.js
index 048172c..90a115d 100644
--- a/ambari-web/app/mixins/common/userPref.js
+++ b/ambari-web/app/mixins/common/userPref.js
@@ -83,7 +83,7 @@ App.UserPref = Em.Mixin.create({
     if(!App.get('isAdmin')) return;
     var keyValuePair = {};
     keyValuePair[key] = JSON.stringify(value);
-    App.ajax.send({
+    return App.ajax.send({
       'name': 'settings.post.user_pref',
       'sender': this,
       'beforeSend': 'postUserPrefBeforeSend',

http://git-wip-us.apache.org/repos/asf/ambari/blob/24225fd0/ambari-web/app/models/cluster_states.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/cluster_states.js b/ambari-web/app/models/cluster_states.js
index f9685e8..3aede29 100644
--- a/ambari-web/app/models/cluster_states.js
+++ b/ambari-web/app/models/cluster_states.js
@@ -178,14 +178,21 @@ App.clusterStatus = Em.Object.create(App.UserPref, {
   },
 
   /**
-   * update cluster status and post it on server
+   * update cluster status and post it on server.
+   * This function should always be called by admin user
    * @param {object} newValue
-   * @param {object} opt - used for additional ajax request options, by default ajax used synchronous mode
+   * @param {object} opt - Can have additional params for ajax callBacks
+   *                 opt.successCallback
+   *                 opt.errorCallback
+   *                 opt.alwaysCallback
    * @method setClusterStatus
    * @return {*}
    */
   setClusterStatus: function (newValue, opt) {
     if (App.get('testMode')) return false;
+    if (!App.get('isAdmin')) {
+      Em.assert('Non-Admin user should not execute setClusterStatus function', true);
+    }
     var user = App.db.getUser();
     var login = App.db.getLoginName();
     var val = {clusterName: this.get('clusterName')};
@@ -223,24 +230,13 @@ App.clusterStatus = Em.Object.create(App.UserPref, {
         App.db.setUser(user);
         App.db.setLoginName(login);
       }
-
-      if (opt) {
-        var keyValuePair = {};
-        keyValuePair[this.get('key')] = JSON.stringify(val);
-        App.ajax.send({
-          name: 'settings.post.user_pref',
-          sender: opt.sender || this,
-          data: {
-            keyValuePair: keyValuePair
-          },
-          success: opt.success,
-          beforeSend: opt.beforeSend,
-          error: opt.error
-        });
-      }
-      else {
-        this.postUserPref(this.get('key'), val);
-      }
+      this.postUserPref(this.get('key'), val).then(function() {
+        !!opt && Em.typeOf(opt.successCallback) === 'function' && opt.successCallback();
+        !!opt && Em.typeOf(opt.alwaysCallback) === 'function' && opt.alwaysCallback();
+      },function() {
+        !!opt && Em.typeOf(opt.errorCallback) === 'function' && opt.errorCallback();
+        !!opt && Em.typeOf(opt.alwaysCallback) === 'function' && opt.alwaysCallback();
+      });
       return newValue;
     }
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/24225fd0/ambari-web/app/routes/add_security.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_security.js b/ambari-web/app/routes/add_security.js
index 8c7af03..02648a9 100644
--- a/ambari-web/app/routes/add_security.js
+++ b/ambari-web/app/routes/add_security.js
@@ -84,8 +84,7 @@ module.exports = App.WizardRoute.extend({
               App.clusterStatus.setClusterStatus({
                 clusterName: router.get('content.cluster.name'),
                 clusterState: 'DEFAULT'
-              });
-              router.transitionTo('adminSecurity.index');
+              },{alwaysCallback: function() {router.transitionTo('adminSecurity.index');location.reload();}});
             },
             didInsertElement: function () {
               this.fitHeight();
@@ -230,7 +229,6 @@ module.exports = App.WizardRoute.extend({
       var controller = router.get('mainAdminSecurityAddStep4Controller');
       if (!controller.get('isSubmitDisabled')) {
         $(context.currentTarget).parents("#modal").find(".close").trigger('click');
-        location.reload();
       }
     }
   }),

http://git-wip-us.apache.org/repos/asf/ambari/blob/24225fd0/ambari-web/app/routes/add_service_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_service_routes.js b/ambari-web/app/routes/add_service_routes.js
index 9aa6edb..2b3812a 100644
--- a/ambari-web/app/routes/add_service_routes.js
+++ b/ambari-web/app/routes/add_service_routes.js
@@ -45,18 +45,16 @@ module.exports = App.WizardRoute.extend({
             this.set('showCloseButton', false); // prevent user to click "Close" many times
             App.router.get('updateController').set('isWorking', true);
             var self = this;
+            App.router.get('updateController').updateServices(function(){
+              App.router.get('updateController').updateServiceMetric();
+            });
             App.clusterStatus.setClusterStatus({
               clusterName: App.router.get('content.cluster.name'),
               clusterState: 'DEFAULT',
               wizardControllerName: App.router.get('addServiceController.name'),
               localdb: App.db.data
-            });
-            App.router.get('updateController').updateServices(function(){
-              App.router.get('updateController').updateServiceMetric(function(){
-                self.hide();
-              });
-            });
-            App.router.transitionTo('main.services.index');
+            }, {alwaysCallback: function() {self.hide();App.router.transitionTo('main.services.index');location.reload();}});
+
           },
           didInsertElement: function(){
             this.fitHeight();
@@ -327,7 +325,6 @@ module.exports = App.WizardRoute.extend({
       addServiceController.finish();
       // We need to do recovery based on whether we are in Add Host or Installer wizard
       addServiceController.saveClusterState('DEFAULT');
-      location.reload();
     }
   }),
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/24225fd0/ambari-web/app/routes/high_availability_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/high_availability_routes.js b/ambari-web/app/routes/high_availability_routes.js
index 6854694..d3d2827 100644
--- a/ambari-web/app/routes/high_availability_routes.js
+++ b/ambari-web/app/routes/high_availability_routes.js
@@ -311,15 +311,12 @@ module.exports = App.WizardRoute.extend({
       var controller = router.get('highAvailabilityWizardController');
       controller.clearTasksData();
       controller.finish();
-      controller.get('popup').hide();
       App.clusterStatus.setClusterStatus({
         clusterName: controller.get('content.cluster.name'),
         clusterState: 'DEFAULT',
         wizardControllerName: 'highAvailabilityWizardController',
         localdb: App.db.data
-      });
-      router.transitionTo('main.index');
-      location.reload();
+      },{alwaysCallback: function() {controller.get('popup').hide();router.transitionTo('main.index');location.reload();}});
     }
   }),