selectComponents.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. *
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. *
  20. */
  21. InstallationWizard.SelectServicesForNewNodes = {
  22. renderData: {},
  23. render: function (deployAddedNodesData) {
  24. InstallationWizard.SelectServicesForNewNodes.renderData = deployAddedNodesData;
  25. getServiceComponentListAndRender(clusterName);
  26. }
  27. };
  28. function getServiceComponentListAndRender(clusterName) {
  29. globalYui.io("../php/frontend/fetchClusterServices.php?clusterName=" + clusterName + "&getComponents=true", {
  30. method: 'GET',
  31. timeout: 10000,
  32. on: {
  33. success: function (x,o) {
  34. globalYui.log("RAW JSON DATA: " + o.responseText);
  35. // Process the JSON data returned from the server
  36. try {
  37. responseJson = globalYui.JSON.parse(o.responseText);
  38. }
  39. catch (e) {
  40. alert("JSON Parse failed!");
  41. return;
  42. }
  43. globalYui.log("PARSED DATA: " + globalYui.Lang.dump(responseJson));
  44. if (responseJson.result != 0) {
  45. // Error!
  46. alert("Got error during fetching services !" + responseJson.error);
  47. return;
  48. }
  49. data = responseJson.response;
  50. var divContent = '<ul>';
  51. // for each service that is enabled, find all the slave components
  52. // and display them.
  53. // At this phase, we do not worry about dependencies because these are
  54. // just slaves and each slave is independent of the other
  55. for (serviceName in data['services']) {
  56. if (data['services'][serviceName]['isEnabled'] != "0" && data['services'][serviceName]['attributes']['noDisplay'] == false) {
  57. component = data['services'][serviceName]['components'];
  58. for (componentIndex in component) {
  59. if (component[componentIndex]['isMaster'] == null &&
  60. (component[componentIndex]['isClient'] == null)) {
  61. continue;
  62. }
  63. if (!component[componentIndex]['isMaster'] &&
  64. !component[componentIndex]['isClient'] &&
  65. component[componentIndex].componentName != 'HIVE_MYSQL') {
  66. divContent += '<li class="selectServicesEntry" name=try>';
  67. divContent += '<label class="checkbox" for="install' + serviceName + 'Id">'
  68. + '<input type="checkbox" disabled="disabled" checked="yes" name="' + serviceName + '" id="install' + serviceName + 'Id" value="' + component[componentIndex].componentName + '"/>'
  69. + component[componentIndex].displayName + '</label>'
  70. + '<div class="contextualhelp">' + component[componentIndex].description + '</div>'
  71. + '</li>';
  72. } else {
  73. continue;
  74. }
  75. }
  76. } else {
  77. continue;
  78. }
  79. }
  80. divContent += '</ul>';
  81. globalYui.one("#selectComponentsDynamicRenderDivId").setContent(divContent);
  82. globalYui.one('#selectServicesCoreDivId').setStyle("display", "block");
  83. },
  84. failure: function (x,o) {
  85. alert("Async call failed!");
  86. }
  87. }
  88. });
  89. }
  90. function getSelectedComponents () {
  91. var desiredComponents = [];
  92. var selections =
  93. globalYui.all("#selectComponentsDynamicRenderDivId input[type=checkbox]");
  94. selections.each(function(selection) {
  95. if (selection.get('checked') == true) {
  96. desiredComponents.push(selection.get('value'));
  97. }
  98. });
  99. return desiredComponents;
  100. }
  101. function renderSelectServicesBlock( selectServicesInfo ) {
  102. InstallationWizard.SelectServicesForNewNodes.render(selectServicesInfo);
  103. }
  104. globalYui.one('#deployAddedNodesSubmitButtonId').on('click',function (e) {
  105. e.target.set('disabled', true);
  106. var deployRequestData = getSelectedComponents();
  107. var url = "../php/frontend/deployAddedNodes.php?clusterName=" + InstallationWizard.SelectServicesForNewNodes.renderData.clusterName;
  108. var requestData = deployRequestData;
  109. var submitButton = e.target;
  110. var thisScreenId = "#selectServicesCoreDivId";
  111. var nextScreenId = "#txnProgressCoreDivId";
  112. var nextScreenRenderFunction = renderDeployAddedNodesProgress;
  113. submitDataAndProgressToNextScreen(url, requestData, submitButton, thisScreenId, nextScreenId, nextScreenRenderFunction);
  114. });