/* * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ function cleanUpTxnProgress () { globalYui.one('#installationWizardProgressBarDivId').setStyle('display', 'block'); globalYui.one('#txnProgressStatusMessageDivId').setContent(''); globalYui.one('#blackScreenDivId').setStyle('display', 'none'); globalYui.one('#txnProgressStatusDivId').setStyle('display', 'none'); globalYui.one('#addNodesCoreDivId').setStyle('display', 'none'); globalYui.one('#txnProgressCoreDivId').setStyle('display', 'none'); //globalYui.one('#txnProgressContentDivId').setContent // ( '' ); } function generateSingleDiscoverProgressStateMarkup(discoverProgressStateTitle, progressState) { var stateClass; var barClass; switch (progressState) { case "SUCCESS": stateClass = 'txnProgressStateDone'; barClass = 'progress progress-success'; break; case "STARTING": case "STARTED": case "IN_PROGRESS": stateClass = 'txnProgressStateInProgress'; //barClass = 'progress progress-striped active'; barClass = 'progress'; break; case "FAILED": case "TOTALFAILURE": stateClass = 'txnProgressStateError'; barClass = 'progress progress-danger'; break; default: // PENDING stateClass = 'txnProgressStatePending'; barClass = 'progress'; break; } var barMarkup = '
'; if (stateClass == 'txnProgressStateInProgress') { barMarkup = '
' + barMarkup + '
'; } var markup = '
  • ' + barMarkup + '
  • '; //globalYui.log('progress state=' + progressState + ', markup=' + markup); return markup; } function renderProgress (discoverProgressInfo) { var txnProgressShown = false; var pollingStopped = false; var discoverProgressDataSource = new globalYui.DataSource.IO ({ source: '../php/frontend/nodesActionProgress.php' }); discoverProgressDataSource.plug(globalYui.Plugin.DataSourceJSONSchema, { schema: { metaFields: { progressStates: 'progressStates', currentProgressStateIndex: 'currentProgressStateIndex', encounteredError: 'encounteredError', stateInfo: 'stateInfo' } } }); function clearActiveProgressBar() { var bar = globalYui.one('#activeProgressBar'); if (bar != null) { bar.remove(); } globalYui.on('windowresize', function(e) { setActiveProgressBarInPlace(); }); } function setActiveProgressBarInPlace() { // 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. var bar = globalYui.one('#activeProgressBar'); var barContainer = globalYui.one('#activeProgressBarContainer'); if (barContainer != null) { if (bar == null) { globalYui.one("body").append('
    '); bar = globalYui.one('#activeProgressBar'); } bar.setStyle('display', 'block'); if (bar.getX() != barContainer.getX() || bar.getY() != barContainer.getY()) { bar.setXY(barContainer.getXY()); } } else if (bar != null) { bar.setStyle('display', 'none'); } } function runPollTask() { discoverProgressDataSource.sendRequest({ request: '?clusterName=' + discoverProgressInfo.clusterName + '&txnId=' + discoverProgressInfo.txnId + '&action=addNodes', callback: { success: function (e) { if (pollingStopped) { return; } globalYui.one("#txnProgressHeader").setContent('Node Discovery and Preparation'); var stateInfo = e.response.meta.stateInfo; var discoverProgressStates = e.response.meta.progressStates; var stateInfoLength = 0; var count = 0; var lastTxnId = 0; var discoverProgressMarkup = ''; globalYui.log('About to generate markup: ' + discoverProgressMarkup); globalYui.one('#txnProgressContentDivId').setContent(discoverProgressMarkup); if (!txnProgressShown) { globalYui.one('#txnProgressCoreDivId').setStyle('display','block'); txnProgressShown = true; } setActiveProgressBarInPlace(); if (!pollingStopped) { poll(); } }, failure: function (e) { alert('Failed to fetch more progress!'); /* No point making any more attempts. */ pollingStopped = true; } } }); } function poll() { window.setTimeout(runPollTask, 3000); } clearActiveProgressBar(); runPollTask(); }