ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject [2/2] git commit: AMBARI-6406 Move Wizard: assign master step next button is not disabled, when host input has error. (atkach)
Date Mon, 07 Jul 2014 18:44:14 GMT
AMBARI-6406 Move Wizard: assign master step next button is not disabled, when host input has
error. (atkach)


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

Branch: refs/heads/trunk
Commit: e3de7b3b684af470fb8f5b08279ba28d4f979a48
Parents: e9d8264
Author: atkach <atkach@hortonworks.com>
Authored: Mon Jul 7 21:26:14 2014 +0300
Committer: atkach <atkach@hortonworks.com>
Committed: Mon Jul 7 21:44:05 2014 +0300

----------------------------------------------------------------------
 .../main/service/reassign/step2_controller.js   | 26 +++++++++++++++
 .../app/controllers/wizard/step5_controller.js  | 35 ++------------------
 2 files changed, 29 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e3de7b3b/ambari-web/app/controllers/main/service/reassign/step2_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/reassign/step2_controller.js b/ambari-web/app/controllers/main/service/reassign/step2_controller.js
index 35e205c..8964c1b 100644
--- a/ambari-web/app/controllers/main/service/reassign/step2_controller.js
+++ b/ambari-web/app/controllers/main/service/reassign/step2_controller.js
@@ -82,6 +82,32 @@ App.ReassignMasterWizardStep2Controller = App.WizardStep5Controller.extend({
       }
       item.set("availableHosts", preparedAvailableHosts.sortProperty('host_name'));
     }, this);
+  },
+  /**
+   * Determines if hostName is valid for component:
+   * <ul>
+   *  <li>host should have only one component with <code>componentName</code></li>
+   * </ul>
+   * @param {string} componentName
+   * @param {string} selectedHost
+   * @returns {boolean} true - valid, false - invalid
+   * @method isHostNameValid
+   */
+  isHostNameValid: function (componentName, selectedHost) {
+    var isValid = this._super(componentName, selectedHost);
+
+    if (isValid) {
+      var reassigned = 0;
+      var existedComponents = App.HostComponent.find().filterProperty('componentName', this.get('content.reassign.component_name')).mapProperty('hostName');
+      var newComponents = this.get('servicesMasters').mapProperty('selectedHost');
+      existedComponents.forEach(function (host) {
+        if (!newComponents.contains(host)) {
+          reassigned++;
+        }
+      }, this);
+      isValid = !(reassigned !== 1);
+    }
+    return isValid;
   }
 });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e3de7b3b/ambari-web/app/controllers/wizard/step5_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step5_controller.js b/ambari-web/app/controllers/wizard/step5_controller.js
index 6bcc467..f004cb0 100644
--- a/ambari-web/app/controllers/wizard/step5_controller.js
+++ b/ambari-web/app/controllers/wizard/step5_controller.js
@@ -185,41 +185,12 @@ App.WizardStep5Controller = Em.Controller.extend({
    * @metohd getIsSubmitDisabled
    */
   getIsSubmitDisabled: function () {
-    if (!this.get('isReassignWizard')) {
-      this.set('submitDisabled', this.get('servicesMasters').someProperty('isHostNameValid',
false));
-    }
-    else {
-      App.ajax.send({
-        name: 'host_components.all',
-        sender: this,
-        data: {
-          clusterName: App.get('clusterName')
-        },
-        success: 'getIsSubmitDisabledSuccessCallBack'
-      });
-    }
+    var isSubmitDisabled = this.get('servicesMasters').someProperty('isHostNameValid', false);
+    this.set('submitDisabled', isSubmitDisabled);
+    return isSubmitDisabled;
   }.observes('servicesMasters.@each.selectedHost', 'servicesMasters.@each.isHostNameValid'),
 
   /**
-   * Success callback for getIsSubmitDisabled method
-   * Set true for Reassign Master Wizard and if more than one master component was reassigned.
-   * For installer, addHost and addService verify that provided host names for components
are valid
-   * @param {object} response
-   * @method getIsSubmitDisabledSuccessCallBack
-   */
-  getIsSubmitDisabledSuccessCallBack: function (response) {
-    var reassigned = 0;
-    var arr1 = response.items.mapProperty('HostRoles').filterProperty('component_name', this.get('content.reassign.component_name')).mapProperty('host_name');
-    var arr2 = this.get('servicesMasters').mapProperty('selectedHost');
-    arr1.forEach(function (host) {
-      if (!arr2.contains(host)) {
-        reassigned++;
-      }
-    }, this);
-    this.set('submitDisabled', reassigned !== 1);
-  },
-
-  /**
    * Clear controller data (hosts, masters etc)
    * @method clearStep
    */


Mime
View raw message