selectComponents.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. InstallationWizard.SelectServicesForNewNodes = {
  2. renderData: {},
  3. render: function (deployAddedNodesData) {
  4. InstallationWizard.SelectServicesForNewNodes.renderData = deployAddedNodesData;
  5. getServiceComponentListAndRender(clusterName);
  6. }
  7. };
  8. function getServiceComponentListAndRender(clusterName) {
  9. globalYui.io("../php/frontend/fetchClusterServices.php?clusterName=" + clusterName + "&getComponents=true", {
  10. method: 'GET',
  11. timeout: 10000,
  12. on: {
  13. success: function (x,o) {
  14. globalYui.log("RAW JSON DATA: " + o.responseText);
  15. // Process the JSON data returned from the server
  16. try {
  17. responseJson = globalYui.JSON.parse(o.responseText);
  18. }
  19. catch (e) {
  20. alert("JSON Parse failed!");
  21. return;
  22. }
  23. globalYui.log("PARSED DATA: " + globalYui.Lang.dump(responseJson));
  24. if (responseJson.result != 0) {
  25. // Error!
  26. alert("Got error during fetching services !" + responseJson.error);
  27. return;
  28. }
  29. data = responseJson.response;
  30. var divContent = '<ul>';
  31. // for each service that is enabled, find all the slave components
  32. // and display them.
  33. // At this phase, we do not worry about dependencies because these are
  34. // just slaves and each slave is independent of the other
  35. for (serviceName in data['services']) {
  36. if (data['services'][serviceName]['isEnabled'] != "0" && data['services'][serviceName]['attributes']['noDisplay'] == false) {
  37. component = data['services'][serviceName]['components'];
  38. for (componentName in component) {
  39. if (component[componentName]['isMaster'] == null &&
  40. (component[componentName]['isClient'] == null)) {
  41. continue;
  42. }
  43. if (!component[componentName]['isMaster'] &&
  44. !component[componentName]['isClient']) {
  45. divContent += '<li class="selectServicesEntry" name=try>';
  46. divContent += '<label class="checkbox" for="install' + serviceName + 'Id">'
  47. + '<input type="checkbox" disabled="disabled" checked="yes" name="' + serviceName + '" id="install' + serviceName + 'Id" value="' + component[componentName]["componentName"] + '"/>'
  48. + component[componentName]['displayName'] + '</label>'
  49. + '<div class="contextualhelp">' + component[componentName]['description'] + '</div>'
  50. + '</li>';
  51. } else {
  52. continue;
  53. }
  54. }
  55. } else {
  56. continue;
  57. }
  58. }
  59. divContent += '</ul>';
  60. globalYui.one("#selectComponentsDynamicRenderDivId").setContent(divContent);
  61. globalYui.one('#selectServicesCoreDivId').setStyle("display", "block");
  62. },
  63. failure: function (x,o) {
  64. alert("Async call failed!");
  65. }
  66. }
  67. });
  68. }
  69. function getSelectedComponents () {
  70. var desiredComponents = [];
  71. var selections =
  72. globalYui.all("#selectComponentsDynamicRenderDivId input[type=checkbox]");
  73. selections.each(function(selection) {
  74. if (selection.get('checked') == true) {
  75. desiredComponents.push(selection.get('value'));
  76. }
  77. });
  78. return desiredComponents;
  79. }
  80. function renderSelectServicesBlock( selectServicesInfo ) {
  81. InstallationWizard.SelectServicesForNewNodes.render(selectServicesInfo);
  82. }
  83. globalYui.one('#deployAddedNodesSubmitButtonId').on('click',function (e) {
  84. e.target.set('disabled', true);
  85. var deployRequestData = getSelectedComponents();
  86. globalYui.io("../php/frontend/deployAddedNodes.php?clusterName="+ InstallationWizard.SelectServicesForNewNodes.renderData.clusterName, {
  87. method: 'POST',
  88. data: globalYui.JSON.stringify(deployRequestData),
  89. timeout : 10000,
  90. on: {
  91. start: function(x, o) {
  92. e.target.set('disabled', false);
  93. showLoadingImg();
  94. },
  95. complete: function(x, o) {
  96. e.target.set('disabled', false);
  97. hideLoadingImg();
  98. },
  99. success: function (x,o) {
  100. globalYui.log("RAW DEPLOY DATA: " + o.responseText);
  101. try {
  102. deployProgressInfoJson = globalYui.JSON.parse(o.responseText);
  103. } catch (e) {
  104. alert("JSON Parse failed!");
  105. return;
  106. }
  107. globalYui.log("PARSED DATA: " + globalYui.Lang.dump(deployProgressInfoJson));
  108. /* Done with this stage, transition to the next. */
  109. transitionToNextStage( "#selectServicesCoreDivId", deployRequestData, "#txnProgressCoreDivId", deployProgressInfoJson, renderDeployProgress );
  110. /* At this point, our users are done with the installation wizard
  111. * and have asked for a deploy, so there's no going back - remove
  112. * all traces of #installationWizardProgressBarDivId.
  113. */
  114. globalYui.one('#installationWizardProgressBarDivId').setStyle('display', 'none');
  115. },
  116. failure: function (x,o) {
  117. e.target.set('disabled', false);
  118. alert("Async call failed!");
  119. }
  120. }
  121. });
  122. });