diff --git a/xCAT-web/config/prefs.php b/xCAT-web/config/prefs.php index e29b87bfe..162335617 100644 --- a/xCAT-web/config/prefs.php +++ b/xCAT-web/config/prefs.php @@ -1,54 +1,53 @@ -
- - - - - - - - - -
Number of nodes per display: - "> -

-

-
-
- - - - - \ No newline at end of file + +EOS; +?> \ No newline at end of file diff --git a/xCAT-web/index.php b/xCAT-web/index.php index 8595db178..63cf1051f 100644 --- a/xCAT-web/index.php +++ b/xCAT-web/index.php @@ -2,6 +2,18 @@ // Main page of the xCAT web interface, but will redirect to the default page -header( 'Location: machines/groups.php' ) ; +$TOPDIR = '.'; +require_once "$TOPDIR/lib/functions.php"; + +// First try to get the cookie of the last visited page +if (isset($_COOKIE['currentpage'])) { + //echo "

here

\n"; + $keys = $_COOKIE['currentpage']; + $m = $MENU[$keys[0]]; // this gets us to the menu choice for the top menu in the data structure + $url = $m['list'][$keys[1]]['url']; // get to the list of submenu choices, choose the proper one, and get its url + //echo "

url: $url, m[label]: " . $m['label'] . "

\n"; +} else { $url = 'machines/groups.php'; } + +header("Location: $url"); ?> \ No newline at end of file diff --git a/xCAT-web/lib/CommandWindow.js b/xCAT-web/lib/CommandWindow.js index 7a90adfdb..f2deb9bf1 100644 --- a/xCAT-web/lib/CommandWindow.js +++ b/xCAT-web/lib/CommandWindow.js @@ -1,40 +1,27 @@ var CommandWindow = {}; CommandWindow.updateCommandResult = function() { - var commandQueryId = "commandQuery"; - var copyChkBoxId = "copyChkBox"; - var nodenameHiddenTxtId = "nodename"; - var nodegrpsCboBoxId = "nodegrpsCboBox"; - var pshChkBoxId = "pshChkBox"; + //todo: add commandQueryObj.value to the history select box - 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 commandQueryObj = $('commandQuery'); + var copyChkBoxObj = $('copyChkBox'); + var nodelistTxtObj = $('nodeList'); + var nodegrpsCboBoxObj = $('nodegrpsCboBox'); + var pshChkBoxObj = $('pshChkBox'); - 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); + var serialChkBoxObj = $('serialChkBox'); + var verifyChkBoxObj = $('verifyChkBox'); + var fanoutTxtBoxObj = $('fanoutTxtBox'); + var userIDTxtBoxObj = $('userIDTxtBox'); + var rshellTxtBoxObj = $('rshellTxtBox'); + var monitorChkBoxObj = $('monitorChkBox'); + var ret_codeChkBoxObj = $('ret_codeChkBox'); // 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 (nodelistTxtObj) { postPara += "&node=" + encodeURIComponent(nodelistTxtObj.value); } + if (nodegrpsCboBoxObj) { 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"; diff --git a/xCAT-web/lib/functions.js b/xCAT-web/lib/functions.js index 78e3fbd2d..02ff7bafa 100644 --- a/xCAT-web/lib/functions.js +++ b/xCAT-web/lib/functions.js @@ -1,17 +1,21 @@ // Javascript functions that most pages need. // Note: this is included by all pages, so only put functions in this file that most/all pages need. -function setCookies(form) -{ -var value = (form.rack.checked?1:0) + '&' + form.nodegrps.value + '&' + form.nodeRange.value; -setCookie('mainpage', value); +function setCookie(name, value, path) { +value = escape(value); // this is needed if value contains spaces, semicolons, or commas +document.cookie = name + '=' + value + + ';expires=' + (new Date("December 31, 2023")).toGMTString() + + ';path=' + path; } -function setCookie(name, value) -{ -value = escape(value); -value = value.replace(/\+/g, '%2B'); // The un_urlize() function in webmin works slightly differently than javascript escape() -document.cookie = name + '=' + value + ';expires=' + (new Date("December 31, 2023")).toGMTString(); +// Return a hash of the cookie names and values +function getCookies() { +//alert('"'+document.cookie+'"'); +var cookies = document.cookie.split(/; */); +//alert(cookies[0]); +var cookret = new Object(); // this is the return value +for (i in cookies) { var pair = cookies[i].split('='); cookret[pair[0]] = unescape(pair[1]); } +return cookret; } function selectAll(element, objectName) diff --git a/xCAT-web/lib/functions.php b/xCAT-web/lib/functions.php index 2c3f4f32e..98f64a008 100644 --- a/xCAT-web/lib/functions.php +++ b/xCAT-web/lib/functions.php @@ -4,22 +4,28 @@ // Some common/global settings session_start(); // retain session variables across page requests +if (!isset($TOPDIR)) { $TOPDIR = '..'; } // The settings below display error on the screen, instead of giving blank pages. error_reporting(E_ALL ^ E_NOTICE); ini_set('display_errors', true); -// Todo: get rid of these globals -$XCATROOT = '/opt/xcat/bin'; -$CURRDIR = '/opt/xcat/web'; - -/*----------------------------------------------------------------------------------------------- - Function to insert the header part of the HTML and the top part of the page -------------------------------------------------------------------------------------------------*/ +/** + * Inserts the header part of the HTML and the top part of the page, including the menu. + * Also includes some common css and js files and the css and js files specified. + * This function should be called at the beginning of every page. + * @param String $title The page title that should go in the window title bar. + * @param array $stylesheets The paths of the styles that are specific to this page. + * @param array $javascripts The paths of the javascript files that are specific to this page. + * @param array $currents The keys to the top menu and 2nd menu that represent the current choice for this page. See insertMenus() for the keys. + */ function insertHeader($title, $stylesheets, $javascripts, $currents) { global $TOPDIR; -if (!$TOPDIR) $TOPDIR = '..'; + +// Remember the current page so we can open it again the next time they come to the web interface +$expire_time = gmmktime(0, 0, 0, 1, 1, 2038); +foreach ($currents as $key => $value) { setcookie("currentpage[$key]", $value, $expire_time, '/'); } echo << @@ -74,63 +80,87 @@ echo "\n"; } // end insertHeader +// This is the data structure that represents the menu for each page. +$MENU = array( + 'machines' => array( + 'label' => 'Machines', + 'default' => 'groups', + 'list' => array( + 'lab' => array('label' => 'Lab Floor', 'url' => "$TOPDIR/machines/lab.php"), + 'frames' => array('label' => 'Frames', 'url' => "$TOPDIR/machines/frames.php"), + 'groups' => array('label' => 'Groups', 'url' => "$TOPDIR/machines/groups.php"), + 'nodes' => array('label' => 'Nodes', 'url' => "$TOPDIR/machines/nodes.php"), + 'layout' => array('label' => 'Layout', 'url' => "$TOPDIR/machines/layout.php"), + ) + ), + 'manage' => array( + 'label' => 'Manage', + 'default' => 'dsh', + 'list' => array( + 'dsh' => array('label' => 'Run Cmds', 'url' => "$TOPDIR/manage/dsh.php"), + 'copyfiles' => array('label' => 'Copy Files', 'url' => "$TOPDIR/manage/copyfiles.php"), + 'cfm' => array('label' => 'Sync Files', 'url' => "$TOPDIR/manage/cfm.php"), + 'hwctrl' => array('label' => 'HW Ctrl', 'url' => "$TOPDIR/manage/hwctrl.php"), + 'diagnodes' => array('label' => 'Diagnose', 'url' => "$TOPDIR/manage/diagnodes.php"), + ) + ), + 'jobs' => array( + 'label' => 'Jobs', + 'default' => 'overview', + 'list' => array( + 'overview' => array('label' => 'Overview', 'url' => "$TOPDIR/jobs/overview.php"), + //todo: Vallard fill in rest + ) + ), + 'deploy' => array( + 'label' => 'Deploy', + 'default' => 'osimages', + 'list' => array( + 'osimages' => array('label' => 'OS Images', 'url' => "$TOPDIR/deploy/osimages.php"), + 'prepare' => array('label' => 'Prepare', 'url' => "$TOPDIR/deploy/prepare.php"), + 'deploy' => array('label' => 'Deploy', 'url' => "$TOPDIR/deploy/deploy.php"), + 'monitor' => array('label' => 'Monitor', 'url' => "$TOPDIR/deploy/monitor.php"), + ) + ), + 'config' => array( + 'label' => 'Configure', + 'default' => 'site', + 'list' => array( + 'prefs' => array('label' => 'Preferences', 'url' => "$TOPDIR/config/prefs.php"), + 'site' => array('label' => 'Cluster Settings', 'url' => "$TOPDIR/config/site.php"), + 'mgmtnode' => array('label' => 'Mgmt Node', 'url' => "$TOPDIR/config/mgmtnode.php"), + 'monitor' => array('label' => 'Monitor Setup', 'url' => "$TOPDIR/config/monitor.php"), + 'eventlog' => array('label' => 'Event Log', 'url' => "$TOPDIR/config/eventlog.php"), + ) + ), + 'support' => array( + 'label' => 'Support', + 'default' => 'diagnose', + 'list' => array( + 'diagnose' => array('label' => 'Diagnose', 'url' => "$TOPDIR/support/diagnose.php"), + 'update' => array('label' => 'Update', 'url' => "$TOPDIR/support/update.php"), + 'howtos' => array('label' => 'HowTos', 'url' => "$TOPDIR/support/howtos.php"), + 'manpages' => array('label' => 'Man Pages', 'url' => "$TOPDIR/support/manpages.php"), + 'maillist' => array('label' => 'Mail List', 'url' => "http://xcat.org/mailman/listinfo/xcat-user"), + 'wiki' => array('label' => 'Wiki', 'url' => "http://xcat.wiki.sourceforge.net/"), + 'suggest' => array('label' => 'Suggestions', 'url' => "$TOPDIR/support/suggest.php"), + 'about' => array('label' => 'About', 'url' => "$TOPDIR/support/about.php"), + ) + ), + ); + + // Insert the menus at the top of the page // $currents is an array of the current menu choice tree function insertMenus($currents) { global $TOPDIR; + global $MENU; echo "\n"; - insertMenuRow($currents[0], 1, array( - 'machines' => array('Machines', "$TOPDIR/machines/groups.php"), - 'jobs' => array('Jobs', "$TOPDIR/jobs/overview.php"), - 'deploy' => array('Deploy', "$TOPDIR/deploy/osimages.php"), - 'config' => array('Configuration', "$TOPDIR/config/site.php"), - 'support' => array('Support', "$TOPDIR/support/diagnose.php") - )); - if ($currents[0] == 'machines') { - insertMenuRow($currents[1], 0, array( - 'lab' => array('Lab Floor', "$TOPDIR/machines/lab.php"), - 'frames' => array('Frames', "$TOPDIR/machines/frames.php"), - 'groups' => array('Groups', "$TOPDIR/machines/groups.php"), - 'nodes' => array('Nodes', "$TOPDIR/machines/nodes.php"), - 'layout' => array('Layout', "$TOPDIR/machines/layout.php") - )); - } - elseif ($currents[0] == 'jobs') { - insertMenuRow($currents[1], 0, array( - 'overview' => array('Overview', "$TOPDIR/jobs/overview.php"), - //todo: Vallard fill in rest - )); - } - elseif ($currents[0] == 'deploy') { - insertMenuRow($currents[1], 0, array( - 'osimages' => array('OS Images', "$TOPDIR/deploy/osimages.php"), - 'prepare' => array('Prepare', "$TOPDIR/deploy/prepare.php"), - 'deploy' => array('Deploy', "$TOPDIR/deploy/deploy.php"), - 'monitor' => array('Monitor', "$TOPDIR/deploy/monitor.php"), - )); - } - elseif ($currents[0] == 'config') { - insertMenuRow($currents[1], 0, array( - 'prefs' => array('Preferences', "$TOPDIR/config/prefs.php"), - 'site' => array('Cluster Settings', "$TOPDIR/config/site.php"), - 'mgmtnode' => array('Mgmt Node', "$TOPDIR/config/mgmtnode.php"), - 'monitor' => array('Monitor Setup', "$TOPDIR/config/monitor.php"), - 'eventlog' => array('Event Log', "$TOPDIR/config/eventlog.php"), - )); - } - elseif ($currents[0] == 'support') { - insertMenuRow($currents[1], 0, array( - 'diagnose' => array('Diagnose', "$TOPDIR/support/diagnose.php"), - 'update' => array('Update', "$TOPDIR/support/update.php"), - 'howtos' => array('HowTos', "$TOPDIR/support/howtos.php"), - 'manpages' => array('Man Pages', "$TOPDIR/support/manpages.php"), - 'maillist' => array('Mail List', "http://xcat.org/mailman/listinfo/xcat-user"), - 'wiki' => array('Wiki', "http://xcat.wiki.sourceforge.net/"), - 'suggest' => array('Suggestions', "$TOPDIR/support/suggest.php"), - 'about' => array('About', "$TOPDIR/support/about.php"), - )); - } + insertMenuRow($currents[0], 1, $MENU); + + insertMenuRow($currents[1], 0, $MENU[$currents[0]]['list']); + echo "
\n"; } @@ -147,13 +177,19 @@ function insertMenuRow($current, $isTop, $items) { //echo "