uninstall.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. function getWipeOutConfirmation () {
  2. var selections = globalYui.all("#confirmWipeOutDivId input[type=checkbox]");
  3. var wipeOutChecked = false;
  4. selections.each( function(selection) {
  5. wipeOutChecked = selection.get('checked');
  6. });
  7. if (wipeOutChecked) {
  8. return "wipeOut";
  9. } else {
  10. return "uninstall";
  11. }
  12. }
  13. globalYui.one('#addNodesSubmitButtonId').on('click',function (e) {
  14. var focusId = '';
  15. var message = '';
  16. var errCount = 0;
  17. var userId = globalYui.Lang.trim(globalYui.one("#clusterDeployUserId").get('value'));
  18. if (userId == '') {
  19. errCount++;
  20. focusId = '#clusterDeployUserId';
  21. message += 'SSH Username cannot be empty';
  22. globalYui.one("#clusterDeployUserId").addClass('formInputError');
  23. } else {
  24. globalYui.one("#clusterDeployUserId").removeClass('formInputError');
  25. }
  26. var fileName = globalYui.one("#clusterDeployUserIdentityFileId").get('value');
  27. if (fileName == '') {
  28. errCount++;
  29. if (focusId == '') {
  30. focusId = '#clusterDeployUserIdentityFileId';
  31. }
  32. if (message != '') {
  33. message += ',';
  34. }
  35. message += 'SSH Private Key File not specified';
  36. globalYui.one("#clusterDeployUserIdentityFileId").addClass('formInputError');
  37. } else {
  38. globalYui.one("#clusterDeployUserIdentityFileId").removeClass('formInputError');
  39. }
  40. if (nodesAction != "uninstall") {
  41. fileName = globalYui.one("#clusterHostsFileId").get('value');
  42. if (fileName == '') {
  43. errCount++;
  44. if (focusId == '') {
  45. focusId = '#clusterHostsFileId';
  46. }
  47. if (message != '') {
  48. message += ',';
  49. }
  50. message += 'Hosts File not specified';
  51. globalYui.one("#clusterHostsFileId").addClass('formInputError');
  52. } else {
  53. globalYui.one("#clusterHostsFileId").removeClass('formInputError');
  54. }
  55. }
  56. if (errCount != 0) {
  57. globalYui.one(focusId).focus();
  58. setFormStatus(message, true);
  59. return;
  60. }
  61. clearFormStatus();
  62. var doWipeout = globalYui.one('#confirmWipeOutCheckId').get('checked');
  63. 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?";
  64. if (!confirm(warningMessage)) {
  65. return;
  66. }
  67. showLoadingImg();
  68. globalYui.log("About to upload files.");
  69. e.target.set('disabled', true);
  70. var addNodesFilesForm = globalYui.one("#addNodesFilesFormId");
  71. addNodesFilesForm.set('action', '../php/frontend/addNodes.php?clusterName=' +
  72. clusterName + "&freshInstall=false");
  73. /* Set the target of the first form's upload to be a hidden iframe
  74. * on the page so as not to redirect to the PHP page we're POSTing
  75. * to.
  76. *
  77. * See http://www.openjs.com/articles/ajax/ajax_file_upload/ for
  78. * more on this.
  79. */
  80. addNodesFilesForm.set('target', 'fileUploadTarget');
  81. /* And then programmatically submit the first of the 2 forms. */
  82. addNodesFilesForm.submit();
  83. globalYui.log("Files submitted to server.");
  84. e.target.set('disabled', false);
  85. });
  86. var setupNodesJson = "";
  87. globalYui.one("#fileUploadTargetId").on('load', function (e) {
  88. e.target.set('disabled', true);
  89. var action = getWipeOutConfirmation();
  90. var uninstallRequestData = { };
  91. var userId = globalYui.Lang.trim(globalYui.one("#clusterDeployUserId").get('value'));
  92. var url = "../php/frontend/uninstall.php?clusterName=" + clusterName + "&action=" + action + "&clusterDeployUser=" + userId;
  93. var requestData = uninstallRequestData;
  94. var submitButton = e.target;
  95. var thisScreenId = "#addNodesCoreDivId";
  96. var nextScreenId = "#txnProgressCoreDivId";
  97. var nextScreenRenderFunction = renderUninstallProgress;
  98. submitDataAndProgressToNextScreen(url, requestData, submitButton, thisScreenId, nextScreenId, nextScreenRenderFunction);
  99. });
  100. /* Main() */
  101. hideLoadingImg();