Files
alfresco-community-repo/source/web/scripts/ajax/deployment.js
Derek Hulley 6e4730ed64 Merged V2.2 to HEAD
7536: Encoded all outputted strings to avoid cross-site scripting issues
         Fixed potential issue where same id for a div could be used multiple times on one page
   7537: Ensured no passwords are logged when deployment debug is turned on
   7538: Fixed ordering of deployment attempts in 'more reports' panel
   7539: Allocated test server is now released when a user sandbox is deleted
   7540: Merged V2.1 to V2.2
      7411: This makes issuers compatible with clustering without a huge performance drop
   7547: AWC-1711 (contribution) - simple workflow actions are not displayed if the user does not have write permission
   7548: Fixed IE scrolling issue when editing deployment server config
   7551: Changed the way scrolling is done to support IE6 (for deployment server config editing)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8414 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2008-03-03 13:51:55 +00:00

233 lines
6.5 KiB
JavaScript

Alfresco.DeploymentMonitor = function(ids, pollingFreq, failedMsg, successMsg)
{
this.ids = ids;
this.url = getContextPath() + "/ajax/invoke/DeploymentProgressBean.getStatus?ids=" + this.ids;
this.pollingFreq = pollingFreq;
this.failedMsg = failedMsg;
this.successMsg = successMsg;
}
Alfresco.DeploymentMonitor.prototype =
{
ids: null,
url: null,
pollingFreq: 5,
failedMsg: null,
successMsg: null,
retrieveDeploymentStatus: function()
{
YAHOO.util.Connect.asyncRequest('GET', this.url,
{
success: this.processResults,
failure: this.handleError,
scope: this
},
null);
},
processResults: function(ajaxResponse)
{
var xml = ajaxResponse.responseXML.documentElement;
var statuses = xml.getElementsByTagName('target-server');
var noInProgress = statuses.length;
if (noInProgress > 0)
{
for (var x = 0; x < noInProgress; x++)
{
var target = statuses[x];
var id = target.getAttribute('id');
var finished = target.getAttribute('finished');
var url = target.getAttribute('url');
var reason = target.getAttribute('reason');
if (finished == 'true')
{
var successful = target.getAttribute('successful');
var icon = document.getElementById(id + '_icon');
if (icon != null)
{
var image = (successful == 'true') ? 'successful' : 'failed';
icon.src = '/alfresco/images/icons/deploy_' + image + '.gif';
}
var statusElem = document.getElementById(id + '_status');
if (statusElem != null)
{
var msg = (successful == 'true') ? this.successMsg : this.failedMsg;
statusElem.innerHTML = msg;
}
var msgElem = document.getElementById(id + '_msg');
if (msgElem != null)
{
if (successful == 'true')
{
if (url != null && url.length > 0)
{
msgElem.innerHTML = "<a target='new' href='" + url + "'>" + url + "</a>";
}
}
else
{
if (reason != null && reason.length > 0)
{
msgElem.innerHTML = "<span style='color: #e00028'>" + reason + "</span>";
}
}
}
}
}
// there are still outstanding deployments, refresh in a few seconds
setTimeout('Alfresco.monitor.retrieveDeploymentStatus()', this.pollingFreq);
}
},
handleError: function(ajaxResponse)
{
handleErrorYahoo(ajaxResponse.status + ' ' + ajaxResponse.statusText);
}
}
var deployActionButtonPressed = false;
Alfresco.checkDeployConfigPage = function()
{
// make sure the relevant fields are visible for current deploy type
Alfresco.deployServerTypeChanged();
// make sure add/edit button is disabled if no host has been supplied
Alfresco.checkDeployConfigButtonState();
var button = document.getElementById('wizard:wizard-body:deployActionButton');
if (button != null)
{
document.getElementById("wizard").onsubmit = Alfresco.validateDeployConfig;
button.onclick = function() {deployActionButtonPressed = true; clear_wizard();}
document.getElementById('wizard:wizard-body:deployServerHost').focus();
}
// if a scroll to id has been set, scroll there
if (window.SCROLL_TO_SERVER_CONFIG_ID)
{
Alfresco.scrollToEditServer(SCROLL_TO_SERVER_CONFIG_ID);
}
}
Alfresco.checkDeployConfigButtonState = function()
{
var host = document.getElementById('wizard:wizard-body:deployServerHost');
var button = document.getElementById('wizard:wizard-body:deployActionButton');
if (button != null)
{
if (host != null && host.value.length == 0)
{
button.disabled = true;
}
else
{
button.disabled = false;
}
}
}
Alfresco.validateDeployConfig = function()
{
if (deployActionButtonPressed)
{
deployActionButtonPressed = false;
var valid = true;
var port = document.getElementById('wizard:wizard-body:deployServerPort');
if (port != null && port.value.length > 0)
{
if (isNaN(port.value))
{
alert(MSG_PORT_MUST_BE_NUMBER);
port.focus();
valid = false;
}
}
return valid;
}
else
{
return true;
}
}
Alfresco.deployServerTypeChanged = function()
{
var typeDropDown = document.getElementById('wizard:wizard-body:deployServerType');
if (typeDropDown != null)
{
var selectedType = typeDropDown.options[typeDropDown.selectedIndex].value;
// show or hide the label
var autoDeployLabel = document.getElementById('autoDeployLabel');
if (autoDeployLabel != null)
{
if (selectedType == "test")
{
autoDeployLabel.style.display = "none";
}
else
{
autoDeployLabel.style.display = "block";
}
}
// show or hide the checkbox
var autoDeployCheckbox = document.getElementById('wizard:wizard-body:autoDeployCheckbox');
if (autoDeployCheckbox != null)
{
if (selectedType == "test")
{
autoDeployCheckbox.style.display = "none";
}
else
{
autoDeployCheckbox.style.display = "block";
}
}
}
}
Alfresco.scrollToEditServer = function(serverId)
{
var serverForm = document.getElementById(serverId);
if (serverForm != null)
{
var yPos = serverForm.offsetTop;
window.scrollTo(0, yPos);
}
}
Alfresco.toggleDeploymentDetails = function(icon, server)
{
var currentState = icon.className;
var detailsDiv = document.getElementById(server + '-deployment-details');
if (currentState == 'collapsed')
{
icon.src = getContextPath() + '/images/icons/expanded.gif';
icon.className = 'expanded';
if (detailsDiv != null)
{
detailsDiv.style.display = 'block';
}
}
else
{
icon.src = getContextPath() + '/images/icons/collapsed.gif';
icon.className = 'collapsed';
if (detailsDiv != null)
{
detailsDiv.style.display = 'none';
}
}
}