You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vi...@apache.org on 2012/06/07 02:37:18 UTC

svn commit: r1347220 - in /incubator/ambari/branches/ambari-186: CHANGES.txt hmc/js/addNodes.js hmc/js/createCluster.js hmc/js/utils.js

Author: vikram
Date: Thu Jun  7 00:37:17 2012
New Revision: 1347220

URL: http://svn.apache.org/viewvc?rev=1347220&view=rev
Log:
AMBARI-416. Fix Inconsistent Validation Error Messages (Contributed by Varun)

Modified:
    incubator/ambari/branches/ambari-186/CHANGES.txt
    incubator/ambari/branches/ambari-186/hmc/js/addNodes.js
    incubator/ambari/branches/ambari-186/hmc/js/createCluster.js
    incubator/ambari/branches/ambari-186/hmc/js/utils.js

Modified: incubator/ambari/branches/ambari-186/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/CHANGES.txt?rev=1347220&r1=1347219&r2=1347220&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/CHANGES.txt (original)
+++ incubator/ambari/branches/ambari-186/CHANGES.txt Thu Jun  7 00:37:17 2012
@@ -6,6 +6,8 @@ characters wide.
 
 Release 0.1.x - unreleased
 
+  AMBARI-416. Fix Inconsistent Validation Error Messages (Varun via Vikram)
+
   AMBARI-417. Typo fix in uninstall path. (Vikram)
 
   AMBARI-415. Reset service back to original state after reconfiguration (Hitesh via Vikram)

Modified: incubator/ambari/branches/ambari-186/hmc/js/addNodes.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/js/addNodes.js?rev=1347220&r1=1347219&r2=1347220&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/js/addNodes.js (original)
+++ incubator/ambari/branches/ambari-186/hmc/js/addNodes.js Thu Jun  7 00:37:17 2012
@@ -24,6 +24,8 @@ InstallationWizard.AddNodes = {
         globalYui.one("#hmcArtifactsDownloadUrlId").set('value', addNodesRenderData.yumRepo.hdpArtifactsDownloadUrl);
         globalYui.one("#hmcGplArtifactsDownloadUrlId").set('value', addNodesRenderData.yumRepo.gplArtifactsDownloadUrl);
       }
+
+      hideLoadingImg();
     }
 };
 

Modified: incubator/ambari/branches/ambari-186/hmc/js/createCluster.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/js/createCluster.js?rev=1347220&r1=1347219&r2=1347220&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/js/createCluster.js (original)
+++ incubator/ambari/branches/ambari-186/hmc/js/createCluster.js Thu Jun  7 00:37:17 2012
@@ -1,3 +1,10 @@
+function handleCreateClusterError (errorResponse) {
+
+  globalYui.one("#clusterNameId").addClass('formInputError');
+  setFormStatus(errorResponse.error, true);
+  globalYui.one("#clusterNameId").focus();
+}
+
 globalYui.one('#createClusterSubmitButtonId').on('click',function (e) {
 
       var createClusterData = {
@@ -6,58 +13,14 @@ globalYui.one('#createClusterSubmitButto
 
       globalYui.log("Cluster Name: "+globalYui.Lang.dump(createClusterData));
 
-      if (createClusterData.clusterName == '') {
-        globalYui.one("#clusterNameId").addClass('formInputError');
-        setFormStatus("Cluster name cannot be empty", true);
-        globalYui.one("#clusterNameId").focus();
-        return;
-      }
-
+      /* Always clear the slate with each submit. */
       clearFormStatus();
       globalYui.one("#clusterNameId").removeClass('formInputError');
-      globalYui.io("../php/frontend/createCluster.php", {
 
-          method: 'POST',
-          data: globalYui.JSON.stringify(createClusterData),
-          timeout : 10000,
-          on: {
-
-            start: function (x,o) {
-              showLoadingImg();
-            },
-            success: function (x,o) {
-              hideLoadingImg();
-              globalYui.log("RAW JSON DATA: " + o.responseText);
-
-              // Process the JSON data returned from the server
-              try {
-                createClusterResponseJson = globalYui.JSON.parse(o.responseText);
-              }
-              catch (e) {
-                alert("JSON Parse failed!");
-                return;
-              }
-
-              globalYui.log("PARSED DATA: " + globalYui.Lang.dump(createClusterResponseJson));
-
-              if (createClusterResponseJson.result != 0) {
-                // Error!
-                alert("Got error!" + createClusterResponseJson.error); 
-                return;
-              }
-
-              createClusterResponseJson = createClusterResponseJson.response;
-
-              /* Done with this stage, transition to the next. */
-              transitionToNextStage( "#createClusterCoreDivId", createClusterData, 
-                  "#addNodesCoreDivId", createClusterResponseJson, InstallationWizard.AddNodes.render );
-            },
-            failure: function (x,o) {
-              hideLoadingImg();
-              alert("Async call failed!");
-            }
-          }
-      });
+      submitDataAndProgressToNextScreen(
+        '../php/frontend/createCluster.php', createClusterData, e.target, 
+        '#createClusterCoreDivId', '#addNodesCoreDivId', InstallationWizard.AddNodes.render,
+        handleCreateClusterError );
 });
 
 /* Signify that the containing application is ready for business. */

Modified: incubator/ambari/branches/ambari-186/hmc/js/utils.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/js/utils.js?rev=1347220&r1=1347219&r2=1347220&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/js/utils.js (original)
+++ incubator/ambari/branches/ambari-186/hmc/js/utils.js Thu Jun  7 00:37:17 2012
@@ -309,7 +309,6 @@ function submitDataAndProgressToNextScre
 
           if (responseJson.result != 0) {
              submitButton.set('disabled', false);
-             hideLoadingImg();
              // Error!
              globalYui.log("Got error during submit data!" + responseJson.error);
              if ( errorHandlerFunction ) {
@@ -318,6 +317,7 @@ function submitDataAndProgressToNextScre
              } else {
                alert("Got error during submit data!" + responseJson.error);
              }
+             hideLoadingImg();
              return;
            }
           responseJson = responseJson.response;