createCluster.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. globalYui.one('#createClusterSubmitButtonId').on('click',function (e) {
  2. var createClusterData = {
  3. "clusterName" : globalYui.Lang.trim(globalYui.one("#clusterNameId").get('value')),
  4. };
  5. globalYui.log("Cluster Name: "+globalYui.Lang.dump(createClusterData));
  6. if (createClusterData.clusterName == '') {
  7. globalYui.one("#clusterNameId").addClass('formInputError');
  8. setFormStatus("Cluster name cannot be empty", true);
  9. globalYui.one("#clusterNameId").focus();
  10. return;
  11. }
  12. clearFormStatus();
  13. globalYui.one("#clusterNameId").removeClass('formInputError');
  14. globalYui.io("../php/frontend/createCluster.php", {
  15. method: 'POST',
  16. data: globalYui.JSON.stringify(createClusterData),
  17. timeout : 10000,
  18. on: {
  19. start: function (x,o) {
  20. showLoadingImg();
  21. },
  22. success: function (x,o) {
  23. hideLoadingImg();
  24. globalYui.log("RAW JSON DATA: " + o.responseText);
  25. // Process the JSON data returned from the server
  26. try {
  27. createClusterResponseJson = globalYui.JSON.parse(o.responseText);
  28. }
  29. catch (e) {
  30. alert("JSON Parse failed!");
  31. return;
  32. }
  33. globalYui.log("PARSED DATA: " + globalYui.Lang.dump(createClusterResponseJson));
  34. if (createClusterResponseJson.result != 0) {
  35. // Error!
  36. alert("Got error!" + createClusterResponseJson.error);
  37. return;
  38. }
  39. createClusterResponseJson = createClusterResponseJson.response;
  40. /* Done with this stage, transition to the next. */
  41. // Add freshInstall tag
  42. createClusterResponseJson.freshInstall = true;
  43. transitionToNextStage( "#createClusterCoreDivId", createClusterData,
  44. "#addNodesCoreDivId", createClusterResponseJson, InstallationWizard.AddNodes.render );
  45. },
  46. failure: function (x,o) {
  47. hideLoadingImg();
  48. alert("Async call failed!");
  49. }
  50. }
  51. });
  52. });
  53. /* Signify that the containing application is ready for business. */
  54. hideLoadingImg();
  55. /* At the end of the installation wizard, we hide
  56. * #installationWizardProgressBarDivId, so make sure we explicitly show
  57. * it at the beginning, to ensure we work correctly when user flow
  58. * (potentially) cycles back here.
  59. */
  60. globalYui.one('#installationWizardProgressBarDivId').setStyle('display', 'block');