2007-12-03 18:16:38 +00:00
|
|
|
var GroupNodeTableUpdater = {};
|
2007-10-26 22:44:33 +00:00
|
|
|
|
2007-12-03 18:16:38 +00:00
|
|
|
GroupNodeTableUpdater.updateCommandResult = function() {
|
2007-10-26 22:44:33 +00:00
|
|
|
var commandQueryId = "commandQuery";
|
|
|
|
var copyChkBoxId = "copyChkBox";
|
|
|
|
var nodenameHiddenTxtId = "nodename";
|
|
|
|
var nodegrpsCboBoxId = "nodegrpsCboBox";
|
|
|
|
var pshChkBoxId = "pshChkBox";
|
|
|
|
|
|
|
|
var serialChkBoxId = "serialChkBox";
|
|
|
|
var verifyChkBoxId = "verifyChkBox";
|
|
|
|
var fanoutTxtBoxId = "fanoutTxtBox";
|
|
|
|
var userIDTxtBoxId = "userIDTxtBox";
|
|
|
|
var rshellTxtBoxId = "rshellTxtBox";
|
|
|
|
var rshellTxtBoxId = "rshellTxtBox";
|
|
|
|
var monitorChkBoxId = "monitorChkBox";
|
|
|
|
var ret_codeChkBoxId = "ret_codeChkBox";
|
|
|
|
|
|
|
|
var copyChkBoxObj = $(copyChkBoxId);
|
|
|
|
var commandQueryObj = $(commandQueryId);
|
|
|
|
var nodenameHiddenTxtObj = $(nodenameHiddenTxtId);
|
|
|
|
var nodegrpsCboBoxObj = $(nodegrpsCboBoxId);
|
|
|
|
var pshChkBoxObj = $(pshChkBoxId);
|
|
|
|
|
|
|
|
var serialChkBoxObj = $(serialChkBoxId);
|
|
|
|
var verifyChkBoxObj = $(verifyChkBoxId);
|
|
|
|
var fanoutTxtBoxObj = $(fanoutTxtBoxId);
|
|
|
|
var userIDTxtBoxObj = $(userIDTxtBoxId);
|
|
|
|
var rshellTxtBoxObj = $(rshellTxtBoxId);
|
|
|
|
var monitorChkBoxObj = $(monitorChkBoxId);
|
|
|
|
var ret_codeChkBoxObj = $(ret_codeChkBoxId);
|
|
|
|
|
|
|
|
// Do AJAX call and get HTML here.
|
|
|
|
var url = "dsh_action.php";
|
|
|
|
var postPara = "command=" + encodeURIComponent(commandQueryObj.value);
|
|
|
|
postPara += "&node=" + encodeURIComponent(nodenameHiddenTxtObj.value);
|
|
|
|
postPara += "&nodegrps=" + encodeURIComponent(nodegrpsCboBoxObj.options[nodegrpsCboBoxObj.selectedIndex].value);
|
|
|
|
if (copyChkBoxObj.checked == true) postPara += "©=on"; else postPara += "©=off";
|
|
|
|
if (pshChkBoxObj.checked == true) postPara += "&psh=on"; else postPara += "&psh=off";
|
|
|
|
if (serialChkBoxObj.checked == true) postPara += "&serial=on"; else postPara += "&serial=off";
|
|
|
|
if (verifyChkBoxObj.checked == true) postPara += "&verify=on"; else postPara += "&verify=off";
|
|
|
|
postPara += "&fanout=" + encodeURIComponent(fanoutTxtBoxObj.value);
|
|
|
|
postPara += "&userID=" + encodeURIComponent(userIDTxtBoxObj.value);
|
|
|
|
postPara += "&rshell=" + encodeURIComponent(rshellTxtBoxObj.value);
|
|
|
|
if (monitorChkBoxObj.checked == true) postPara += "&monitor=on"; else postPara += "&monitor=off";
|
|
|
|
if (ret_codeChkBoxObj.checked == true) postPara += "&ret_code=on"; else postPara += "&ret_code=off";
|
|
|
|
|
|
|
|
new Ajax.Request(url, {
|
|
|
|
method: 'post', postBody: postPara,
|
|
|
|
onSuccess: function(transport) {
|
|
|
|
var htmlContent = transport.responseText;
|
|
|
|
|
|
|
|
var win = new Window({className: "dialog",
|
|
|
|
width: 350,
|
|
|
|
height: 400,
|
|
|
|
zIndex: 100,
|
|
|
|
resizable: true,
|
|
|
|
title: "Running commands",
|
|
|
|
showEffect: Effect.BlindDown,
|
|
|
|
hideEffect: Effect.SwitchOff,
|
|
|
|
draggable: true,
|
|
|
|
wiredDrag: true});
|
|
|
|
|
|
|
|
win.getContent().innerHTML = htmlContent;
|
|
|
|
//win.setStatusBar("Status bar info");
|
|
|
|
win.showCenter();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides/shows the nodes in a node group table.
|
|
|
|
*/
|
2007-12-03 18:16:38 +00:00
|
|
|
GroupNodeTableUpdater.toggleSection = function(nodeGroupName) {
|
2007-10-26 22:44:33 +00:00
|
|
|
var tableId = "div_" + nodeGroupName;
|
|
|
|
var imageId = tableId + '-im';
|
|
|
|
var expandSpanId = "img_gr_" + nodeGroupName;
|
|
|
|
|
|
|
|
var tableObj = $(tableId);
|
|
|
|
|
|
|
|
if(null == tableObj) {
|
|
|
|
alert('Error: section ' + tableId + ' not found.');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
var imageTag = $(imageId);
|
|
|
|
var expandSpanObj = $(expandSpanId);
|
|
|
|
|
|
|
|
if(!tableObj.style.display || tableObj.style.display == 'inline') {
|
|
|
|
// the inner table is currently visible
|
|
|
|
tableObj.style.display = 'none';
|
2007-11-28 19:37:25 +00:00
|
|
|
imageTag.src = "../images/plus-sign.gif";
|
2007-10-26 22:44:33 +00:00
|
|
|
expandSpanObj.title = "Click to expand section";
|
|
|
|
} else {
|
|
|
|
// the inner table is currently invisible
|
|
|
|
tableObj.style.display = 'inline';
|
2007-11-28 19:37:25 +00:00
|
|
|
imageTag.src = "../images/minus-sign.gif";
|
2007-10-26 22:44:33 +00:00
|
|
|
expandSpanObj.title = "Click to collapse section";
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2007-12-03 18:16:38 +00:00
|
|
|
GroupNodeTableUpdater.getFailureSpanHTML = function(nodeGroupName) {
|
2007-10-26 22:44:33 +00:00
|
|
|
var spanId = "nodegroup_" + nodeGroupName + "_failure";
|
|
|
|
var html = '<span id="' + spanId + '">There was a problem loading the node for the group ' + nodeGroupName + '</span>';
|
|
|
|
return html;
|
|
|
|
}
|
|
|
|
|
2007-12-03 18:16:38 +00:00
|
|
|
GroupNodeTableUpdater.getLoadingSpanHTML = function(nodeGroupName) {
|
2007-10-26 22:44:33 +00:00
|
|
|
var spanId = "nodegroup_" + nodeGroupName + "_loading";
|
2007-11-28 19:37:25 +00:00
|
|
|
var html = '<span id="' + spanId + '" style="padding-left: 0.5em; display: none;"><img alt="Loading ..." src="../images/ajax-loader.gif" />Loading ...</span>';
|
2007-10-26 22:44:33 +00:00
|
|
|
return html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2007-12-03 18:16:38 +00:00
|
|
|
* This is the onCreate callback for the AJAX request made in GroupNodeTableUpdater.updateNodeList.
|
2007-10-26 22:44:33 +00:00
|
|
|
* It updates the interface to show that the request is loading.
|
|
|
|
* See http://www.prototypejs.org/api/ajax/options
|
|
|
|
*/
|
2007-12-03 18:16:38 +00:00
|
|
|
GroupNodeTableUpdater.updateNodeListLoading = function(nodeGroupName) {
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
var spanId = 'img_gr_' + nodeGroupName;
|
2007-12-03 18:16:38 +00:00
|
|
|
new Insertion.Bottom(spanId, GroupNodeTableUpdater.getLoadingSpanHTML(nodeGroupName));
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
var loadingSpanId = "nodegroup_" + nodeGroupName + "_loading";
|
|
|
|
new Effect.Appear(loadingSpanId);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2007-12-03 18:16:38 +00:00
|
|
|
* This is the onFailure callback for the AJAX request made in GroupNodeTableUpdater.updateNodeList.
|
2007-10-26 22:44:33 +00:00
|
|
|
* It updates the interface to show that the request failed.
|
|
|
|
* See http://www.prototypejs.org/api/ajax/options
|
|
|
|
*/
|
2007-12-03 18:16:38 +00:00
|
|
|
GroupNodeTableUpdater.updateNodeListFailure = function(nodeGroupName) {
|
2007-10-26 22:44:33 +00:00
|
|
|
var spanId = 'img_gr_' + nodeGroupName;
|
2007-12-03 18:16:38 +00:00
|
|
|
new Insertion.Bottom(spanId, GroupNodeTableUpdater.getFailureSpanHTML(nodeGroupName));
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
var failureSpanId = "nodegroup_" + nodeGroupName + "_failure";
|
|
|
|
new Effect.Shake(failureSpanId);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add table rows representing nodes to the table that represents the node group
|
|
|
|
* identified by the given name.
|
|
|
|
*/
|
2007-12-03 18:16:38 +00:00
|
|
|
GroupNodeTableUpdater.updateNodeList = function(nodeGroupName) {
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
var tableId = "div_" + nodeGroupName;
|
|
|
|
var imageId = tableId + '-im';
|
|
|
|
var expandSpanId = "img_gr_" + nodeGroupName;
|
|
|
|
|
2007-12-03 18:16:38 +00:00
|
|
|
var tableObj = $(tableId);
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
if(null == tableObj) {
|
|
|
|
alert('Error: section ' + tableId + ' not found.');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-12-03 18:16:38 +00:00
|
|
|
var imageTag = $(imageId);
|
|
|
|
var expandSpanObj = $(expandSpanId);
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
if(!tableObj.style.display || tableObj.style.display == 'inline') {// currently visible
|
|
|
|
|
|
|
|
tableObj.style.display = 'none';
|
2007-11-28 19:37:25 +00:00
|
|
|
imageTag.src = "../images/plus-sign.gif";
|
2007-10-26 22:44:33 +00:00
|
|
|
expandSpanObj.title = "Click to expand section";
|
|
|
|
|
|
|
|
} else { //currently invisible
|
2007-11-28 19:37:25 +00:00
|
|
|
imageTag.src = "../images/minus-sign.gif";
|
2007-10-26 22:44:33 +00:00
|
|
|
expandSpanObj.title = "Click to collapse section";
|
|
|
|
|
|
|
|
var target = "div_" + nodeGroupName;
|
|
|
|
var pars = 'nodeGroupName=' + nodeGroupName;
|
|
|
|
var URL = 'nodes_by_group.php';
|
|
|
|
|
|
|
|
// Check whether the table already exists and has already been updated?
|
|
|
|
|
|
|
|
//var URL = "webservice.php?method=getXCATNodeRows&nodeGroupName=" + encodeURIComponent(nodeGroupName);
|
|
|
|
|
2007-12-03 18:16:38 +00:00
|
|
|
//alert('About to call Ajax.Updater');
|
2007-10-26 22:44:33 +00:00
|
|
|
new Ajax.Updater(target, URL, {
|
|
|
|
method: 'post', parameters: pars,
|
2007-12-03 18:16:38 +00:00
|
|
|
onCreate: function() { GroupNodeTableUpdater.updateNodeListLoading(nodeGroupName) }, // Needs Prototype 1.5.1
|
|
|
|
onFailure: function() {GroupNodeTableUpdater.updateNodeListFailure(nodeGroupName) },
|
2007-10-26 22:44:33 +00:00
|
|
|
onComplete: function() {new Effect.Fade("nodegroup_" + nodeGroupName + "_loading")}
|
|
|
|
});
|
|
|
|
|
|
|
|
// the inner table is currently invisible
|
|
|
|
tableObj.style.display = 'inline';
|
2007-12-03 18:16:38 +00:00
|
|
|
//alert('Back from Ajax.Updater');
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-12-03 18:16:38 +00:00
|
|
|
//GroupNodeTableUpdater.toggleSection(nodeGroupName);
|
2007-10-26 22:44:33 +00:00
|
|
|
}
|