uninstall.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. function getWipeOutConfirmation () {
  22. var selections = globalYui.all("#confirmWipeOutDivId input[type=checkbox]");
  23. var wipeOutChecked = false;
  24. selections.each( function(selection) {
  25. wipeOutChecked = selection.get('checked');
  26. });
  27. if (wipeOutChecked) {
  28. return "wipeOut";
  29. } else {
  30. return "uninstall";
  31. }
  32. }
  33. globalYui.one('#addNodesSubmitButtonId').on('click',function (e) {
  34. var focusId = '';
  35. var message = '';
  36. var errCount = 0;
  37. var userId = globalYui.Lang.trim(globalYui.one("#clusterDeployUserId").get('value'));
  38. if (userId == '') {
  39. errCount++;
  40. focusId = '#clusterDeployUserId';
  41. message += 'SSH Username cannot be empty';
  42. globalYui.one("#clusterDeployUserId").addClass('formInputError');
  43. } else {
  44. globalYui.one("#clusterDeployUserId").removeClass('formInputError');
  45. }
  46. var fileName = globalYui.one("#clusterDeployUserIdentityFileId").get('value');
  47. if (fileName == '') {
  48. errCount++;
  49. if (focusId == '') {
  50. focusId = '#clusterDeployUserIdentityFileId';
  51. }
  52. if (message != '') {
  53. message += ',';
  54. }
  55. message += 'SSH Private Key File not specified';
  56. globalYui.one("#clusterDeployUserIdentityFileId").addClass('formInputError');
  57. } else {
  58. globalYui.one("#clusterDeployUserIdentityFileId").removeClass('formInputError');
  59. }
  60. if (nodesAction != "uninstall") {
  61. fileName = globalYui.one("#clusterHostsFileId").get('value');
  62. if (fileName == '') {
  63. errCount++;
  64. if (focusId == '') {
  65. focusId = '#clusterHostsFileId';
  66. }
  67. if (message != '') {
  68. message += ',';
  69. }
  70. message += 'Hosts File not specified';
  71. globalYui.one("#clusterHostsFileId").addClass('formInputError');
  72. } else {
  73. globalYui.one("#clusterHostsFileId").removeClass('formInputError');
  74. }
  75. }
  76. if (errCount != 0) {
  77. globalYui.one(focusId).focus();
  78. setFormStatus(message, true);
  79. return;
  80. }
  81. clearFormStatus();
  82. var doWipeout = globalYui.one('#confirmWipeOutCheckId').get('checked');
  83. var warningMessage = doWipeout ? "All your data, in addition to services, will be deleted from all your cluster nodes. Are you sure you want to proceed?" : "All your services will be deleted from all your cluster nodes. Your data will not be deleted. Are you sure you want to proceed?";
  84. var confirmPanel = createInformationalPanel('#informationalPanelContainerDivId','Uninstall Cluster');
  85. confirmPanel.set('centered', true);
  86. confirmPanel.set('bodyContent', warningMessage);
  87. confirmPanel.addButton({
  88. value: 'Cancel',
  89. action: function (e) {
  90. e.preventDefault();
  91. destroyInformationalPanel(confirmPanel);
  92. },
  93. classNames: '',
  94. section: 'footer'
  95. });
  96. confirmPanel.addButton({
  97. value: 'Proceed with Uninstall',
  98. action: function (e) {
  99. e.preventDefault();
  100. destroyInformationalPanel(confirmPanel);
  101. showLoadingImg();
  102. globalYui.log("About to upload files.");
  103. e.target.set('disabled', true);
  104. var addNodesFilesForm = globalYui.one("#addNodesFilesFormId");
  105. addNodesFilesForm.set('action', '../php/frontend/addNodes.php?clusterName=' +
  106. clusterName);
  107. /* Set the target of the first form's upload to be a hidden iframe
  108. * on the page so as not to redirect to the PHP page we're POSTing
  109. * to.
  110. *
  111. * See http://www.openjs.com/articles/ajax/ajax_file_upload/ for
  112. * more on this.
  113. */
  114. addNodesFilesForm.set('target', 'fileUploadTarget');
  115. /* And then programmatically submit the first of the 2 forms. */
  116. addNodesFilesForm.submit();
  117. globalYui.log("Files submitted to server.");
  118. e.target.set('disabled', false);
  119. },
  120. classNames: 'okButton',
  121. section: 'footer'
  122. });
  123. confirmPanel.show();
  124. });
  125. var setupNodesJson = "";
  126. globalYui.one("#fileUploadTargetId").on('load', function (e) {
  127. e.target.set('disabled', true);
  128. var action = getWipeOutConfirmation();
  129. var uninstallRequestData = { };
  130. var userId = globalYui.Lang.trim(globalYui.one("#clusterDeployUserId").get('value'));
  131. var url = "../php/frontend/uninstall.php?clusterName=" + clusterName + "&action=" + action + "&clusterDeployUser=" + userId;
  132. var requestData = uninstallRequestData;
  133. var submitButton = e.target;
  134. var thisScreenId = "#addNodesCoreDivId";
  135. var nextScreenId = "#txnProgressCoreDivId";
  136. var nextScreenRenderFunction = renderUninstallProgress;
  137. submitDataAndProgressToNextScreen(url, requestData, submitButton, thisScreenId, nextScreenId, nextScreenRenderFunction);
  138. });
  139. /* Main() */
  140. hideLoadingImg();