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 2013/06/17 09:29:35 UTC

svn commit: r1493663 - in /incubator/ambari/trunk/ambari-web/app: controllers/main/admin/security.js controllers/main/admin/security/add/step3.js controllers/main/admin/security/disable.js routes/add_security.js routes/main.js views/common/modal_popup.js

Author: jaimin
Date: Mon Jun 17 07:29:35 2013
New Revision: 1493663

URL: http://svn.apache.org/r1493663
Log:
AMBARI-2398. Security Wizard: Misc fixes for re-running the wizard, delay and pop-up.

Modified:
    incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security.js
    incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js
    incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js
    incubator/ambari/trunk/ambari-web/app/routes/add_security.js
    incubator/ambari/trunk/ambari-web/app/routes/main.js
    incubator/ambari/trunk/ambari-web/app/views/common/modal_popup.js

Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security.js?rev=1493663&r1=1493662&r2=1493663&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security.js Mon Jun 17 07:29:35 2013
@@ -108,9 +108,9 @@ App.MainAdminSecurityController = Em.Con
       this.set('securityEnabled', true);
     }
     else {
-      this.loadUsers(configs);
       this.set('securityEnabled', false);
     }
+    this.loadUsers(configs);
     this.set('dataIsLoaded', true);
   },
 

Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js?rev=1493663&r1=1493662&r2=1493663&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js Mon Jun 17 07:29:35 2013
@@ -58,13 +58,10 @@ App.MainAdminSecurityAddStep3Controller 
 
   loadStep: function () {
     this.set('secureMapping', require('data/secure_mapping').slice(0));
+    this.clearStep();
     var stages = App.db.getSecurityDeployStages();
     this.prepareSecureConfigs();
-    this.clearStep();
-    if (stages === undefined) {
-      this.loadStages();
-      this.addInfoToStages();
-    } else {
+    if (stages && stages.length > 0) {
       stages.forEach(function (_stage, index) {
         stages[index] = App.Poll.create(_stage);
       }, this);
@@ -72,14 +69,16 @@ App.MainAdminSecurityAddStep3Controller 
         var failedStages = stages.filterProperty('isError', true);
         failedStages.setEach('isError', false);
         failedStages.setEach('isStarted', false);
-        failedStages.setEach('isCompleted', false)
+        failedStages.setEach('isCompleted', false);
       } else if (stages.filterProperty('isStarted', true).someProperty('isCompleted', false)) {
         var runningStage = stages.filterProperty('isStarted', true).findProperty('isCompleted', false);
         runningStage.set('isStarted', false);
       }
       this.get('stages').pushObjects(stages);
+    } else {
+      this.loadStages();
+      this.addInfoToStages();
     }
-
     this.moveToNextStage();
   },
 
@@ -90,6 +89,8 @@ App.MainAdminSecurityAddStep3Controller 
         this.set('isBackBtnDisabled', false);
         App.router.get('addSecurityController').setStepsEnable();
       }
+    } else {
+      this.set('isSubmitDisabled', true);
     }
   }.observes('stages.@each.isCompleted'),
 
@@ -275,6 +276,7 @@ App.MainAdminSecurityAddStep3Controller 
   loadGlobals: function () {
     var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
     this.set('globalProperties', globals);
+    this.loadStaticGlobal(); //Hack for properties which are declared in config_properties.js and not able to retrieve values declared in secure_properties.js
     this.loadUsersToGlobal();
   },
 
@@ -287,6 +289,23 @@ App.MainAdminSecurityAddStep3Controller 
     }, this);
   },
 
+  loadStaticGlobal: function() {
+    var globalProperties = this.get('globalProperties');
+    this.get('globalProperties').forEach(function(_property){
+      switch (_property.name) {
+        case 'security_enabled':
+          _property.value = 'true';
+          break;
+        case 'dfs_datanode_address':
+          _property.value = '1019';
+          break;
+        case 'dfs_datanode_http_address':
+          _property.value = '1022';
+          break;
+      }
+    },this);
+  },
+
   loadUsersFromServer: function () {
     if (App.testMode) {
       var serviceUsers = this.get('serviceUsers');
@@ -430,7 +449,6 @@ App.MainAdminSecurityAddStep3Controller 
         this.get('globalProperties').forEach(function (_globalProperty) {
           _serviceConfigTags.configs[_globalProperty.name] = _globalProperty.value;
         }, this);
-        _serviceConfigTags.configs.security_enabled = 'true';
       }
       else {
         this.get('configs').filterProperty('id', 'site property').filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
@@ -458,11 +476,5 @@ App.MainAdminSecurityAddStep3Controller 
       stages.pushObject(stage);
     }, this);
     App.db.setSecurityDeployStages(stages);
-    App.clusterStatus.setClusterStatus({
-      clusterName: this.get('clusterName'),
-      clusterState: 'ADD_SECURITY_STEP_3',
-      wizardControllerName: App.router.get('addSecurityController.name'),
-      localdb: App.db.data
-    });
   }.observes('stages.@each.requestId', 'stages.@each.isStarted', 'stages.@each.isCompleted')
 });

Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js?rev=1493663&r1=1493662&r2=1493663&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js Mon Jun 17 07:29:35 2013
@@ -41,12 +41,10 @@ App.MainAdminSecurityDisableController =
   },
 
   loadStep: function () {
-    var stages = App.db.getSecurityDeployStages();
+
     this.clearStep();
-    if (stages === undefined) {
-      this.loadStages();
-      this.addInfoToStages();
-    } else {
+    var stages = App.db.getSecurityDeployStages();
+    if (stages && stages.length > 0) {
       stages.forEach(function (_stage, index) {
         stages[index] = App.Poll.create(_stage);
       }, this);
@@ -60,6 +58,9 @@ App.MainAdminSecurityDisableController =
         runningStage.set('isStarted', false);
       }
       this.get('stages').pushObjects(stages);
+    } else {
+      this.loadStages();
+      this.addInfoToStages();
     }
     this.loadSecureServices();
     this.moveToNextStage();
@@ -85,6 +86,8 @@ App.MainAdminSecurityDisableController =
   enableSubmit: function () {
     if (this.get('stages').someProperty('isError', true) || this.get('stages').everyProperty('isSuccess', true)) {
       this.set('isSubmitDisabled', false);
+    } else {
+      this.set('isSubmitDisabled', true);
     }
   }.observes('stages.@each.isCompleted'),
 
@@ -201,7 +204,7 @@ App.MainAdminSecurityDisableController =
     //prepare tags to fetch all configuration for a service
     this.get('secureServices').forEach(function (_secureService) {
       this.setServiceTagNames(_secureService, jsonData.Clusters.desired_configs);
-    },this);
+    }, this);
     this.getAllConfigurations();
   },
 
@@ -364,12 +367,6 @@ App.MainAdminSecurityDisableController =
       stages.pushObject(stage);
     }, this);
     App.db.setSecurityDeployStages(stages);
-    App.clusterStatus.setClusterStatus({
-      clusterName: this.get('clusterName'),
-      clusterState: 'DISABLE_SECURITY',
-      wizardControllerName: this.get('name'),
-      localdb: App.db.data
-    });
   }.observes('stages.@each.requestId', 'stages.@each.isStarted', 'stages.@each.isCompleted')
 
 });

Modified: incubator/ambari/trunk/ambari-web/app/routes/add_security.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/routes/add_security.js?rev=1493663&r1=1493662&r2=1493663&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/routes/add_security.js (original)
+++ incubator/ambari/trunk/ambari-web/app/routes/add_security.js Mon Jun 17 07:29:35 2013
@@ -41,22 +41,32 @@ module.exports = Em.Route.extend({
             onClose: function () {
               var self = this;
               if (router.get('addSecurityController.currentStep') == 3) {
+                var controller = router.get('mainAdminSecurityAddStep3Controller');
+                if (!controller.get('isSubmitDisabled')) {
+                  self.proceedOnClose();
+                  return;
+                }
                 var applyingConfigStage = router.get('mainAdminSecurityAddStep3Controller.stages').findProperty('stage', 'stage3');
-                if (applyingConfigStage && !applyingConfigStage.get('isCompleted')) {
-                  if (applyingConfigStage.get('isStarted')) {
-                    App.showAlertPopup(Em.I18n.t('admin.security.applying.config.header'), Em.I18n.t('admin.security.applying.config.body'));
-                    return;
+                if (applyingConfigStage) {
+                  if (!applyingConfigStage.get('isCompleted')) {
+                    if (applyingConfigStage.get('isStarted')) {
+                      App.showAlertPopup(Em.I18n.t('admin.security.applying.config.header'), Em.I18n.t('admin.security.applying.config.body'));
+                      return;
+                    } else {
+                      App.showConfirmationPopup(function () {
+                        self.proceedOnClose();
+                      }, Em.I18n.t('admin.addSecurity.enable.onClose'));
+                      return;
+                    }
                   } else {
                     App.showConfirmationPopup(function () {
-                      self.proceedOnClose();
-                    }, Em.I18n.t('admin.addSecurity.enable.onClose'));
+                        this.hide();
+                      }, Em.I18n.t('admin.addSecurity.enable.after.stage2.onClose'),
+                      function () {
+                        self.proceedOnClose();
+                      });
                     return;
                   }
-                } else {
-                  App.showConfirmationPopup(function () {
-                    self.proceedOnClose();
-                  }, Em.I18n.t('admin.addSecurity.enable.after.stage2.onClose'));
-                  return;
                 }
               }
               self.proceedOnClose();

Modified: incubator/ambari/trunk/ambari-web/app/routes/main.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/routes/main.js?rev=1493663&r1=1493662&r2=1493663&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/routes/main.js (original)
+++ incubator/ambari/trunk/ambari-web/app/routes/main.js Mon Jun 17 07:29:35 2013
@@ -709,7 +709,12 @@ module.exports = Em.Route.extend({
 
                 onClose: function () {
                   var self = this;
-                  var applyingConfigStage = router.get('mainAdminSecurityDisableController.stages').findProperty('stage', 'stage3');
+                  var controller = router.get('mainAdminSecurityDisableController');
+                  if (!controller.get('isSubmitDisabled')) {
+                    self.proceedOnClose();
+                    return;
+                  }
+                  var applyingConfigStage = controller.get('stages').findProperty('stage', 'stage3');
                   if (applyingConfigStage && !applyingConfigStage.get('isCompleted')) {
                     if (applyingConfigStage.get('isStarted')) {
                       App.showAlertPopup(Em.I18n.t('admin.security.applying.config.header'), Em.I18n.t('admin.security.applying.config.body'));
@@ -720,9 +725,9 @@ module.exports = Em.Route.extend({
                       }, Em.I18n.t('admin.addSecurity.disable.onClose'));
                       return;
                     }
+                  } else {
+                    self.proceedOnClose();
                   }
-                  self.proceedOnClose();
-
                 },
                 proceedOnClose: function () {
                   router.get('mainAdminSecurityDisableController').clearStep();

Modified: incubator/ambari/trunk/ambari-web/app/views/common/modal_popup.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/views/common/modal_popup.js?rev=1493663&r1=1493662&r2=1493663&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/views/common/modal_popup.js (original)
+++ incubator/ambari/trunk/ambari-web/app/views/common/modal_popup.js Mon Jun 17 07:29:35 2013
@@ -56,19 +56,19 @@ App.ModalPopup = Ember.View.extend({
   secondary: Em.I18n.t('common.cancel'),
   autoHeight: true,
 
-  onPrimary: function() {
+  onPrimary: function () {
     this.hide();
   },
 
-  onSecondary: function() {
+  onSecondary: function () {
     this.hide();
   },
 
-  onClose: function() {
+  onClose: function () {
     this.hide();
   },
 
-  hide: function() {
+  hide: function () {
     this.destroy();
   },
 
@@ -79,31 +79,31 @@ App.ModalPopup = Ember.View.extend({
    */
   showCloseButton: true,
 
-  didInsertElement: function(){
-    if(this.autoHeight){
+  didInsertElement: function () {
+    if (this.autoHeight) {
       var block = this.$().find('#modal > .modal-body').first();
       block.css('max-height', $(window).height() - block.offset().top - 300 + $(window).scrollTop()); // fix popup height
     }
   },
 
-  fitHeight: function(){
+  fitHeight: function () {
     var popup = this.$().find('#modal');
     var block = this.$().find('#modal > .modal-body');
     var wh = $(window).height();
 
     var top = wh * .05;
     popup.css({
-      'top' : top + 'px',
-      'marginTop' : 0
+      'top': top + 'px',
+      'marginTop': 0
     });
 
-    block.css('max-height', $(window).height()- top * 2 - 100);
+    block.css('max-height', $(window).height() - top * 2 - 100);
   }
 });
 
 App.ModalPopup.reopenClass({
 
-  show: function(options) {
+  show: function (options) {
     var popup = this.create(options);
     popup.appendTo('#wrapper');
     return popup;
@@ -111,7 +111,7 @@ App.ModalPopup.reopenClass({
 
 })
 
-App.showReloadPopup = function(){
+App.showReloadPopup = function () {
   return App.ModalPopup.show({
     primary: null,
     secondary: null,
@@ -129,7 +129,7 @@ App.showReloadPopup = function(){
  * @param {String} body - additional text constant. Will be placed in the popup-body
  * @return {*}
  */
-App.showConfirmationPopup = function(primary, body, template) {
+App.showConfirmationPopup = function (primary, body, secondary) {
   if (!primary) {
     return false;
   }
@@ -138,12 +138,18 @@ App.showConfirmationPopup = function(pri
     secondary: Em.I18n.t('common.cancel'),
     header: Em.I18n.t('popup.confirmation.commonHeader'),
     body: body || Em.I18n.t('question.sure'),
-    onPrimary: function() {
+    onPrimary: function () {
       this.hide();
       primary();
+    },
+    onSecondary: function () {
+      this.hide();
+      if (secondary) {
+        secondary();
+      }
     }
   });
-}
+};
 
 /**
  * Show alert popup
@@ -153,13 +159,13 @@ App.showConfirmationPopup = function(pri
  * @param {Function} primary - function to call upon clicking the OK button
  * @return {*}
  */
-App.showAlertPopup = function(header, body, primary) {
+App.showAlertPopup = function (header, body, primary) {
   return App.ModalPopup.show({
     primary: Em.I18n.t('ok'),
     secondary: null,
     header: header,
     body: body,
-    onPrimary: function() {
+    onPrimary: function () {
       this.hide();
       if (primary) {
         primary();