More clean up of web interface and clean up of ajax operations

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@90 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
bp-sawyers 2007-11-28 19:37:25 +00:00
parent a003f27576
commit 7bc9eaeef5
8 changed files with 20 additions and 99 deletions

View File

@ -89,12 +89,12 @@ XCATui.toggleSection = function(nodeGroupName) {
if(!tableObj.style.display || tableObj.style.display == 'inline') {
// the inner table is currently visible
tableObj.style.display = 'none';
imageTag.src = "./images/plus-sign.gif";
imageTag.src = "../images/plus-sign.gif";
expandSpanObj.title = "Click to expand section";
} else {
// the inner table is currently invisible
tableObj.style.display = 'inline';
imageTag.src = "./images/minus-sign.gif";
imageTag.src = "../images/minus-sign.gif";
expandSpanObj.title = "Click to collapse section";
}
@ -109,7 +109,7 @@ XCATui.getFailureSpanHTML = function(nodeGroupName) {
XCATui.getLoadingSpanHTML = function(nodeGroupName) {
var spanId = "nodegroup_" + nodeGroupName + "_loading";
var html = '<span id="' + spanId + '" style="padding-left: 0.5em; display: none;"><img alt="Loading ..." src="./images/ajax-loader.gif" />Loading ...</span>';
var html = '<span id="' + spanId + '" style="padding-left: 0.5em; display: none;"><img alt="Loading ..." src="../images/ajax-loader.gif" />Loading ...</span>';
return html;
}
@ -150,24 +150,24 @@ XCATui.updateNodeList = function(nodeGroupName) {
var imageId = tableId + '-im';
var expandSpanId = "img_gr_" + nodeGroupName;
var tableObj = $(tableId);
var tableObj = document.getElementById(tableId); //$(tableId);
if(null == tableObj) {
alert('Error: section ' + tableId + ' not found.');
return false;
}
var imageTag = $(imageId);
var expandSpanObj = $(expandSpanId);
var imageTag = document.getElementById(imageId); //$(imageId);
var expandSpanObj = document.getElementById(expandSpanId); //$(expandSpanId);
if(!tableObj.style.display || tableObj.style.display == 'inline') {// currently visible
tableObj.style.display = 'none';
imageTag.src = "./images/plus-sign.gif";
imageTag.src = "../images/plus-sign.gif";
expandSpanObj.title = "Click to expand section";
} else { //currently invisible
imageTag.src = "./images/minus-sign.gif";
imageTag.src = "../images/minus-sign.gif";
expandSpanObj.title = "Click to collapse section";
var target = "div_" + nodeGroupName;
@ -178,6 +178,7 @@ XCATui.updateNodeList = function(nodeGroupName) {
//var URL = "webservice.php?method=getXCATNodeRows&nodeGroupName=" + encodeURIComponent(nodeGroupName);
alert('About to call Ajax.Updater');
new Ajax.Updater(target, URL, {
method: 'post', parameters: pars,
onCreate: function() { XCATui.updateNodeListLoading(nodeGroupName) }, // Needs Prototype 1.5.1
@ -187,6 +188,7 @@ XCATui.updateNodeList = function(nodeGroupName) {
// the inner table is currently invisible
tableObj.style.display = 'inline';
alert('Back from Ajax.Updater');
}

View File

@ -2,7 +2,8 @@
/**
* Produces HTML for use in the interface.
*/
//require_once("config.php");
if (!$TOPDIR) { $TOPDIR = '..'; }
require_once "$TOPDIR/lib/functions.php";
class GroupNodeTable {

View File

@ -14,7 +14,7 @@ class XCATCommandRunner {
function XCATCommandRunner() {
$this->XCATRoot = ''; //'/opt/xcat/bin'; //todo: get rid of these
$this->CurrDir = ''; //'/opt/xcat/web';
$this->Sudo = '\bin\sudo ';
$this->Sudo = '/bin/sudo ';
$this->XCATNodeManager = &XCATNodeManager::getInstance();
$this->XCATNodeGroupManager = &XCATNodeGroupManager::getInstance();
@ -44,7 +44,7 @@ class XCATCommandRunner {
* @return An array containing the name of all nodes in the group.
*/
function getNodeNamesByGroupName($groupName) {
$cmdString = $this->Sudo . $this->XCATRoot . "/nodels $groupName";
$cmdString = $this->Sudo . "nodels $groupName";
$outputStat = $this->runCommand($cmdString);
return $outputStat["output"];
@ -55,7 +55,7 @@ class XCATCommandRunner {
*/
function getXCATNodeByName($nodeName) {
$cmdString = $this->Sudo . $this->XCATRoot . "/nodestat $nodeName";
$cmdString = $this->Sudo . "nodestat $nodeName";
$outputStat = $this->runCommand($cmdString);
$xcn = new XCATNode();
@ -98,7 +98,7 @@ class XCATCommandRunner {
* @return An array containing the name of every node group.
*/
function getAllGroupNames() {
$cmdString = $this->Sudo . $this->XCATRoot . "/listattr";
$cmdString = $this->Sudo . "listattr";
$outputStat = $this->runCommand($cmdString);
return $outputStat["output"];

View File

@ -1,55 +0,0 @@
<?php
require_once("../lib/GroupNodeTable.class.php");
/**
* This class exposes an API for calling the XCAT PHP classes.
* It works in conjunction with webservice.php .
*
* This class delegates all of its methods to other classes
* that do all of the actual work.
*/
class XCATWebservice {
/**
* @param String methodName The name of a static method in the XCATWebservice class.
* @param Hash parameterHash Parameter names (keys) and values (values) for the method to be called.
*/
function processRequest($methodName, $parameterHash) {
// Only static method can be called when the class name is also provided.
$classMethod = array("XCATWebservice", $methodName);
$parameterValues = array_values($parameterHash);
call_user_func_array($classMethod, $parameterValues);
}
/**
* @param String methodName The name of the method whose parameter
* names we want.
* @return Returns an array of strings, representing the names of the
* parameters this method expects. Parameters are provided in
* the order they are expected.
*/
function getMethodParameters($methodName) {
$parameterNames = array();
switch($methodName) {
case "getXCATNodeRows":
$parameterNames = array("nodeGroupName");
break;
// Add case statements for other methods here.
default:
$parameterNames = NULL;
break;
}
return $parameterNames;
}
function getXCATNodeRows($nodeGroupName) {
$html = GroupNodeTable::getNodeTableRow($nodeGroupName);
echo $html;
}
}
?>

View File

@ -9,7 +9,7 @@ if (isAIX()) { $aixDisabled = 'disabled'; }
require_once("$TOPDIR/lib/GroupNodeTable.class.php");
require_once("$TOPDIR/lib/XCAT/XCATCommand/XCATCommandRunner.class.php");
insertHeader('Groups', array('groups.css'), NULL, array('machines','groups'));
insertHeader('Groups', array('groups.css'), array("$TOPDIR/js_xcat/ui.js","$TOPDIR/js/prototype.js"), array('machines','groups'));
echo "<div id=content align=center>\n";

View File

@ -1,6 +1,7 @@
<?php
require_once("lib/GroupNodeTable.class.php");
require_once("lib/XCAT/XCATCommand/XCATCommandRunner.class.php");
$TOPDIR = '..';
require_once("$TOPDIR/lib/GroupNodeTable.class.php");
require_once("$TOPDIR/lib/XCAT/XCATCommand/XCATCommandRunner.class.php");
$nodeGroupName = @$_REQUEST["nodeGroupName"];

View File

@ -1,10 +0,0 @@
<?php
require_once("lib/XCAT/XCATCommand/XCATCommandRunner.class.php");
require_once("lib/XCAT/XCATNode/XCATNodeManager.class.php");
require_once("lib/XCAT/XCATNodeGroup/XCATNodeGroupManager.class.php");
$cmdRunner = new XCATCommandRunner($xCAT_ROOT);
$var = $cmdRunner->getAllXCATNodeGroups();
echo "$var.";
print_r($var);
?>

View File

@ -1,18 +0,0 @@
<?php
/**
* This file works in conjunction with lib/XCAT/webservice/XCATWebservice.class.php
*/
require_once("lib/XCAT/webservice/XCATWebservice.class.php");
$methodName = $_REQUEST["method"];
$parameterNames = XCATWebservice::getMethodParameters($methodName);
$parameterHash = array();
foreach($parameterNames as $parameterName) {
$parameterHash[$parameterName] = $_REQUEST[$parameterName];
}
XCATWebservice::processRequest($methodName, $parameterHash);
?>