deployAddedNodesProgress.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. function DeployAddedNodes() {
  2. function generateLogsContent(errorInfoJson) {
  3. return '<pre>' +
  4. globalYui.JSON.stringify( errorInfoJson.logs, null, 4 ) +
  5. '</pre>';
  6. }
  7. this.renderProgress = function(progressInfo) {
  8. hideLoadingImg();
  9. /* At this point, our users are done with the installation wizard
  10. * and have asked for a deploy, so there's no going back - remove
  11. * all traces of #installationWizardProgressBarDivId.
  12. */
  13. var installationWizardProgressBarDiv = globalYui.one('#installationWizardProgressBarDivId');
  14. /* But be safe and perform this removal only if #installationWizardProgressBarDivId
  15. * actually exists on the page - this .js file is now being used in more
  16. * than one place, so this robustness is needed.
  17. */
  18. if (installationWizardProgressBarDiv) {
  19. installationWizardProgressBarDiv.setStyle('display', 'none')
  20. }
  21. var progressStatusMessage = {
  22. success:
  23. '<p>' +
  24. 'Successfully added new nodes to your cluster.<br><a href="index.php" id="addMoreNodesSuccessLink" style="margin-top:10px" class="btn btn-large">Continue</a>' +
  25. '</p>',
  26. failure:
  27. '<p>' +
  28. 'Failed to add new nodes to the cluster.<br>Take a look at the ' +
  29. '<a href="javascript:void(null)" id="showDeployTxnLogsLinkId">deploy logs</a>' +
  30. ' to find out what might have gone wrong.' +
  31. '<a href="index.php" class="btn btn-large" style="margin-top:10px" id="addMoreNodesFailedLink">' +
  32. 'Continue' +
  33. '</a>' +
  34. '</p>'
  35. };
  36. var postCompletionFixup = {
  37. success: function(txnProgressWidget) {
  38. },
  39. failure: function(txnProgressWidget) {
  40. /* Create the panel that'll display our error info. */
  41. var errorInfoPanel =
  42. createInformationalPanel( '#informationalPanelContainerDivId', 'Deploy Logs' );
  43. /* Prime the panel to start off showing our stock loading image. */
  44. var errorInfoPanelBodyContent =
  45. '<img id="errorInfoPanelLoadingImgId" class="loadingImg" src="../images/loading.gif" />';
  46. /* Make the call to our backend to fetch the report for this txnId. */
  47. globalYui.io('../php/frontend/fetchTxnLogs.php?clusterName=' +
  48. txnProgressWidget.txnProgressContext.clusterName + '&txnId=' + txnProgressWidget.txnProgressContext.txnId, {
  49. timeout: 10000,
  50. on: {
  51. success: function (x,o) {
  52. globalYui.log("RAW JSON DATA: " + o.responseText);
  53. var errorInfoJson = null;
  54. // Process the JSON data returned from the server
  55. try {
  56. errorInfoJson = globalYui.JSON.parse(o.responseText);
  57. }
  58. catch (e) {
  59. alert("JSON Parse failed!");
  60. return;
  61. }
  62. /* TODO XXX Remove some of the noise from this to allow
  63. * for better corelation - for now, just dump a
  64. * pretty-printed version of the returned JSON.
  65. */
  66. errorInfoPanelBodyContent = generateLogsContent(errorInfoJson);
  67. /* Update the contents of errorInfoPanel (which was, till
  68. * now, showing the loading image).
  69. */
  70. errorInfoPanel.set( 'bodyContent', errorInfoPanelBodyContent );
  71. },
  72. failure: function (x,o) {
  73. alert("Async call failed!");
  74. }
  75. }
  76. });
  77. /* Register a click-handler for #showDeployTxnLogsLinkId to render
  78. * the contents inside errorInfoPanel (and make it visible).
  79. */
  80. globalYui.one("#showDeployTxnLogsLinkId").on( "click", function(e) {
  81. errorInfoPanel.set('bodyContent', errorInfoPanelBodyContent);
  82. errorInfoPanel.show();
  83. });
  84. }
  85. };
  86. var progressWidget = new TxnProgressWidget(progressInfo, 'Add Nodes', progressStatusMessage, postCompletionFixup);
  87. progressWidget.show();
  88. }
  89. };