incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject svn commit: r1357770 - in /incubator/ambari/trunk: CHANGES.txt hmc/js/deployAddedNodesProgress.js hmc/js/deployProgress.js hmc/js/manageServicesProgress.js hmc/js/txnUtils.js hmc/js/uninstallProgress.js hmc/js/utils.js
Date Thu, 05 Jul 2012 17:58:28 GMT
Author: yusaku
Date: Thu Jul  5 17:58:28 2012
New Revision: 1357770

URL: http://svn.apache.org/viewvc?rev=1357770&view=rev
Log:
AMBARI-589. Refactor progress popup (TxnProgressWidget) Javascript code (Contributed by yusaku)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/hmc/js/deployAddedNodesProgress.js
    incubator/ambari/trunk/hmc/js/deployProgress.js
    incubator/ambari/trunk/hmc/js/manageServicesProgress.js
    incubator/ambari/trunk/hmc/js/txnUtils.js
    incubator/ambari/trunk/hmc/js/uninstallProgress.js
    incubator/ambari/trunk/hmc/js/utils.js

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1357770&r1=1357769&r2=1357770&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Thu Jul  5 17:58:28 2012
@@ -6,6 +6,9 @@ characters wide.
 
 Release 1.0.0 - unreleased
 
+  AMBARI-589. Refactor progress popup (TxnProgressWidget) Javascript code
+  (yusaku)
+
   AMBARI-597. Remove /usr/bin/php dependency from the rpm's. (mahadev)
 
   AMBARI-596. Remove unused images in images/ directory. (vinodkv)

Modified: incubator/ambari/trunk/hmc/js/deployAddedNodesProgress.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/js/deployAddedNodesProgress.js?rev=1357770&r1=1357769&r2=1357770&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/js/deployAddedNodesProgress.js (original)
+++ incubator/ambari/trunk/hmc/js/deployAddedNodesProgress.js Thu Jul  5 17:58:28 2012
@@ -19,109 +19,40 @@
  *
 */
 
-function generateLogsContent(errorInfoJson) {
-  return '<pre>' +
-           globalYui.JSON.stringify( errorInfoJson.logs, null, 4 ) +
-         '</pre>';
-}
-  
-function renderDeployAddedNodesProgress(progressInfo) {
-
-  hideLoadingImg();
+renderDeployAddedNodesProgress = function (context) {
 
   /* At this point, our users are done with the installation wizard
    * and have asked for a deploy, so there's no going back - remove
    * all traces of #installationWizardProgressBarDivId.
    */
-  var installationWizardProgressBarDiv = globalYui.one('#installationWizardProgressBarDivId');
-
-  /* But be safe and perform this removal only if #installationWizardProgressBarDivId 
-   * actually exists on the page - this .js file is now being used in more 
-   * than one place, so this robustness is needed.
-   */
-  if (installationWizardProgressBarDiv) {
-    installationWizardProgressBarDiv.setStyle('display', 'none')
+  var progressBarDiv = Y.one('#installationWizardProgressBarDivId');
+  if (progressBarDiv) {
+    progressBarDiv.hide();
   }
 
-  var progressStatusMessage = {
-
-    success:
-      '<p>' +
-        'Successfully added new nodes to your cluster.<br><a href="index.php" id="addMoreNodesSuccessLink" style="margin-top:10px" class="btn btn-large">Continue</a>' + 
-      '</p>',
-    failure:
-      '<p>' +
-        'Failed to add new nodes to the cluster.<br>Take a look at the ' +
-          '<a href="javascript:void(null)" id="showDeployTxnLogsLinkId">deploy logs</a>' +
-        ' to find out what might have gone wrong.' +
-        '<a href="index.php" class="btn btn-large" style="margin-top:10px" id="addMoreNodesFailedLink">' + 
-        'Continue' +
-        '</a>' +
-      '</p>'
+  var successMessage =
+    '<p>' +
+      'Successfully added new nodes to your cluster.<br><a href="index.php" id="addMoreNodesSuccessLink" style="margin-top:10px" class="btn btn-large">Continue</a>' +
+      '</p>';
+
+  var failureMessage =
+    '<p>' +
+      'Failed to add new nodes to the cluster.<br>Take a look at the ' +
+      '<a href="javascript:void(null)" id="txnProgressWidgetShowLogsLink">deploy logs</a>' +
+      ' to find out what might have gone wrong.' +
+      '<a href="index.php" class="btn btn-large" style="margin-top:10px" id="addMoreNodesFailedLink">' +
+      'Continue' +
+      '</a>' +
+      '</p>';
+
+  var config = {
+    context: context,
+    title: 'Add Nodes Progress',
+    successMessage: successMessage,
+    failureMessage: failureMessage
   };
 
-  var postCompletionFixup = {
-
-    failure: function(txnProgressWidget) {
-
-      /* Create the panel that'll display our error info. */
-      var errorInfoPanel = 
-        createInformationalPanel( '#informationalPanelContainerDivId', 'Deploy Logs' );
-
-      /* Prime the panel to start off showing our stock loading image. */
-      var errorInfoPanelBodyContent = 
-        '<img id="errorInfoPanelLoadingImgId" class="loadingImg" src="../images/loading.gif" />';
-
-      /* Make the call to our backend to fetch the report for this txnId. */
-      globalYui.io('../php/frontend/fetchTxnLogs.php?clusterName=' + 
-        txnProgressWidget.txnProgressContext.clusterName + '&txnId=' + txnProgressWidget.txnProgressContext.txnId, {
-          
-          timeout: 10000,
-          on: {
-            success: function (x,o) {
-
-              globalYui.log("RAW JSON DATA: " + o.responseText);
-
-              var errorInfoJson = null;
-
-              // Process the JSON data returned from the server
-              try {
-                errorInfoJson = globalYui.JSON.parse(o.responseText);
-              }
-              catch (e) {
-                alert("JSON Parse failed!");
-                return;
-              }
-
-              /* TODO XXX Remove some of the noise from this to allow
-               * for better corelation - for now, just dump a 
-               * pretty-printed version of the returned JSON.
-               */
-              errorInfoPanelBodyContent = generateLogsContent(errorInfoJson);
-
-              /* Update the contents of errorInfoPanel (which was, till
-               * now, showing the loading image). 
-               */
-              errorInfoPanel.set( 'bodyContent', errorInfoPanelBodyContent );
-            },
-            failure: function (x,o) {
-              alert("Async call failed!");
-            }
-        }
-      });
-
-      /* Register a click-handler for #showDeployTxnLogsLinkId to render 
-       * the contents inside errorInfoPanel (and make it visible). 
-       */
-      globalYui.one("#showDeployTxnLogsLinkId").on( "click", function(e) {
-        errorInfoPanel.set('bodyContent', errorInfoPanelBodyContent);
-        errorInfoPanel.show();
-
-      });
-    }
-  };
+  var progressWidget = new App.ui.TxnProgressWidget(config);
 
-  var progressWidget = new TxnProgressWidget(progressInfo, 'Add Nodes Progress', progressStatusMessage, postCompletionFixup);
-  
   progressWidget.show();
-} 
+};

Modified: incubator/ambari/trunk/hmc/js/deployProgress.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/js/deployProgress.js?rev=1357770&r1=1357769&r2=1357770&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/js/deployProgress.js (original)
+++ incubator/ambari/trunk/hmc/js/deployProgress.js Thu Jul  5 17:58:28 2012
@@ -19,169 +19,69 @@
  *
 */
 
-function generateLogsContent(errorInfoJson) {
-/*
-  content = '<div id=\"ProgressLogsContainer\">'
-  for (i=0; i < errorInfoJson['progress'].length; i++) {
-    var subTxnId = errorInfoJson['progress'][i]['subTxnId'];
-    var state = errorInfoJson['progress'][i]['state'];
-    var desc = errorInfoJson['progress'][i]['description'];
-
-    var stateClass = 'ProgressLogsSubTxnState' + state;
-
-    var subTxnDiv = '<div id=\"'
-      + 'ProgressLogsSubTxnContainer' + subTxnId + 'Id\"'
-      + ' class=\"ProgressLogsSubTxnContainer ' + stateClass + ' \" name=\"' + desc + '\">';
-
-    for (hostName in errorInfoJson['logs'][subTxnId]['nodeLogs']) {
-      var nodeReport = errorInfoJson['logs'][subTxnId]['nodeLogs'][hostName];
-      var hostState = nodeReport['overall'];
-      var hostStateClass = 'ProgressLogsSubTxnNodeState' + hostState;
-      var reportContainer = '<div id=\"ProgressLogsSubTxnNodeContainer' + subTxnId + hostName + 'Id\"'
-        + ' class=\"ProgressLogsSubTxnNodeContainer ' + hostStateClass + '\"' + ' name=\"' + hostName + '\">'
-        + '<div class=\"ProgressLogsSubTxnNodeContainerLogs\">'
-        + globalYui.JSON.stringify(nodeReport.message)
-        + '</div>'
-        + '</div>' + '<br/>'
-      subTxnDiv += reportContainer;
-    }
-    subTxnDiv += '</div>' + '<br/>';
-    content += subTxnDiv;
-  }
-  content += '</div>';
-
-  return content;
-*/
-  return '<pre>' +
-           globalYui.JSON.stringify( errorInfoJson.logs, null, 4 ) +
-         '</pre>';
-
-}
-
-function renderDeployProgress (deployProgressInfo) {
-
-  hideLoadingImg();
+renderDeployProgress = function (context) {
 
   /* At this point, our users are done with the installation wizard
    * and have asked for a deploy, so there's no going back - remove
    * all traces of #installationWizardProgressBarDivId.
    */
-  var installationWizardProgressBarDiv = globalYui.one('#installationWizardProgressBarDivId');
-
-  /* But be safe and perform this removal only if #installationWizardProgressBarDivId 
-   * actually exists on the page - this .js file is now being used in more 
-   * than one place, so this robustness is needed.
-   */
-  if (installationWizardProgressBarDiv) {
-    installationWizardProgressBarDiv.setStyle('display', 'none')
+  var progressBarDiv = Y.one('#installationWizardProgressBarDivId');
+  if (progressBarDiv) {
+    progressBarDiv.hide();
   }
 
   var hmcRestartMsg = '';
-  if (deployProgressInfo.nagiosGangliaCoHosted != null
-      && deployProgressInfo.nagiosGangliaCoHosted) {
-    hmcRestartMsg = '<span style="color:red"><strong>Note:</strong> You need to restart ' + App.Props.managerServiceName + ' as'
-        + ' Nagios/Ganglia are co-hosted on this server.<br>Please restart '
-        + App.Props.managerServiceName + ' using \"service ' + App.Props.managerServiceName.toLowerCase() + ' restart\".</span><br>After that is done, ';
+  if (context.nagiosGangliaCoHosted != null && context.nagiosGangliaCoHosted) {
+    hmcRestartMsg = '<span style="color:red"><strong>Note:</strong> You need to restart '
+      + App.Props.managerServiceName + ' as Nagios/Ganglia are co-hosted on this server.<br>Restart '
+      + App.Props.managerServiceName + ' by executing <i>sudo service ' + App.Props.managerServiceName.toLowerCase()
+      + ' restart</i> from the command line.</span><br>After that is done, ';
   } else {
     hmcRestartMsg = 'Please ';
   }
 
-  hmcRestartMsg += 
-      '<a href="javascript:void(null)" id="clustersListLinkId">' +
-        'click here to start managing your cluster.' +
+  hmcRestartMsg +=
+    '<a href="javascript:void(null)" id="clustersListLinkId">' +
+      'click here to start managing your cluster.' +
       '</a>';
 
-  var deployProgressStatusMessage = {
-
-    success:
-      '<p>' +
-        'Your cluster is ready! <br/>' + hmcRestartMsg +
-      '</p>',
-    failure:
-      '<p>' +
-        'Failed to finish setting up the cluster.<br>Take a look at the ' +
-          '<a href="javascript:void(null)" id="showDeployTxnLogsLinkId">deploy logs</a>' +
-        ' to find out what might have gone wrong.' +
-        '<a href="javascript:void(null)" class="btn btn-large" style="margin-top:10px" id="restartInstallationWizardLinkId">' + 
-        'Reinstall Cluster' +
-        '</a>' +
-      '</p>'
+  var successMessage =
+    '<p>' +
+      'Your cluster is ready! <br/>' + hmcRestartMsg +
+      '</p>';
+
+  var failureMessage =
+    '<p>' +
+      'Failed to finish setting up the cluster.<br>Take a look at the ' +
+      '<a href="javascript:void(null)" id="txnProgressWidgetShowLogsLink">deploy logs</a>' +
+      ' to find out what might have gone wrong.' +
+      '<a href="javascript:void(null)" class="btn btn-large" style="margin-top:10px" id="restartInstallationWizardLinkId">' +
+      'Reinstall Cluster' +
+      '</a>' +
+      '</p>';
+
+  var onSuccess = function (txnProgressWidget) {
+    Y.one('#clustersListLinkId').on('click', function (e) {
+      document.location.href = App.props.homeUrl;
+    });
   };
 
-  var deployProgressPostCompletionFixup = {
-
-    success: function( txnProgressWidget ) {
+  var onFailure = function (txnProgressWidget) {
+    Y.one('#restartInstallationWizardLinkId').on('click', function (e) {
+      document.location.href = App.props.homeUrl;
+    });
+  };
 
-      globalYui.one("#clustersListLinkId").on( "click", function(e) {
-        document.location.href = generateHMCUrl();
-      });
-    },
-
-    failure: function( txnProgressWidget ) {
-      globalYui.one("#restartInstallationWizardLinkId").on( "click", function(e) {
-        document.location.href = 'installFailed.php';
-      });
-
-      /* Create the panel that'll display our error info. */
-      var errorInfoPanel = 
-        createInformationalPanel( '#informationalPanelContainerDivId', 'Deploy Logs' );
-
-      /* Prime the panel to start off showing our stock loading image. */
-      var errorInfoPanelBodyContent = 
-        '<img id="errorInfoPanelLoadingImgId" class="loadingImg" src="../images/loading.gif" />';
-
-      /* Make the call to our backend to fetch the report for this txnId. */
-      globalYui.io('../php/frontend/fetchTxnLogs.php?clusterName=' + 
-        txnProgressWidget.txnProgressContext.clusterName + '&txnId=' + txnProgressWidget.txnProgressContext.txnId, {
-          
-          timeout: 10000,
-          on: {
-            success: function (x,o) {
-
-              globalYui.log("RAW JSON DATA: " + o.responseText);
-
-              var errorInfoJson = null;
-
-              // Process the JSON data returned from the server
-              try {
-                errorInfoJson = globalYui.JSON.parse(o.responseText);
-              }
-              catch (e) {
-                alert("JSON Parse failed!");
-                return;
-              }
-
-              /* TODO XXX Remove some of the noise from this to allow
-               * for better corelation - for now, just dump a 
-               * pretty-printed version of the returned JSON.
-               */
-              errorInfoPanelBodyContent = generateLogsContent(errorInfoJson);
-
-              /* Update the contents of errorInfoPanel (which was, till
-               * now, showing the loading image). 
-               */
-              errorInfoPanel.set( 'bodyContent', errorInfoPanelBodyContent );
-            },
-            failure: function (x,o) {
-              alert("Async call failed!");
-            }
-        }
-      });
-
-      /* Register a click-handler for #showDeployTxnLogsLinkId to render 
-       * the contents inside errorInfoPanel (and make it visible). 
-       */
-      globalYui.one("#showDeployTxnLogsLinkId").on( "click", function(e) {
-
-        errorInfoPanel.set( 'centered', true );
-        errorInfoPanel.set( 'bodyContent', errorInfoPanelBodyContent );
-        errorInfoPanel.show();
-      });
-    }
+  var config = {
+    context: context,
+    title: 'Deployment Progress',
+    successMessage: successMessage,
+    failureMessage: failureMessage,
+    onSuccess: onSuccess,
+    onFailure: onFailure
   };
 
-  var deployProgressWidget = new TxnProgressWidget
-    ( deployProgressInfo, 'Deployment Progress', deployProgressStatusMessage, deployProgressPostCompletionFixup );
-  
-  deployProgressWidget.show();
-} 
+  var progressWidget = new App.ui.TxnProgressWidget(config);
+
+  progressWidget.show();
+};

Modified: incubator/ambari/trunk/hmc/js/manageServicesProgress.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/js/manageServicesProgress.js?rev=1357770&r1=1357769&r2=1357770&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/js/manageServicesProgress.js (original)
+++ incubator/ambari/trunk/hmc/js/manageServicesProgress.js Thu Jul  5 17:58:28 2012
@@ -19,152 +19,32 @@
  *
 */
 
-function renderManageServicesProgress( manageServicesProgressInfo ) {
+renderManageServicesProgress = function (context) {
 
-  var manageServicesProgressStatusMessage = {
-
-    success:
-      '<p>' +
-        'Successfully completed the operation. ' + 
-          '<a href="javascript:void(null)" id=closeManageServicesProgressWidgetLinkId>' + 
-            'Continue' +
-          '</a>' +
-      '</p>',
-
-    failure: 
-      '<p>' + 
-        'Failed to complete the operation.  Please ' +
-          '<a href="javascript:void(null)" id=showManageServicesTxnLogsLinkId>take a look at Operation Logs</a>' +
-        ' to see what might have gone wrong.' +
-      '</p>'
+  var onSuccess = function (txnProgressWidget) {
+    /* Resume polling for information about the cluster's services. */
+    if (typeof fetchClusterServicesPoller != 'undefined') {
+      fetchClusterServicesPoller.start();
+    }
   };
 
-  var manageServicesProgressPostCompletionFixup = {
-
-    success: function( txnProgressWidget ) {
+  var onClose = function (e) {
+    var uriPath = '/hmc/html/manageServices.php';
+    var uriPathRegEx = new RegExp(uriPath);
 
-      /* Register a click-handler for the just-rendered 
-       * #closeManageServicesProgressWidgetLinkId.
-       *
-       * Don't worry about this being a double-registration - although
-       * it looks that way, it's not, because (an identical, but that's 
-       * irrelevant, really) manageServicesProgressStatusMessage.success 
-       * is re-rendered afresh each time through, and thus this 
-       * click-handler must also be re-registered each time 'round.
-       */
-      globalYui.one("#closeManageServicesProgressWidgetLinkId").on( "click", function(e) {
-
-        var manageServicesUriPath = '/hmc/html/manageServices.php';
-        var manageServicesUriPathRegEx = new RegExp(manageServicesUriPath);
-
-        /* If we're already on manageServicesUriPath, just close the txnProgressWidget. */
-        if( window.location.pathname.match(manageServicesUriPathRegEx) ) {
-          txnProgressWidget.hide();
-        }
-        /* If not, redirect to manageServicesUriPath. */
-        else {
-          document.location.href = generateHMCUrl
-            ( manageServicesUriPath + '?clusterName=' + txnProgressWidget.txnProgressContext.clusterName );
-        }
-      });
-
-      /* Resume polling for information about the cluster's services. */
-      if( typeof fetchClusterServicesPoller != 'undefined' ) {
-        fetchClusterServicesPoller.start();
-      }
-    },
-
-    failure: function( txnProgressWidget ) {
-
-      /* <-------------------- REZXXX BEGIN -----------------------> */
-
-      /* Create the panel that'll display our error info. */
-      var errorInfoPanel = 
-        createInformationalPanel( '#informationalPanelContainerDivId', 'Operation Logs' );
-
-      /* Prime the panel to start off showing our stock loading image. */
-      var errorInfoPanelBodyContent = 
-        '<img id=errorInfoPanelLoadingImgId class=loadingImg src=../images/loading.gif />';
-
-      /* Make the call to our backend to fetch the report for this txnId. */
-      globalYui.io('../php/frontend/fetchTxnLogs.php?clusterName=' + 
-        txnProgressWidget.txnProgressContext.clusterName + '&txnId=' + txnProgressWidget.txnProgressContext.txnId, {
-          
-        timeout: 10000,
-        on: {
-          success: function (x,o) {
-
-            globalYui.log("RAW JSON DATA: " + o.responseText);
-
-            var errorInfoJson = null;
-
-            // Process the JSON data returned from the server
-            try {
-              errorInfoJson = globalYui.JSON.parse(o.responseText);
-            }
-            catch (e) {
-              alert("JSON Parse failed!");
-              return;
-            }
-
-            /* TODO XXX Remove some of the noise from this to allow
-             * for better corelation - for now, just dump a 
-             * pretty-printed version of the returned JSON.
-             */
-            errorInfoPanelBodyContent = 
-              '<pre>' + 
-                globalYui.JSON.stringify( errorInfoJson.logs, null, 4 ) +
-              '</pre>';
-
-            /* Update the contents of errorInfoPanel (which was, till
-             * now, showing the loading image). 
-             */
-            errorInfoPanel.set( 'bodyContent', errorInfoPanelBodyContent );
-          },
-          failure: function (x,o) {
-            alert("Async call failed!");
-          }
-        }
-      });
-
-      var firstTimeShowingErrorInfoPanel = true;
-
-      /* Register a click-handler for #showManageServicesTxnLogsLinkId 
-       * to render the contents inside errorInfoPanel (and make it visible). 
-       */
-      globalYui.one("#showManageServicesTxnLogsLinkId").on( "click", function(e) {
-
-        errorInfoPanel.set( 'centered', true );
-        errorInfoPanel.set( 'bodyContent', errorInfoPanelBodyContent );
-        errorInfoPanel.show();
-
-        if( firstTimeShowingErrorInfoPanel ) {
-
-          globalYui.one('#txnProgressStatusActionsDivId').setContent(  
-            '<a href="javascript:void(null)" id=closeManageServicesProgressWidgetLinkId>' + 
-              'Close' +
-            '</a>' );
-
-          globalYui.one("#closeManageServicesProgressWidgetLinkId").on( "click", function(e) {
-
-            txnProgressWidget.hide();
-          });
-
-          firstTimeShowingErrorInfoPanel = false;
-        }
-      });
-
-      /* <--------------------- REZXXX END ------------------------> */
-
-      if( typeof fetchClusterServicesPoller != 'undefined' ) {
-        /* Resume polling for information about the cluster's services. */
-        fetchClusterServicesPoller.start();
-      }
+    if (!window.location.pathname.match(uriPathRegEx)) {
+      document.location.href = uriPath + '?clusterName=' + context.clusterName;
     }
   };
 
-  var manageServicesProgressWidget = new TxnProgressWidget
-    ( manageServicesProgressInfo, 'Manage Services', manageServicesProgressStatusMessage, manageServicesProgressPostCompletionFixup );
+  var config = {
+    context: context,
+    title: 'Manage Services',
+    onSuccess: onSuccess,
+    onClose: onClose
+  };
+
+  var progressWidget = new App.ui.TxnProgressWidget(config);
 
-  manageServicesProgressWidget.show();
-}
+  progressWidget.show();
+};

Modified: incubator/ambari/trunk/hmc/js/txnUtils.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/js/txnUtils.js?rev=1357770&r1=1357769&r2=1357770&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/js/txnUtils.js (original)
+++ incubator/ambari/trunk/hmc/js/txnUtils.js Thu Jul  5 17:58:28 2012
@@ -19,137 +19,161 @@
  *
 */
 
-function TxnProgressWidget( txnProgressContext, txnProgressTitle, txnProgressStatusMessage, txnProgressPostCompletionFixup ) {
+App.ui.TxnProgressWidget = function (config) {
+
+  var CONTAINER_DOM_ID = 'txnProgressCoreDivId';
+  var CLOSE_LINK_DOM_ID = 'txnProgressWidgetCloseLink';
+  var SHOW_LOGS_LINK_DOM_ID = 'txnProgressWidgetShowLogsLink';
+
+  var periodicDataPoller = null;
+  var isLogFetched = false;
+  var errorInfoPanel = null;
+  var targetUrl = null;
+
+  config.successMessage = config.successMessage ||
+    '<p>' +
+      'Successfully completed the operation.' +
+      '<a href="javascript:void(null)" id="' + CLOSE_LINK_DOM_ID + '" style="margin-left:10px" class="btn btn-large">' +
+      'Continue' +
+      '</a>' +
+      '</p>';
+
+  config.failureMessage = config.failureMessage ||
+    '<p>' +
+      'Failed to complete the operation.  Please ' +
+      '<a href="javascript:void(null)" id="' + SHOW_LOGS_LINK_DOM_ID + '">take a look at Operation Logs</a>' +
+      ' to see what might have gone wrong.  ' +
+      '<a href="javascript:void(null)" id="' + CLOSE_LINK_DOM_ID + '">' +
+      'Close' +
+      '</a>' +
+      '</p>';
+
+  config.onSuccess = config.onSuccess || function (widget) {
+  };
+
+  config.onFailure = config.onFailure || function (widget) {
+  };
+
+  config.onClose = config.onClose || function (widget) {
+  };
+
+  this.setTargetUrl = function (url) {
+    targetUrl = url;
+  };
+
+  var txnProgressStateShouldBeSkipped = function (txnProgressState) {
 
-  
-  /**************************** Private methods ********************************/
-  var txnProgressStateShouldBeSkipped = function( txnProgressState ) {
-    
     var skipIt = false;
 
-    /* Step over any deploy progress states that aren't in the CLUSTER, SERVICE 
-     * or SERVICE-SMOKETEST contexts. 
-     */
-    if( (txnProgressState.subTxnType != 'CLUSTER') && 
-        (txnProgressState.subTxnType != 'SERVICE') &&
-        (txnProgressState.subTxnType != 'SERVICE-SMOKETEST') ) {
+    if ((txnProgressState.subTxnType != 'CLUSTER') &&
+      (txnProgressState.subTxnType != 'SERVICE') &&
+      (txnProgressState.subTxnType != 'SERVICE-SMOKETEST')) {
 
       skipIt = true;
     }
 
     return skipIt;
-  }
+  };
 
-  var generateSingleTxnProgressStateMarkup = function( txnProgressStateTitle, txnProgressState ) {
+  var getTxnElementMarkup = function (txnProgressStateTitle, txnProgressState) {
 
     var stateClass;
     var barClass;
     var status;
-    
+
     switch (txnProgressState) {
-    case 'COMPLETED':
-      stateClass = 'txnProgressStateDone';
-      barClass = 'progress progress-success';
-      status = 'Completed';
-      break;
-
-    case 'IN_PROGRESS':
-      stateClass = 'txnProgressStateInProgress';
-      //barClass = 'progress progress-striped active';
-      barClass = 'progress';
-      status = 'In Progress';
-      break;
-
-    case 'FAILED':
-      stateClass = 'txnProgressStateError';
-      barClass = 'progress progress-danger';
-      status = 'Failed';
-      break;
-
-    default:
-      stateClass = 'txnProgressStatePending';
-      barClass = 'progress';
-      status = 'Pending';
-      break;
+      case 'COMPLETED':
+        stateClass = 'txnProgressStateDone';
+        barClass = 'progress progress-success';
+        status = 'Completed';
+        break;
+
+      case 'IN_PROGRESS':
+        stateClass = 'txnProgressStateInProgress';
+        //barClass = 'progress progress-striped active';
+        barClass = 'progress';
+        status = 'In Progress';
+        break;
+
+      case 'FAILED':
+        stateClass = 'txnProgressStateError';
+        barClass = 'progress progress-danger';
+        status = 'Failed';
+        break;
+
+      default:
+        stateClass = 'txnProgressStatePending';
+        barClass = 'progress';
+        status = 'Pending';
+        break;
     }
 
-    var barMarkup = '<div class="' + barClass + '"><div class="bar"></div></div>'; 
-    
+    var barMarkup = '<div class="' + barClass + '"><div class="bar"></div></div>';
+
     if (stateClass == 'txnProgressStateInProgress') {
       barMarkup = '<div id="activeProgressBarContainer">' + barMarkup + '</div>';
     }
-    
+
     var markup = '<li class="clearfix"><label class="' + stateClass + '">' + txnProgressStateTitle + '</label>' + barMarkup + '<div class="status ' + stateClass + '">' + status + '</div>' + '</li>';
 
-    globalYui.log("XXX" + markup);
     return markup;
-  }
-
-  /**************************** Public data members ********************************/
-  globalYui.log( 'Got txnId:' + txnProgressContext.txnId );
-
-  this.txnProgressContext = txnProgressContext;
-  this.txnProgressTitle = txnProgressTitle;
-  this.txnProgressStatusMessage = txnProgressStatusMessage;
-  this.txnProgressPostCompletionFixup = txnProgressPostCompletionFixup;
-  var requestStr = '?clusterName=' + this.txnProgressContext.clusterName + '&txnId=' + this.txnProgressContext.txnId;
-
-  if ("deployUser" in this.txnProgressContext) {
-    requestStr += '&deployUser=' + this.txnProgressContext.deployUser;
-  }
-
-  var pdpDataSourceContext = {
-    source: '../php/frontend/fetchTxnProgress.php',
-    schema: {
-      metaFields: {
-        progress: 'progress'
-      }
-    },
-
-    request: requestStr, 
-    pollInterval: 3000,
-    maxFailedAttempts: 5
   };
-  
-  this.clearActiveProgressBar = function() {
-    var bar = globalYui.one('#activeProgressBar');
+
+  var clearActiveProgressBar = function () {
+    var bar = Y.one('#activeProgressBar');
     if (bar != null) {
       bar.remove();
     }
-    globalYui.on('windowresize', function(e) {
+    Y.on('windowresize', function (e) {
       setActiveProgressBarInPlace();
     });
   };
-  
-  function setActiveProgressBarInPlace() {  
-    var bar = globalYui.one('#activeProgressBar');
-    var barContainer = globalYui.one('#activeProgressBarContainer');
+
+  var setActiveProgressBarInPlace = function () {
+    var bar = Y.one('#activeProgressBar');
+    var barContainer = Y.one('#activeProgressBarContainer');
     var marginTop = 3;
-    
+
     // Puts an active progress bar where the placeholder with the DIV ID of "activeProgressBarSpot" is located.
     // Creates an instance of the active progress bar if one does not already exist
     // so that we can keep reusing it and moving it in place, rather than dynamically rendering it
     // on every successful callback to avoid flickering/disconnect due to animation.
     if (barContainer != null) {
       if (bar == null) {
-        globalYui.one("body").append('<div id="activeProgressBar" class="progress progress-striped active" style="position:absolute;top:-50px;left:0;z-index:99;"><div style="width:100%" class="bar"></div></div>');
-        bar = globalYui.one('#activeProgressBar');
-      }      
-      bar.setStyle('display', 'block');     
-      if (bar.getX() != barContainer.getX() || bar.getY() != barContainer.getY() + marginTop) {      
+        Y.one("body").append('<div id="activeProgressBar" class="progress progress-striped active" style="position:absolute;top:-50px;left:0;z-index:99;"><div style="width:100%" class="bar"></div></div>');
+        bar = Y.one('#activeProgressBar');
+      }
+      bar.show();
+      if (bar.getX() != barContainer.getX() || bar.getY() != barContainer.getY() + marginTop) {
         bar.setXY([ barContainer.getX(), barContainer.getY() + marginTop ]);
       }
     } else if (bar != null) {
-      bar.setStyle('display', 'none');
-    }    
+      bar.hide();
+    }
+  };
+
+  var requestStr = '?clusterName=' + config.context.clusterName + '&txnId=' + config.context.txnId;
+  if ("deployUser" in config.context) {
+    requestStr += '&deployUser=' + config.context.deployUser;
   }
 
+  var pdpDataSourceContext = {
+    source: '/hmc/php/frontend/fetchTxnProgress.php',
+    schema: {
+      metaFields: {
+        progress: 'progress'
+      }
+    },
+    request: requestStr,
+    pollInterval: 3000,
+    maxFailedAttempts: 5
+  };
+
   var pdpResponseHandler = {
     success: function (e, pdp) {
 
-      /* What we're here to render. */
-      var txnProgressMarkup = 
-        '<img id=txnProgressLoadingImgId class=loadingImg src=../images/loading.gif />'; 
+      var txnProgressMarkup =
+        '<img id=txnProgressLoadingImgId class=loadingImg src=/hmc/images/loading.gif />';
 
       var noNeedForFurtherPolling = false;
       var txnProgressStatusDivContent = '';
@@ -157,14 +181,14 @@ function TxnProgressWidget( txnProgressC
 
       var txnProgress = e.response.meta.progress;
 
-      /* Guard against race conditions where txnProgress is null because the 
+      /* Guard against race conditions where txnProgress is null because the
        * txn hasn't had time to be kicked off yet.
        */
       if (txnProgress) {
 
-        /* The first time we get back meaningful progress data, pause the 
-         * automatic polling to avoid race conditions where response N+1 
-         * is made (and returns with fresh data) while request N hasn't 
+        /* The first time we get back meaningful progress data, pause the
+         * automatic polling to avoid race conditions where response N+1
+         * is made (and returns with fresh data) while request N hasn't
          * yet been fully processed.
          *
          * We'll unpause at the end, after we've performed the rendering
@@ -173,42 +197,42 @@ function TxnProgressWidget( txnProgressC
         pdp.pause();
 
         var txnProgressStates = txnProgress.subTxns || [];
-        globalYui.log(globalYui.Lang.dump(txnProgressStates));
+        Y.log(Y.Lang.dump(txnProgressStates));
 
         txnProgressMarkup = '<ul>';
 
         var progressStateIndex = 0;
 
         /* Generate markup for all the "done" states. */
-        for( ; progressStateIndex < txnProgressStates.length; ++progressStateIndex ) {
+        for (; progressStateIndex < txnProgressStates.length; ++progressStateIndex) {
 
           var presentTxnProgressState = txnProgressStates[ progressStateIndex ];
 
           /* Step over any progress states that don't deserve to be shown. */
-          if( txnProgressStateShouldBeSkipped( presentTxnProgressState ) ) {
+          if (txnProgressStateShouldBeSkipped(presentTxnProgressState)) {
             continue;
           }
 
           /* The first sign of a state that isn't done, and we're outta here. */
-          if( presentTxnProgressState.progress != 'COMPLETED' ) {
+          if (presentTxnProgressState.progress != 'COMPLETED') {
             break;
           }
 
-          globalYui.log( 'Done loop - ' + progressStateIndex );
+          Y.log('Done loop - ' + progressStateIndex);
 
-          txnProgressMarkup += generateSingleTxnProgressStateMarkup
-            ( presentTxnProgressState.description, 'COMPLETED' );
+          txnProgressMarkup += getTxnElementMarkup
+            (presentTxnProgressState.description, 'COMPLETED');
 
-            globalYui.log("Currently, markup is:" + txnProgressMarkup );
+          Y.log("Currently, markup is:" + txnProgressMarkup);
         }
 
         /* Next, generate markup for the first "in-progress" state. */
-        for( ; progressStateIndex < txnProgressStates.length; ++progressStateIndex ) {
+        for (; progressStateIndex < txnProgressStates.length; ++progressStateIndex) {
 
           var presentTxnProgressState = txnProgressStates[ progressStateIndex ];
 
           /* Step over any progress states that don't deserve to be shown. */
-          if( txnProgressStateShouldBeSkipped( presentTxnProgressState ) ) {
+          if (txnProgressStateShouldBeSkipped(presentTxnProgressState)) {
             continue;
           }
 
@@ -216,110 +240,110 @@ function TxnProgressWidget( txnProgressC
            * "in-progress", even if presentTxnProgressState.progress is
            * not explicitly set to "IN_PROGRESS".
            *
-           * This is to take care of race conditions where the poll to the 
-           * backend is made at a time when the previous state has 
+           * This is to take care of race conditions where the poll to the
+           * backend is made at a time when the previous state has
            * "COMPLETED" but the next state hasn't been started yet (which
            * means it's "PENDING") - if we were explicitly looking for
            * "IN_PROGRESS", there'd be nothing to show in this loop and it
            * would run to the end of txnProgressStates hunting for that
-           * elusive "IN_PROGRESS", thus not even showing any of the 
+           * elusive "IN_PROGRESS", thus not even showing any of the
            * "PENDING" states, causing a momentary jitter in the rendering
            * (see AMBARI-344 for an example).
            */
-          globalYui.log( 'In-progress/failed - ' + progressStateIndex );
+          Y.log('In-progress/failed - ' + progressStateIndex);
 
           /* Decide upon what CSS class to assign to the currently-in-progress
            * state - if an error was marked as having been encountered, assign
            * the fitting .txnProgressStateError, else just annoint it with
-           * .txnProgressStateInProgress 
+           * .txnProgressStateInProgress
            */
           var currentProgressState = 'IN_PROGRESS';
 
           /* The 2 possible indications of error are:
-           * 
-           * a) presentTxnProgressState.progress is 'IN_PROGRESS' but 
+           *
+           * a) presentTxnProgressState.progress is 'IN_PROGRESS' but
            *    txnProgress.encounteredError is true.
            * b) presentTxnProgressState.progress is 'FAILED'.
            */
-          if( (txnProgress.encounteredError) || 
-              (presentTxnProgressState.progress == 'FAILED') ) {
+          if ((txnProgress.encounteredError) ||
+            (presentTxnProgressState.progress == 'FAILED')) {
 
             currentProgressState = 'FAILED';
           }
 
           /* And generate markup for this "in-progress" state. */
-          txnProgressMarkup += generateSingleTxnProgressStateMarkup
-            ( presentTxnProgressState.description, currentProgressState );
+          txnProgressMarkup += getTxnElementMarkup
+            (presentTxnProgressState.description, currentProgressState);
 
-          /* It's important to manually increment progressStateIndex here, 
+          /* It's important to manually increment progressStateIndex here,
            * to set it up correctly for the upcoming loop.
            */
           ++progressStateIndex;
 
           /* Remember, we only care for the FIRST "in-progress" state.
            *
-           * Any following "in-progress" states will all be marked as 
-           * "pending", so as to avoid the display from becoming 
+           * Any following "in-progress" states will all be marked as
+           * "pending", so as to avoid the display from becoming
            * disorienting (with multiple states "in-progress").
            */
           break;
         }
 
         /* Finally, generate markup for all the "pending" states. */
-        for( ; progressStateIndex < txnProgressStates.length; ++progressStateIndex ) {
+        for (; progressStateIndex < txnProgressStates.length; ++progressStateIndex) {
 
           var presentTxnProgressState = txnProgressStates[ progressStateIndex ];
 
           /* Step over any progress states that don't deserve to be shown. */
-          if( txnProgressStateShouldBeSkipped( presentTxnProgressState ) ) {
+          if (txnProgressStateShouldBeSkipped(presentTxnProgressState)) {
             continue;
           }
 
-          globalYui.log( 'Pending loop - ' + progressStateIndex );
-          
-          txnProgressMarkup += generateSingleTxnProgressStateMarkup
-            ( presentTxnProgressState.description, 'PENDING' );
-          
+          Y.log('Pending loop - ' + progressStateIndex);
+
+          txnProgressMarkup += getTxnElementMarkup
+            (presentTxnProgressState.description, 'PENDING');
+
         }
 
         txnProgressMarkup += '</ul>';
 
-        /* Make sure we have some progress data to show - if not, 
+        /* Make sure we have some progress data to show - if not,
          * we'll just show a loading image until this is non-null.
          *
-         * The additional check for txnProgress.processRunning is to account 
-         * for cases where there are no subTxns (because it's all a no-op at 
-         * the backend) - the loading image should only be shown as long as 
+         * The additional check for txnProgress.processRunning is to account
+         * for cases where there are no subTxns (because it's all a no-op at
+         * the backend) - the loading image should only be shown as long as
          * the backend is still working; after that, we should break out of
          * the loading image loop and let the user know that there was
          * nothing to be done.
          */
-        if( txnProgress.subTxns == null ) {
-          if( txnProgress.processRunning == 0 ) {
-            txnProgressMarkup = 
-              '<br/>' + 
-              '<div class=txnNoOpMsg>' + 
+        if (txnProgress.subTxns == null) {
+          if (txnProgress.processRunning == 0) {
+            txnProgressMarkup =
+              '<br/>' +
+                '<div class="txnNoOpMsg">' +
                 'There are no tasks for this transaction.' +
-              '</div>' + 
-              '<br/>';
-          } 
+                '</div>' +
+                '<br/>';
+          }
           else {
-            txnProgressMarkup = 
-              '<img id=txnProgressLoadingImgId class=loadingImg src=../images/loading.gif />';
+            txnProgressMarkup =
+              '<img id="txnProgressLoadingImgId" class="loadingImg" src="/hmc/images/loading.gif" />';
           }
         }
 
-        /* We can break this polling cycle in one of 2 ways: 
-         * 
+        /* We can break this polling cycle in one of 2 ways:
+         *
          * 1) If we are explicitly told by the backend that we're done.
          */
-        if( txnProgress.processRunning == 0 ) {
+        if (txnProgress.processRunning == 0) {
 
           noNeedForFurtherPolling = true;
           /* Be optimistic and assume that no errors were encountered (we'll
            * get more in touch with reality further below).
            */
-          txnProgressStatusDivContent = this.txnProgressStatusMessage.success;
+          txnProgressStatusDivContent = config.successMessage;
           txnProgressStatusDivCssClass = 'statusOk';
         }
 
@@ -329,22 +353,22 @@ function TxnProgressWidget( txnProgressC
          * as an override in case the backend explicitly told us that we're
          * done, but an error was encountered in that very last progress report.
          */
-        if( txnProgress.encounteredError ) {
+        if (txnProgress.encounteredError) {
 
           noNeedForFurtherPolling = true;
-          txnProgressStatusDivContent = this.txnProgressStatusMessage.failure;
+          txnProgressStatusDivContent = config.failureMessage;
           txnProgressStatusDivCssClass = 'statusError';
         }
       }
 
       /* Render txnProgressMarkup before making any decisions about the
-       * future state of pdp. 
+       * future state of pdp.
        */
-      globalYui.log('About to generate markup: ' + txnProgressMarkup);
-      globalYui.one('#txnProgressContentDivId').setContent( txnProgressMarkup );
+      Y.log('About to generate markup: ' + txnProgressMarkup);
+      Y.one('#txnProgressContentDivId').setContent(txnProgressMarkup);
       setActiveProgressBarInPlace();
 
-      /* And before checking out, decide whether we're done with this txn 
+      /* And before checking out, decide whether we're done with this txn
        * or whether any more polling is required.
        */
       if (noNeedForFurtherPolling) {
@@ -352,21 +376,21 @@ function TxnProgressWidget( txnProgressC
         /* We've made all the progress we could have, so stop polling. */
         pdp.stop();
 
-        var txnProgressStatusDiv = globalYui.one('#txnProgressStatusDivId');
-        
+        var txnProgressStatusDiv = Y.one('#txnProgressStatusDivId');
+
         txnProgressStatusDiv.addClass(txnProgressStatusDivCssClass);
         txnProgressStatusDiv.one('#txnProgressStatusMessageDivId').setContent(txnProgressStatusDivContent);
-        txnProgressStatusDiv.setStyle('display', 'block');
+        txnProgressStatusDiv.show();
 
-        /* Run the post-completion fixups. */
+        /* Run the post-completion callback. */
         if (txnProgressStatusDivCssClass == 'statusOk') {
-          if (this.txnProgressPostCompletionFixup.success) {
-            this.txnProgressPostCompletionFixup.success(this);
+          if (config.onSuccess) {
+            config.onSuccess(this);
           }
         }
         else if (txnProgressStatusDivCssClass == 'statusError') {
-          if (this.txnProgressPostCompletionFixup.failure) {
-            this.txnProgressPostCompletionFixup.failure(this);
+          if (config.onFailure) {
+            config.onFailure(this);
           }
         }
       }
@@ -382,45 +406,98 @@ function TxnProgressWidget( txnProgressC
     }.bind(this)
   };
 
-  this.periodicDataPoller = new PeriodicDataPoller( pdpDataSourceContext, pdpResponseHandler );
-}
+  this.show = function () {
+    // start with a clean slate to clear any mess left by previous invocations
+    var statusDiv = Y.one('#txnProgressStatusDivId');
+    statusDiv.one('#txnProgressStatusMessageDivId').setContent('');
+    statusDiv.one('#txnProgressStatusActionsDivId').setContent('');
+    statusDiv.removeClass('statusOk');
+    statusDiv.removeClass('statusError');
+    statusDiv.hide();
+    Y.one('#txnProgressContentDivId').setContent
+      ('<ul class="wrapped"><li><img id="txnProgressLoadingImgId" class="loadingImg" src="/hmc/images/loading.gif" /></li></ul>');
+
+    // clear active progress bar if one already exists
+    clearActiveProgressBar();
+
+    App.ui.hideLoadingOverlay();
+
+    Y.one("#txnProgressHeader").setContent(config.title);
+    Y.one('#blackScreenDivId').show();
+    Y.one('#txnProgressCoreDivId').show();
+
+    periodicDataPoller.start();
+  };
+
+  this.hide = function () {
+    periodicDataPoller.stop();
+
+    Y.one('#txnProgressCoreDivId').hide();
+    Y.one('#blackScreenDivId').hide();
+  };
+
+  // initialize this object
+
+  periodicDataPoller = new App.io.PeriodicDataPoller(pdpDataSourceContext, pdpResponseHandler);
+
+  var onClick = function (e) {
+    switch (e.target.get('id')) {
+      case CLOSE_LINK_DOM_ID:
+        if (config.onClose) {
+          config.onClose();
+          if (targetUrl != null) {
+            document.location.href = targetUrl;
+          }
+          this.hide();
+        }
+        break;
+      case SHOW_LOGS_LINK_DOM_ID:
+
+        if (!isLogFetched) {
+          errorInfoPanel = App.ui.createInfoPanel('Operation Logs');
+
+          var bodyContent =
+            '<img id="errorInfoPanelLoadingImgId" class="loadingImg" src="/hmc/images/loading.gif" />';
+
+          errorInfoPanel.set('bodyContent', bodyContent);
+          errorInfoPanel.show();
+
+          Y.io('/hmc/php/frontend/fetchTxnLogs.php?clusterName=' +
+            config.context.clusterName + '&txnId=' + config.context.txnId, {
+
+            timeout: App.io.FETCH_LOG_TIMEOUT_MS,
+            on: {
+              success: function (x, o) {
+
+                var errorInfoJson = null;
+                try {
+                  errorInfoJson = Y.JSON.parse(o.responseText);
+                } catch (e) {
+                  alert("JSON Parse failed!");
+                  return;
+                }
+
+                errorInfoPanelBodyContent =
+                  '<pre>' +
+                    Y.JSON.stringify(errorInfoJson.logs, null, 4) +
+                    '</pre>';
+
+                errorInfoPanel.set('bodyContent', errorInfoPanelBodyContent);
+
+                isLogFetched = true;
+              },
+              failure: function (x, o) {
+                alert("Async call failed!");
+              }
+            }
+          });
+        } else {
+          errorInfoPanel.show();
+        }
+        break;
+    }
+  }.bind(this);
+
+  Y.one('#' + CONTAINER_DOM_ID).delegate('click', onClick, 'a');
 
-TxnProgressWidget.prototype.show = function() {
-     
-  /* Start with a clean slate for #txnProgressStatusDivId, regardless of 
-   * the mess previous uses might have left it in.
-   */
-  var txnProgressStatusDiv = globalYui.one('#txnProgressStatusDivId');
-  txnProgressStatusDiv.one('#txnProgressStatusMessageDivId').setContent('');
-  txnProgressStatusDiv.one('#txnProgressStatusActionsDivId').setContent('');
-  globalYui.one('#txnProgressHeader').setContent('');
-  /* Remove the CSS statusOk/statusError classes from txnProgressStatusDiv 
-   * as well - sure would be nice to remove all classes that match a 
-   * pattern, but oh well. 
-   */
-  txnProgressStatusDiv.removeClass('statusOk');
-  txnProgressStatusDiv.removeClass('statusError');
-
-  /* Similarly, set a clean slate for #txnProgressContentDivId as well. */
-  globalYui.one('#txnProgressContentDivId').setContent
-    ( '<ul class="wrapped"><li><img id=txnProgressLoadingImgId class=loadingImg src=../images/loading.gif /></li></ul>' );
-
-  // clear active progress bar if one already exists
-  this.clearActiveProgressBar();
-  
-  globalYui.one("#txnProgressHeader").setContent(this.txnProgressTitle);
-  
-  globalYui.one('#blackScreenDivId').setStyle('display', 'block');
-  globalYui.one('#txnProgressCoreDivId').setStyle('display','block');  
-
-  this.periodicDataPoller.start();
-}
-
-TxnProgressWidget.prototype.hide = function() {
-
-  this.periodicDataPoller.stop();
-  
-  globalYui.one('#txnProgressStatusDivId').setStyle('display', 'none'); 
-  globalYui.one('#txnProgressCoreDivId').setStyle('display','none');
-  globalYui.one('#blackScreenDivId').setStyle('display', 'none');
-}
+};

Modified: incubator/ambari/trunk/hmc/js/uninstallProgress.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/js/uninstallProgress.js?rev=1357770&r1=1357769&r2=1357770&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/js/uninstallProgress.js (original)
+++ incubator/ambari/trunk/hmc/js/uninstallProgress.js Thu Jul  5 17:58:28 2012
@@ -19,142 +19,39 @@
  *
 */
 
-function generateLogsContent(errorInfoJson) {
-/*
-  content = '<div id=\"ProgressLogsContainer\">'
-  for (i=0; i < errorInfoJson['progress'].length; i++) {
-    var subTxnId = errorInfoJson['progress'][i]['subTxnId'];
-    var state = errorInfoJson['progress'][i]['state'];
-    var desc = errorInfoJson['progress'][i]['description'];
-
-    var stateClass = 'ProgressLogsSubTxnState' + state;
-
-    var subTxnDiv = '<div id=\"'
-      + 'ProgressLogsSubTxnContainer' + subTxnId + 'Id\"'
-      + ' class=\"ProgressLogsSubTxnContainer ' + stateClass + ' \" name=\"' + desc + '\">';
-
-    for (hostName in errorInfoJson['logs'][subTxnId]['nodeLogs']) {
-      var nodeReport = errorInfoJson['logs'][subTxnId]['nodeLogs'][hostName];
-      var hostState = nodeReport['overall'];
-      var hostStateClass = 'ProgressLogsSubTxnNodeState' + hostState;
-      var reportContainer = '<div id=\"ProgressLogsSubTxnNodeContainer' + subTxnId + hostName + 'Id\"'
-        + ' class=\"ProgressLogsSubTxnNodeContainer ' + hostStateClass + '\"' + ' name=\"' + hostName + '\">'
-        + '<div class=\"ProgressLogsSubTxnNodeContainerLogs\">'
-        + globalYui.JSON.stringify(nodeReport.message)
-        + '</div>'
-        + '</div>' + '<br/>'
-      subTxnDiv += reportContainer;
-    }
-    subTxnDiv += '</div>' + '<br/>';
-    content += subTxnDiv;
-  }
-  content += '</div>';
+renderUninstallProgress = function (context) {
 
-  return content;
-*/
-  return '<pre>' +
-           globalYui.JSON.stringify( errorInfoJson.logs, null, 4 ) +
-         '</pre>';
-
-}
-
-function renderUninstallProgress (uninstallProgressInfo) {
-
-  hideLoadingImg();
-
-
-  var uninstallProgressStatusMessage = {
-
-    success:
-      '<p>' +
-        'Uninstalled the cluster successfully.' +
-        '<a href="javascript:void(null)" style="margin-left:20px" class="btn btn-large" id="clustersListLinkId">' +
-          'Continue' +
-        '</a>' +
-      '</p>',
-    failure:
-      '<p>' +
-        'There was a problem with uninstall.<br />Take a look at ' +
-          '<a href="javascript:void(null)" id="showUninstallTxnLogsLinkId">Uninstall Logs</a>' +
-        ' to see what might have happened.<br>' +
-        '<a href="javascript:void(null)" class="btn btn-large" style="margin-top:10px" id="clustersListLinkId">' + 
-            'Close' + 
-        '</a>' +
-      '</p>'
-  };
+  var successMessage =
+    '<p>' +
+      'Uninstalled the cluster successfully.' +
+      '<a href="javascript:void(null)" style="margin-left:20px" class="btn btn-large" id="txnProgressWidgetCloseLink">' +
+      'Continue' +
+      '</a>' +
+      '</p>';
+
+  var failureMessage =
+    '<p>' +
+      'There was a problem with uninstall.<br />Take a look at ' +
+      '<a href="javascript:void(null)" id="txnProgressWidgetShowLogsLink">Uninstall Logs</a>' +
+      ' to see what might have happened.<br>' +
+      '<a href="javascript:void(null)" class="btn btn-large" style="margin-top:10px" id="txnProgressWidgetCloseLink">' +
+      'Close' +
+      '</a>' +
+      '</p>';
 
-  var uninstallProgressPostCompletionFixup = {
-
-    success: function( txnProgressWidget ) {
+  var onClose = function (txnProgressWidget) {
+    document.location.href = App.props.homeUrl;
+  };
 
-      globalYui.one("#clustersListLinkId").on( "click", function(e) {
-        document.location.href = generateHMCUrl();
-      });
-    },
-
-    failure: function( txnProgressWidget ) {
-
-      globalYui.one("#clustersListLinkId").on( "click", function(e) {
-        document.location.href = generateHMCUrl();
-      });
-      
-      /* Create the panel that'll display our error info. */
-      var errorInfoPanel = 
-        createInformationalPanel( '#informationalPanelContainerDivId', 'Uninstall Logs' );
-
-      /* Prime the panel to start off showing our stock loading image. */
-      var errorInfoPanelBodyContent = 
-        '<img id=errorInfoPanelLoadingImgId class=loadingImg src=../images/loading.gif />';
-
-      /* Make the call to our backend to fetch the report for this txnId. */
-      globalYui.io('../php/frontend/fetchTxnLogs.php?clusterName=' + 
-        txnProgressWidget.txnProgressContext.clusterName + '&txnId=' + txnProgressWidget.txnProgressContext.txnId, {
-          
-          timeout: 10000,
-          on: {
-            success: function (x,o) {
-
-              globalYui.log("RAW JSON DATA: " + o.responseText);
-
-              var errorInfoJson = null;
-
-              // Process the JSON data returned from the server
-              try {
-                errorInfoJson = globalYui.JSON.parse(o.responseText);
-              }
-              catch (e) {
-                alert("JSON Parse failed!");
-                return;
-              }
-
-              /* TODO XXX Remove some of the noise from this to allow
-               * for better corelation - for now, just dump a 
-               * pretty-printed version of the returned JSON.
-               */
-              errorInfoPanelBodyContent = generateLogsContent(errorInfoJson);
-
-              /* Update the contents of errorInfoPanel (which was, till
-               * now, showing the loading image). 
-               */
-              errorInfoPanel.set( 'bodyContent', errorInfoPanelBodyContent );
-            },
-            failure: function (x,o) {
-              alert("Async call failed!");
-            }
-        }
-      });
-
-
-      globalYui.one("#showUninstallTxnLogsLinkId").on( "click", function(e) {
-        errorInfoPanel.set( 'centered', true);
-        errorInfoPanel.set( 'bodyContent', errorInfoPanelBodyContent );
-        errorInfoPanel.show();
-      });
-    }
+  var config = {
+    context: context,
+    title: 'Uninstall Cluster',
+    successMessage: successMessage,
+    failureMessage: failureMessage,
+    onClose: onClose
   };
 
-  var uninstallProgressWidget = new TxnProgressWidget
-    ( uninstallProgressInfo, 'Uninstall Cluster', uninstallProgressStatusMessage, uninstallProgressPostCompletionFixup );
+  var progressWidget = new App.ui.TxnProgressWidget(config);
 
-  uninstallProgressWidget.show();
-} 
+  progressWidget.show();
+};

Modified: incubator/ambari/trunk/hmc/js/utils.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/js/utils.js?rev=1357770&r1=1357769&r2=1357770&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/js/utils.js (original)
+++ incubator/ambari/trunk/hmc/js/utils.js Thu Jul  5 17:58:28 2012
@@ -17,43 +17,40 @@
  * specific language governing permissions and limitations
  * under the License.
  *
-*/
-
-
-var multipleClustersSupported = false;
+ */
 
 /* Allows 'this' to be bound statically.
  *
  * Primarily used when creating objects whose methods will be used as
  * callbacks in unknown contexts.
  */
-Function.prototype.bind = function(scope) {
+Function.prototype.bind = function (scope) {
   var _function = this;
 
-  return function() {
+  return function () {
     return _function.apply(scope, arguments);
   };
 };
 
 var globalSingletonInformationalPanel;
 
-function createInformationalPanel( containerNodeId, headerContentString ) {
+function createInformationalPanel(containerNodeId, headerContentString) {
 
-  /* XXX This should check that globalSingletonInformationalPanel is within 
+  /* XXX This should check that globalSingletonInformationalPanel is within
    * containerNodeId, and only then perform this cleanup, but this whole
    * panel-related section needs to be rewritten anyway - for now, we only
    * support the one globalSingletonInformationalPanel, and passing in
-   * anything other than #informationalPanelContainerDivId as containerNodeId 
+   * anything other than #informationalPanelContainerDivId as containerNodeId
    * is not guaranteed to work.
    */
-  if( globalSingletonInformationalPanel ) {
-    destroyInformationalPanel( globalSingletonInformationalPanel );
+  if (globalSingletonInformationalPanel) {
+    destroyInformationalPanel(globalSingletonInformationalPanel);
   }
 
-  globalYui.one( containerNodeId ).append('<div id="informationalPanelInnerContainerDivId"></div>');
-              
-  var newPanel = new globalYui.Panel({
-    srcNode: '#informationalPanelInnerContainerDivId', 
+  Y.one(containerNodeId).append('<div id="informationalPanelInnerContainerDivId"></div>');
+  
+  var newPanel = new Y.Panel({
+    srcNode: '#informationalPanelInnerContainerDivId',
     headerContent: headerContentString,
     width: 800,
     height: 400,
@@ -69,81 +66,85 @@ function createInformationalPanel( conta
   return newPanel;
 }
 
-function destroyInformationalPanel( theInformationalPanelInstance ) {
+function createInfoPanel(headerContent) {
+  return createInformationalPanel('#informationalPanelContainerDivId', headerContent);
+}
+
+function destroyInformationalPanel(theInformationalPanelInstance) {
 
-  if( theInformationalPanelInstance ) {
+  if (theInformationalPanelInstance) {
 
     theInformationalPanelInstance.hide();
     theInformationalPanelInstance.destroy();
 
-    if( theInformationalPanelInstance === globalSingletonInformationalPanel ) {
+    if (theInformationalPanelInstance === globalSingletonInformationalPanel) {
       globalSingletonInformationalPanel = null;
     }
   }
 }
 
 function showLoadingImg() {
-  globalYui.one("#loadingDivId").show();
+  Y.one("#loadingDivId").show();
 }
 
 function hideLoadingImg() {
-  globalYui.one("#loadingDivId").hide();
+  Y.one("#loadingDivId").hide();
 }
 
-function swapStageVisibilities( currentStageDivSelector, newStageDivSelector ) {
+function swapStageVisibilities(currentStageDivSelector, newStageDivSelector) {
 
-  globalYui.log("In swapStageVisibilities: " + currentStageDivSelector + "->" + newStageDivSelector);
+  Y.log("In swapStageVisibilities: " + currentStageDivSelector + "->" + newStageDivSelector);
   /* Hide the current stage. */
-  globalYui.one(currentStageDivSelector).hide();
+  Y.one(currentStageDivSelector).hide();
 
   /* Show the new stage. */
-  globalYui.one(newStageDivSelector).show();
+  Y.one(newStageDivSelector).show();
 }
 
 /* TODO XXX Consider bundling the last 3 parameters into their own NewStage object.
- * TODO XXX Do the same for the first 2 parameters and a CurrentStage object.  
+ * TODO XXX Do the same for the first 2 parameters and a CurrentStage object.
  */
-function transitionToNextStage( currentStageDivSelector, currentStageData, newStageDivSelector, newStageData, newStageRenderFunction ) {
+function transitionToNextStage(currentStageDivSelector, currentStageData, newStageDivSelector, newStageData, newStageRenderFunction) {
 
   clearFormStatus();
 
-  globalYui.one(currentStageDivSelector).hide();
-  
+  Y.one(currentStageDivSelector).hide();
+
   /* Render the next stage. */
   newStageRenderFunction(newStageData);
 
-  globalYui.log("In transitionToNextStage: " + currentStageDivSelector + "->" + newStageDivSelector);
+  Y.log("In transitionToNextStage: " + currentStageDivSelector + "->" + newStageDivSelector);
 
-  //// tshooter: No longer doing this given dynamic rendering on stages. Only hide current stage.  
+  //// tshooter: No longer doing this given dynamic rendering on stages. Only hide current stage.
   /* And make it visibly replace the currently showing one. */
   ///// tshooter: commented: swapStageVisibilities(currentStageDivSelector, newStageDivSelector);
 
   /* And now, handle the updates to addNodesWizardStages... */
 
   /* There can be only one 'current' stage at a time. */
-  var currentStage = globalYui.one('.installationWizardCurrentStage');
+  var currentStage = Y.one('.installationWizardCurrentStage');
 
-  if ( currentStage ) {
+  if (currentStage) {
     var nextStage = null;
 
     /* Check to make sure we haven't reached the last stage. */
-    if( nextStage = currentStage.next('.installationWizardUnvisitedStage') ) {
+    if (nextStage = currentStage.next('.installationWizardUnvisitedStage')) {
 
       /* Mark this up-until-now 'current' stage as 'visited'. */
-      currentStage.replaceClass( 'installationWizardCurrentStage', 'installationWizardVisitedStage' );
+      currentStage.replaceClass('installationWizardCurrentStage', 'installationWizardVisitedStage');
 
       /* Mark the stage after that as the new 'current' stage. */
-      nextStage.replaceClass( 'installationWizardUnvisitedStage', 'installationWizardCurrentStage' );
+      nextStage.replaceClass('installationWizardUnvisitedStage', 'installationWizardCurrentStage');
     }
   }
 }
 
 function clearFormStatus() {
-  var formStatusDiv = globalYui.all("#formStatusDivId");
+  var formStatusDiv = Y.all("#formStatusDivId");
   // formStatusDiv.setContent("");
   formStatusDiv.setStyle("visibility", "hidden");
   formStatusDiv.hide();
-  formStatusDiv.set('className','');
+  formStatusDiv.set('className', '');
   formStatusDiv.addClass("formStatusBar");
 }
 
@@ -154,10 +155,10 @@ function setFormStatus(statusString, isE
   } else {
     formStatusDivCssClass = 'statusOk';
   }
-  var formStatusDiv = globalYui.all("#formStatusDivId");
+  var formStatusDiv = Y.all("#formStatusDivId");
   formStatusDiv.setStyle("visibility", "visible");
   formStatusDiv.show();
-  formStatusDiv.set('className','');
+  formStatusDiv.set('className', '');
   formStatusDiv.addClass("formStatusBar");
   formStatusDiv.addClass(formStatusDivCssClass);
   formStatusDiv.setContent(statusString);
@@ -167,11 +168,11 @@ function setFormStatus(statusString, isE
 }
 
 function fadeFormStatus() {
-  var formStatusDiv = globalYui.one("#formStatusDivId");
+  var formStatusDiv = Y.one("#formStatusDivId");
   formStatusDiv.addClass("formStatusBarZeroOpacity");
 }
 
-function convertDisplayType (displayType) {
+function convertDisplayType(displayType) {
   switch (displayType) {
     case "NODISPLAY":
       return "NODISPLAY";
@@ -184,121 +185,121 @@ function convertDisplayType (displayType
 
     case "ONOFF":
       return "checkbox";
-    
+
     default:
       return "text";
   }
 }
 
 function executeStage(inputUrl, renderStageFunction) {
-  globalYui.io(inputUrl, {
-      method: 'GET',
-      timeout : 10000,
-      on: {
-        success: function (x,o) {
-          globalYui.log("RAW JSON DATA: " + o.responseText);
-          // Process the JSON data returned from the server
-          try {
-            responseJson = globalYui.JSON.parse(o.responseText);
-          }
-          catch (e) {
-            hideLoadingImg();
-            alert("JSON Parse failed!");
-            return;
-          }
+  Y.io(inputUrl, {
+    method: 'GET',
+    timeout: 10000,
+    on: {
+      success: function (x, o) {
+        Y.log("RAW JSON DATA: " + o.responseText);
+        // Process the JSON data returned from the server
+        try {
+          responseJson = Y.JSON.parse(o.responseText);
+        }
+        catch (e) {
+          hideLoadingImg();
+          alert("JSON Parse failed!");
+          return;
+        }
 
-          globalYui.log("PARSED DATA: " + globalYui.Lang.dump(responseJson));
+        Y.log("PARSED DATA: " + Y.Lang.dump(responseJson));
 
-          if (responseJson.result != 0) {
-             hideLoadingImg();
-             // Error!
-             alert("Got error during getting data: " + responseJson.error); 
-             return;
-           }
-          responseJson = responseJson.response;
-          renderStageFunction(responseJson);
+        if (responseJson.result != 0) {
           hideLoadingImg();
-          return;
-        },
-        failure: function (x,o) {
-          alert("Async call failed!");
+          // Error!
+          alert("Got error during getting data: " + responseJson.error);
           return;
         }
+        responseJson = responseJson.response;
+        renderStageFunction(responseJson);
+        hideLoadingImg();
+        return;
+      },
+      failure: function (x, o) {
+        alert(App.io.DEFAULT_AJAX_ERROR_MESSAGE);
+        return;
       }
+    }
   });
 }
 
 function submitDataAndProgressToNextScreen(url, requestData, submitButton, thisScreenId, nextScreenId, nextScreenRenderFunction, errorHandlerFunction) {
   showLoadingImg();
-  globalYui.io(url, {
+  Y.io(url, {
 
-      method: 'POST',
-      data: globalYui.JSON.stringify(requestData),
-      timeout : 10000,
-      on: {
-        start: function(x, o) {
-          submitButton.set('disabled', true);
-          globalYui.log("In start function");
-          // showLoadingImg();
-        },
-        complete: function(x, o) {
-          submitButton.set('disabled', false);
-          globalYui.log("In stop function");
-          // hideLoadingImg();
-        },
-        success: function (x,o) {
+    method: 'POST',
+    data: Y.JSON.stringify(requestData),
+    timeout: 10000,
+    on: {
+      start: function (x, o) {
+        submitButton.set('disabled', true);
+        Y.log("In start function");
+        // showLoadingImg();
+      },
+      complete: function (x, o) {
+        submitButton.set('disabled', false);
+        Y.log("In stop function");
+        // hideLoadingImg();
+      },
+      success: function (x, o) {
+        submitButton.set('disabled', false);
+        Y.log("RAW JSON DATA: " + o.responseText);
+
+        // Process the JSON data returned from the server
+        try {
+          responseJson = Y.JSON.parse(o.responseText);
+        }
+        catch (e) {
           submitButton.set('disabled', false);
-          globalYui.log("RAW JSON DATA: " + o.responseText);
-
-          // Process the JSON data returned from the server
-          try {
-            responseJson = globalYui.JSON.parse(o.responseText);
-          }
-          catch (e) {
-            submitButton.set('disabled', false);
-            hideLoadingImg();
-            alert("JSON Parse failed!");
-            return;
-          }
+          hideLoadingImg();
+          alert("JSON Parse failed!");
+          return;
+        }
 
-          globalYui.log("PARSED DATA: " + globalYui.Lang.dump(responseJson));
+        Y.log("PARSED DATA: " + Y.Lang.dump(responseJson));
 
-          if (responseJson.result != 0) {
-             submitButton.set('disabled', false);
-             // Error!
-             globalYui.log("Got error during submit data!" + responseJson.error);
-             if ( errorHandlerFunction ) {
-               globalYui.log("Invoking error handler function");
-               errorHandlerFunction(responseJson);
-             } else {
-               alert("Got error during submit data!" + responseJson.error);
-             }
-             hideLoadingImg();
-             return;
-           }
-          responseJson = responseJson.response;
-
-          /* Done with this stage, transition to the next. */
-          transitionToNextStage( thisScreenId, requestData, nextScreenId, responseJson, nextScreenRenderFunction );
-        },
-        failure: function (x,o) {
+        if (responseJson.result != 0) {
           submitButton.set('disabled', false);
-          alert("Async call failed!");
+          // Error!
+          Y.log("Got error during submit data!" + responseJson.error);
+          if (errorHandlerFunction) {
+            Y.log("Invoking error handler function");
+            errorHandlerFunction(responseJson);
+          } else {
+            alert("Got error during submit data!" + responseJson.error);
+          }
+          hideLoadingImg();
+          return;
         }
+        responseJson = responseJson.response;
+
+        /* Done with this stage, transition to the next. */
+        transitionToNextStage(thisScreenId, requestData, nextScreenId, responseJson, nextScreenRenderFunction);
+      },
+      failure: function (x, o) {
+        submitButton.set('disabled', false);
+        alert(App.io.DEFAULT_AJAX_ERROR_MESSAGE);
       }
+    }
   });
 }
 
-function PeriodicDataPoller( dataSourceContext, responseHandler ) {
+function PeriodicDataPoller(dataSourceContext, responseHandler) {
 
   this.dataSourceContext = dataSourceContext;
 
   /* Smoothe out the optional bits of this.dataSourceContext. */
-  if( !this.dataSourceContext.pollInterval ) {
+  if (!this.dataSourceContext.pollInterval) {
     /* How often we poll. */
     this.dataSourceContext.pollInterval = 5000;
   }
-  if( !this.dataSourceContext.maxFailedAttempts ) {
+  if (!this.dataSourceContext.maxFailedAttempts) {
     /* How many failed attempts before we stop polling. */
     this.dataSourceContext.maxFailedAttempts = 25;
   }
@@ -308,11 +309,11 @@ function PeriodicDataPoller( dataSourceC
   /* Of course, we're not paused when we start off. */
   this.paused = false;
 
-  this.dataSource = new globalYui.DataSource.IO ({
+  this.dataSource = new Y.DataSource.IO({
     source: this.dataSourceContext.source
   });
 
-  this.dataSource.plug(globalYui.Plugin.DataSourceJSONSchema, {
+  this.dataSource.plug(Y.Plugin.DataSourceJSONSchema, {
     schema: this.dataSourceContext.schema
   });
 
@@ -325,32 +326,30 @@ function PeriodicDataPoller( dataSourceC
     request: this.dataSourceContext.request,
     callback: {
       success: function (e) {
-
-        /* Avoid race conditions in JS by not processing incoming responses 
+        /* Avoid race conditions in JS by not processing incoming responses
          * from the backend if the PDP is paused (which is our signal that
-         * a previous response is still in the middle of being processed). 
+         * a previous response is still in the middle of being processed).
          */
-        if( !(this.isPaused()) ) {
+        if (!(this.isPaused())) {
           /* Reset our failure count every time we succeed. */
           this.dataSourcePollFailureCount = 0;
 
           /* Invoke user-pluggable code. */
-          if( this.responseHandler.success ) {
-            this.responseHandler.success( e, this );
+          if (this.responseHandler.success) {
+            this.responseHandler.success(e, this);
           }
         }
       }.bind(this),
 
       failure: function (e) {
-
-        if( !(this.isPaused()) ) {
+        if (!(this.isPaused())) {
           ++this.dataSourcePollFailureCount;
 
-          if( this.dataSourcePollFailureCount > this.dataSourceContext.maxFailedAttempts ) {
+          if (this.dataSourcePollFailureCount > this.dataSourceContext.maxFailedAttempts) {
 
             /* Invoke user-pluggable code. */
-            if( this.responseHandler.failure ) {
-              this.responseHandler.failure( e, this );
+            if (this.responseHandler.failure) {
+              this.responseHandler.failure(e, this);
             }
 
             /* No point making any more attempts. */
@@ -363,80 +362,79 @@ function PeriodicDataPoller( dataSourceC
 }
 
 /* Start polling. */
-PeriodicDataPoller.prototype.start = function() {
+PeriodicDataPoller.prototype.start = function () {
 
   this.dataSourcePollHandle = this.dataSource.setInterval
-    ( this.dataSourceContext.pollInterval, this.dataSourcePollRequestContext );
-}
+    (this.dataSourceContext.pollInterval, this.dataSourcePollRequestContext);
+};
 
 /* Stop polling. */
-PeriodicDataPoller.prototype.stop = function() {
+PeriodicDataPoller.prototype.stop = function () {
 
   /* Always unPause() during stop(), so the next start() won't be neutered. */
   this.unPause();
-  this.dataSource.clearInterval( this.dataSourcePollHandle );
-}
+  this.dataSource.clearInterval(this.dataSourcePollHandle);
+};
 
-/* When the PDP is paused, the polling continues on its regular fixed 
+/* When the PDP is paused, the polling continues on its regular fixed
  * interval, but this.responseHandler is not invoked, thus avoiding
  * a race condition (at least) in JS.
  *
  * TODO XXX Improve upon this to not even make calls to the backend
  * while not losing our periodicity.
  */
-PeriodicDataPoller.prototype.pause = function() {
+PeriodicDataPoller.prototype.pause = function () {
 
   this.paused = true;
-}
+};
 
-PeriodicDataPoller.prototype.unPause = function() {
+PeriodicDataPoller.prototype.unPause = function () {
 
   this.paused = false;
-}
+};
 
-PeriodicDataPoller.prototype.isPaused = function() {
+PeriodicDataPoller.prototype.isPaused = function () {
 
   return this.paused;
-}
+};
 
-/* Perform a one-time poll. 
+/* Perform a one-time poll.
  *
- * Meant to be used when the polling is not at a set frequency (as with the 
- * start()/stop() pair), and is instead meant to be under explicit 
- * control of the application. 
+ * Meant to be used when the polling is not at a set frequency (as with the
+ * start()/stop() pair), and is instead meant to be under explicit
+ * control of the application.
  */
-PeriodicDataPoller.prototype.pollOnce = function() {
+PeriodicDataPoller.prototype.pollOnce = function () {
 
-  globalYui.io(this.dataSourceContext.source + this.dataSourcePollRequestContext.request, {
+  Y.io(this.dataSourceContext.source + this.dataSourcePollRequestContext.request, {
     on: this.dataSourcePollRequestContext.callback
   });
-}
-
-function titleCase(word){
-  return word.substr(0,1).toUpperCase() + word.substr(1).toLowerCase();
-}
-
-function generateHMCUrl( uriPath ) {
-
-  var url = '';
-
-  /* By default, go to the HMC home page. */
-  uriPath = ( typeof uriPath == "undefined" ) ? '/hmc/html/index.php' : uriPath;
-    
-  var currentUrl = window.location.href;
-  globalYui.log('Current URL: ' + currentUrl);
-  var currentPathPos = currentUrl.indexOf(window.location.pathname);
-  globalYui.log('Current Path Pos: ' + currentPathPos);
-
-  if( -1 != currentPathPos ) {
-    url = currentUrl.substr(0, currentPathPos) + uriPath;
-  }
+};
 
-  return url;
+function titleCase(word) {
+  return word.substr(0, 1).toUpperCase() + word.substr(1).toLowerCase();
 }
 
+// Create namespace and export functionality.
+// We'll remove globally defined functions and properties eventually
+// For now we need to keep the non-namespaced global functions and properties
+// so that our existing code continues to work without refactoring.
 var App = App || {
-  Props: {
-    managerServiceName: 'Ambari'
+  props: {
+    managerServiceName: 'Ambari',
+    clusterName: '',
+    homeUrl: '/hmc/html/'
+  },
+  io: {
+    PeriodicDataPoller: PeriodicDataPoller,
+    DEFAULT_AJAX_TIMEOUT_MS: 10000,
+    FETCH_LOG_TIMEOUT_MS: 20000,
+    DEFAULT_AJAX_ERROR_MESSAGE: 'Failed to retrieve information from the server'
+  },
+  ui: {
+    createInfoPanel: createInfoPanel,
+    hideLoadingOverlay: hideLoadingImg
   }
 };
+
+App.Props = App.props;



Mime
View raw message