Integrated Vallard's DB editing page into xCAT-web
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2327 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
7f029dcd7d
commit
8e39431f75
@ -1 +0,0 @@
|
||||
root:FY0Bc7abHEm5w
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>xCAT-web</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>net.sourceforge.phpeclipse.parserbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>net.sourceforge.phpeclipse.phpnature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
39
xCAT-web/config/change.php
Normal file
39
xCAT-web/config/change.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
// Modify the shadow copy of the table on the svr.
|
||||
|
||||
$TOPDIR = '..';
|
||||
require_once "$TOPDIR/lib/functions.php";
|
||||
/* $Id */
|
||||
$tab = $_GET['tab'];
|
||||
|
||||
// Delete a row
|
||||
if (isset($_GET['delrow'])) {
|
||||
$row = $_GET['delrow'];
|
||||
$editable = & $_SESSION["editable-$tab"]; # Get an easier alias for the table array
|
||||
unset($editable[$row]);
|
||||
}
|
||||
|
||||
// Change a value in a cell
|
||||
else {
|
||||
$id = $_POST['id'];
|
||||
$value = $_POST['value'];
|
||||
|
||||
$coord = array();
|
||||
$coord = explode('-', $id);
|
||||
$theLine = $coord[0];
|
||||
$theField = $coord[1];
|
||||
#echo "line: $theLine field: $theField<br>";
|
||||
|
||||
# Get an easier alias for the table array
|
||||
$editable = & $_SESSION["editable-$tab"];
|
||||
|
||||
# Modify the array with the new value from the editable widget
|
||||
//$oldValue = $editable[$theLine][$theField];
|
||||
$editable[$theLine][$theField] = $value;
|
||||
//$s = 's=' . $editable[$theLine][$theField] . '.';
|
||||
|
||||
// This value goes back to the javascript editable object in the browser
|
||||
echo "$value";
|
||||
}
|
||||
?>
|
104
xCAT-web/config/db.css
Normal file
104
xCAT-web/config/db.css
Normal file
@ -0,0 +1,104 @@
|
||||
|
||||
/* Styles specific to the db.php page */
|
||||
|
||||
#tableNames {
|
||||
position: relative; /* so the h3 inside can be absolute to this div */
|
||||
border: 1px solid black;
|
||||
text-align: left;
|
||||
padding: 12px 5px 10px 5px;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#tableNames H3 {
|
||||
position: absolute;
|
||||
top: -25px;
|
||||
left: 15px;
|
||||
background-color: white;
|
||||
padding: 0px 5px;
|
||||
}
|
||||
|
||||
#tableNames A {
|
||||
font-size: 9pt;
|
||||
margin-left: 0.6em;
|
||||
margin-right: 0.6em;
|
||||
}
|
||||
|
||||
#helpLinks A {
|
||||
margin-left: 0.4em;
|
||||
margin-right: 0.4em;
|
||||
}
|
||||
|
||||
|
||||
.middlepane {
|
||||
/* float: left; */
|
||||
padding: 5px;
|
||||
margin: 10px;
|
||||
min-width: 600px;
|
||||
}
|
||||
|
||||
/*
|
||||
.bottompane {
|
||||
float: left;
|
||||
padding: 5px;
|
||||
margin: 10px;
|
||||
min-width: 600px;
|
||||
border-top: 1px dotted #555;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
.colHeaders {
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* the alternating rows of the table */
|
||||
.ListLine0 { background: #e0f8f8; }
|
||||
.ListLine1 { background: #b0f8f8; }
|
||||
|
||||
.Xcell { /* the table cell that contains the red x */
|
||||
background-color: white;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.Ximg { padding-right: 15px; }
|
||||
.Ximg2 { padding-right: 15px; }
|
||||
|
||||
.edit {
|
||||
background: #8f8f0b;
|
||||
}
|
||||
|
||||
a.gbutton {
|
||||
background: transparent url('../images/bg_button_a.gif') no-repeat scroll top right;
|
||||
color: #444;
|
||||
display: inline-block;
|
||||
/* float: left; */
|
||||
font: normal 12px arial, sans-serif;
|
||||
height: 24px;
|
||||
margin-right: 6px;
|
||||
padding-right: 18px; /* sliding doors padding */
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.gbutton span {
|
||||
background: transparent url('../images/bg_button_span.gif') no-repeat;
|
||||
display: inline-block;
|
||||
line-height: 14px;
|
||||
padding: 5px 0 5px 18px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
a.gbutton:active {
|
||||
background-position: bottom right;
|
||||
color: #000;
|
||||
outline: none; /* hide dotted outline in Firefox */
|
||||
}
|
||||
|
||||
a.gbutton:active span {
|
||||
background-position: bottom left;
|
||||
padding: 6px 0 4px 18px; /* push text down 1px */
|
||||
cursor: pointer;
|
||||
}
|
59
xCAT-web/config/db.js
Normal file
59
xCAT-web/config/db.js
Normal file
@ -0,0 +1,59 @@
|
||||
// Javascript functions needed by the db page.
|
||||
|
||||
// Make this class of elements editable
|
||||
function makeEditable(table, cellclass, imgclass, linkclass) {
|
||||
// Make all the cells editable
|
||||
//todo: figure out how to make the tab key commit the current cell and edit the next
|
||||
$(cellclass).editable('change.php?tab=' + table, {
|
||||
indicator : "<img src='../images/indicator.gif'>",
|
||||
type : 'text',
|
||||
tooltip : 'Click to edit...',
|
||||
style : 'inherit',
|
||||
cssclass : 'inherit',
|
||||
placeholder : ''
|
||||
// callback : function(value,settings) { alert(dump(settings)); }
|
||||
});
|
||||
|
||||
// Set up rollover and action for red x to delete row
|
||||
$(imgclass).hover(function() { $(this).attr('src','../images/red-x2.gif'); },
|
||||
function() { $(this).attr('src','../images/red-x2-light.gif'); }
|
||||
);
|
||||
$(linkclass).click(function() {
|
||||
var tr = $(this).parent().parent();
|
||||
var rowid = tr.attr('id');
|
||||
var match = rowid.match(/\d+/);
|
||||
$.get('change.php?tab=' + table + '&delrow=' + match[0]);
|
||||
tr.remove();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Form a table row to add to the table
|
||||
function formRow(linenum, numCells, ooe) {
|
||||
var newrow = '<tr class=ListLine' + ooe + ' id=row' + linenum + '><td class=Xcell><a class=Xlink2 title="Delete row"><img class=Ximg2 src=../images/red-x2-light.gif></a></td>';
|
||||
for (var i=1; i<=numCells; i++) {
|
||||
var val = '';
|
||||
if (i == 1) { val = 'x'; }
|
||||
newrow += '<td class=editme2 id="' + linenum + '-' + i + '">' + val + '</td>';
|
||||
}
|
||||
newrow += '</tr>';
|
||||
return newrow;
|
||||
}
|
||||
|
||||
|
||||
// Load edittab.php, specifying this table as a param
|
||||
function loadTable(table) {
|
||||
var url = 'edittab.php?tab=' + table;
|
||||
$('#middlepane').load(url);
|
||||
}
|
||||
|
||||
|
||||
// Associate a click event with each table link to get its url (which is
|
||||
// the table name) and load edittab.php with that table name.
|
||||
function bindTableLinks() {
|
||||
$('#tableNames A').click(function(e) {
|
||||
var tableName = this.hash.substr(1); // strip off the leading # in the hash string
|
||||
loadTable(tableName);
|
||||
return false;
|
||||
});
|
||||
}
|
47
xCAT-web/config/db.php
Normal file
47
xCAT-web/config/db.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
// Display/edit tables in the xcat db
|
||||
|
||||
$TOPDIR = '..';
|
||||
require_once "$TOPDIR/lib/functions.php";
|
||||
|
||||
insertHeader('xCAT Database', array('db.css'),
|
||||
array('db.js',"$TOPDIR/jq/jquery.min.js","$TOPDIR/jq/jquery.jeditable.mini.js"),
|
||||
array('config','db'));
|
||||
|
||||
echo "<div id=content align=center>\n";
|
||||
|
||||
// Display all the table links
|
||||
echo "<div id=tableNames><h3>Tables</h3>\n";
|
||||
$tables = getTabNames();
|
||||
foreach ($tables as $t) {
|
||||
//if ($i++ > 7) { echo "</tr>\n<tr>"; $i = 1; }
|
||||
echo "<a href='#$t'>$t</a> ";
|
||||
}
|
||||
echo "\n</div>\n";
|
||||
|
||||
if(isset($_REQUEST['tab'])) { $tab = $_REQUEST['tab']; }
|
||||
else { $tab = "nodelist"; }
|
||||
$p = "edittab.php?tab=$tab";
|
||||
|
||||
echo "<div class=middlepane id=middlepane>Loading $tab ...</div>\n";
|
||||
//echo "<div class=bottompane></div>\n";
|
||||
echo "<script type='text/javascript'>\n";
|
||||
echo " loadTable('$tab');";
|
||||
echo " bindTableLinks();";
|
||||
echo "\n</script>\n";
|
||||
|
||||
|
||||
insertFooter();
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Return the list of database table names
|
||||
function getTabNames() {
|
||||
$xml = docmd('tabdump','',NULL);
|
||||
$tabs = array();
|
||||
foreach ($xml->children() as $response) foreach ($response->children() as $t) { $tabs[] = (string) $t; }
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
?>
|
154
xCAT-web/config/edittab.php
Normal file
154
xCAT-web/config/edittab.php
Normal file
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
// Display/edit a single table from the xcat db. This is call via a jQuery load() call.
|
||||
|
||||
$TOPDIR = '..';
|
||||
require_once "$TOPDIR/lib/functions.php";
|
||||
|
||||
if(isset($_REQUEST['tab'])) { $tab = $_REQUEST['tab']; }
|
||||
else { echo "<p>No table name specified. Please specify a table to edit.</p>\n"; exit; }
|
||||
|
||||
//echo "<p>" . implode(',',array_keys($_SESSION)) . "</p>\n";
|
||||
//if (array_key_exists("editable-$tab",$_SESSION)) { echo "<p>count=".count($_SESSION["editable-$tab"])."</p>\n"; }
|
||||
|
||||
if(isset($_REQUEST['kill'])) {
|
||||
unset($_SESSION["editable-$tab"]);
|
||||
}
|
||||
|
||||
if(isset($_REQUEST['save'])) {
|
||||
$rsp = savexCATchanges($tab,$_SESSION["editable-$tab"]);
|
||||
$errors = array();
|
||||
if (getXmlErrors($rsp,$errors)) { echo "<p class=Error>Tabrestore failed: ", implode(' ',$errors), "</p>\n"; }
|
||||
else { echo "<p class=Info>Changes have been saved.</p>\n"; }
|
||||
}
|
||||
|
||||
// Get table contents
|
||||
//$f = splitTableFields2('"node01","node02","5000","off",,'); echo '<p>'; foreach ($f as $k => $v) { echo "$k=$v<br>"; } echo "</p>\n";
|
||||
echo "<h1>$tab Table</h1>";
|
||||
echo "<table border=0><tr><td rowspan=2>", getTabDescription($tab), "</td>\n";
|
||||
echo "<td><a href='" . getDocURL('dbtable',$tab) . "' target='_blank'>Column Descriptions</a></td></tr>\n";
|
||||
echo "<tr><td><a href='" . getDocURL('dbtable') . "' target='_blank'>Regular Expression Support</a></td></tr></table>\n";
|
||||
|
||||
// Display the column names
|
||||
$xml = docmd('tabdump','',array($tab));
|
||||
$headers = getTabHeaders($xml);
|
||||
if(!is_array($headers)){ die("<p>Can't find header line in $tab</p>"); }
|
||||
echo "<table id=tabTable>\n";
|
||||
echo "<tr class='colHeaders'><td></td>\n"; // extra cell is for the red x
|
||||
foreach($headers as $colHead) { echo "<td>$colHead</td>"; }
|
||||
echo "</tr>\n"; # close header table
|
||||
|
||||
// Save the width of the table for adding a new row when they click that button
|
||||
$tableWidth = count($headers);
|
||||
|
||||
// Display table contents and remember its contents in a session variable.
|
||||
$ooe = 0; // alternates the background of the table
|
||||
$item = 0; // the column #
|
||||
$line = 0;
|
||||
$editable = array();
|
||||
foreach ($xml->children() as $response) foreach ($response->children() as $arr){
|
||||
$arr = (string) $arr;
|
||||
if(ereg("^#", $arr)){ // handle the header specially
|
||||
$editable[$line++][$item] = $arr;
|
||||
continue;
|
||||
}
|
||||
$cl = "ListLine$ooe";
|
||||
$values = splitTableFields($arr);
|
||||
// If you change this line, be sure to change the formRow function in db.js
|
||||
echo "<tr class=$cl id=row$line><td class=Xcell><a class=Xlink title='Delete row'><img class=Ximg src=$TOPDIR/images/red-x2-light.gif></a></td>";
|
||||
foreach($values as $v){
|
||||
//$v = preg_replace('/\"/','', $v);
|
||||
echo "<td class=editme id='$line-$item'>$v</td>";
|
||||
$editable[$line][$item++] = $v;
|
||||
}
|
||||
echo "</tr>\n";
|
||||
$line++;
|
||||
$item = 0;
|
||||
$ooe = 1 - $ooe;
|
||||
}
|
||||
echo "</table>\n";
|
||||
$_SESSION["editable-$tab"] = & $editable; // save the array so we can access it in the next call of this file or change.php
|
||||
//unset($_SESSION["editable-$tab"]);
|
||||
|
||||
echo "<p><a class=gbutton id=newrow><span>Add Row</span></a>\n";
|
||||
echo "<a class=gbutton id=saveit><span>Save</span></a>\n";
|
||||
echo "<a class=gbutton id=reset><span>Cancel</span></a></p>\n";
|
||||
?>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
//jQuery(document).ready(function() {
|
||||
makeEditable('<?php echo $tab ?>', '.editme', '.Ximg', '.Xlink');
|
||||
|
||||
// Set up global vars to pass to the newrow button
|
||||
document.linenum = <?php echo $line ?>;
|
||||
document.ooe = <?php echo $ooe ?>;
|
||||
|
||||
// Set actions for buttons
|
||||
$("#reset").click(function(){
|
||||
//alert('You sure you want to discard changes?');
|
||||
$('#middlepane').load("edittab.php?tab=<?php echo $tab ?>&kill=1");
|
||||
});
|
||||
$("#newrow").click(function(){
|
||||
var newrow = formRow(document.linenum, <?php echo $tableWidth ?>, document.ooe);
|
||||
document.linenum++;
|
||||
document.ooe = 1 - document.ooe;
|
||||
$('#tabTable').append($(newrow));
|
||||
makeEditable('<?php echo $tab ?>', '.editme2', '.Ximg2', '.Xlink2');
|
||||
});
|
||||
$("#saveit").click(function(){
|
||||
$('#middlepane').load("edittab.php?tab=<?php echo $tab ?>&save=1", {
|
||||
indicator : "<img src='../images/indicator.gif'>",
|
||||
});
|
||||
});
|
||||
//});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
function getTabHeaders($xml){
|
||||
foreach ($xml->children() as $response) foreach ($response->children() as $line) {
|
||||
$line = (string) $line;
|
||||
if (ereg("^#", $line)) {
|
||||
$line = preg_replace('/^#/','', $line);
|
||||
$headers = explode(',', $line);
|
||||
return $headers;
|
||||
}
|
||||
}
|
||||
// If we get here, we never found the header line
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
function savexCATchanges($tab, & $editable){
|
||||
$request = simplexml_load_string('<xcatrequest></xcatrequest>');
|
||||
$request->addChild('command','tabrestore');
|
||||
foreach($editable as $line){
|
||||
foreach ($line as &$f) { if (!empty($f) && !preg_match('/^".*"$/', $f)) { $f = '"'.$f.'"'; } }
|
||||
$linestr = implode(",",$line);
|
||||
$linestr = str_replace('"', '"',$linestr); //todo: should we use the htmlentities function?
|
||||
$linestr = str_replace("'", ''',$linestr);
|
||||
//echo "<p>addChild:$linestr.</p>\n";
|
||||
$request->addChild('data', $linestr);
|
||||
}
|
||||
$request->addChild('table',$tab);
|
||||
$resp = submit_request($request, 0);
|
||||
return $resp;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
function getTabDescription($tab) {
|
||||
$xml = docmd('tabdump','',array('-d'));
|
||||
foreach ($xml->children() as $response) foreach ($response->children() as $line) {
|
||||
$line = (string) $line;
|
||||
if (ereg("^$tab:",$line)) {
|
||||
$line = preg_replace("/^$tab:\s*/", '', $line);
|
||||
return $line;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
?>
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Display/change global settings in the site table
|
||||
|
||||
$TOPDIR = '..';
|
||||
require_once "$TOPDIR/lib/functions.php";
|
||||
|
||||
insertHeader('Site', NULL, NULL, array('config','site'));
|
||||
insertNotDoneYet();
|
||||
echo '</body></html>';
|
||||
?>
|
BIN
xCAT-web/images/indicator.gif
Normal file
BIN
xCAT-web/images/indicator.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
xCAT-web/images/red-x.gif
Normal file
BIN
xCAT-web/images/red-x.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1002 B |
BIN
xCAT-web/images/red-x2-light.gif
Normal file
BIN
xCAT-web/images/red-x2-light.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 973 B |
BIN
xCAT-web/images/red-x2.gif
Normal file
BIN
xCAT-web/images/red-x2.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 973 B |
634
xCAT-web/jq/jquery-ui-personalized.min.js
vendored
Normal file
634
xCAT-web/jq/jquery-ui-personalized.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
30
xCAT-web/jq/jquery.jeditable.mini.js
Normal file
30
xCAT-web/jq/jquery.jeditable.mini.js
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
(function($){$.fn.editable=function(target,options){var settings={target:target,name:'value',id:'id',type:'text',width:'auto',height:'auto',event:'click',onblur:'cancel',loadtype:'GET',loadtext:'Loading...',placeholder:'Click to edit',loaddata:{},submitdata:{}};if(options){$.extend(settings,options);}
|
||||
var plugin=$.editable.types[settings.type].plugin||function(){};var submit=$.editable.types[settings.type].submit||function(){};var buttons=$.editable.types[settings.type].buttons||$.editable.types['defaults'].buttons;var content=$.editable.types[settings.type].content||$.editable.types['defaults'].content;var element=$.editable.types[settings.type].element||$.editable.types['defaults'].element;var reset=$.editable.types[settings.type].reset||$.editable.types['defaults'].reset;var callback=settings.callback||function(){};if(!$.isFunction($(this)[settings.event])){$.fn[settings.event]=function(fn){return fn?this.bind(settings.event,fn):this.trigger(settings.event);}}
|
||||
$(this).attr('title',settings.tooltip);settings.autowidth='auto'==settings.width;settings.autoheight='auto'==settings.height;return this.each(function(){var self=this;var savedwidth=$(self).width();var savedheight=$(self).height();if(!$.trim($(this).html())){$(this).html(settings.placeholder);}
|
||||
$(this)[settings.event](function(e){if(self.editing){return;}
|
||||
if(0==$(self).width()){settings.width=savedwidth;settings.height=savedheight;}else{if(settings.width!='none'){settings.width=settings.autowidth?$(self).width():settings.width;}
|
||||
if(settings.height!='none'){settings.height=settings.autoheight?$(self).height():settings.height;}}
|
||||
if($(this).html().toLowerCase().replace(/;/,'')==settings.placeholder.toLowerCase().replace(/;/,'')){$(this).html('');}
|
||||
self.editing=true;self.revert=$(self).html();$(self).html('');var form=$('<form/>');if(settings.cssclass){if('inherit'==settings.cssclass){form.attr('class',$(self).attr('class'));}else{form.attr('class',settings.cssclass);}}
|
||||
if(settings.style){if('inherit'==settings.style){form.attr('style',$(self).attr('style'));form.css('display',$(self).css('display'));}else{form.attr('style',settings.style);}}
|
||||
var input=element.apply(form,[settings,self]);var input_content;if(settings.loadurl){var t=setTimeout(function(){input.disabled=true;content.apply(form,[settings.loadtext,settings,self]);},100);var loaddata={};loaddata[settings.id]=self.id;if($.isFunction(settings.loaddata)){$.extend(loaddata,settings.loaddata.apply(self,[self.revert,settings]));}else{$.extend(loaddata,settings.loaddata);}
|
||||
$.ajax({type:settings.loadtype,url:settings.loadurl,data:loaddata,async:false,success:function(result){window.clearTimeout(t);input_content=result;input.disabled=false;}});}else if(settings.data){input_content=settings.data;if($.isFunction(settings.data)){input_content=settings.data.apply(self,[self.revert,settings]);}}else{input_content=self.revert;}
|
||||
content.apply(form,[input_content,settings,self]);input.attr('name',settings.name);buttons.apply(form,[settings,self]);$(self).append(form);plugin.apply(form,[settings,self]);$(':input:visible:enabled:first',form).focus();if(settings.select){input.select();}
|
||||
input.keydown(function(e){if(e.keyCode==27){e.preventDefault();reset.apply(form,[settings,self]);}});var t;if('cancel'==settings.onblur){input.blur(function(e){t=setTimeout(function(){reset.apply(form,[settings,self]);},500);});}else if('submit'==settings.onblur){input.blur(function(e){form.submit();});}else if($.isFunction(settings.onblur)){input.blur(function(e){settings.onblur.apply(self,[input.val(),settings]);});}else{input.blur(function(e){});}
|
||||
form.submit(function(e){if(t){clearTimeout(t);}
|
||||
e.preventDefault();if(false!==submit.apply(form,[settings,self])){if($.isFunction(settings.target)){var str=settings.target.apply(self,[input.val(),settings]);$(self).html(str);self.editing=false;callback.apply(self,[self.innerHTML,settings]);if(!$.trim($(self).html())){$(self).html(settings.placeholder);}}else{var submitdata={};submitdata[settings.name]=input.val();submitdata[settings.id]=self.id;if($.isFunction(settings.submitdata)){$.extend(submitdata,settings.submitdata.apply(self,[self.revert,settings]));}else{$.extend(submitdata,settings.submitdata);}
|
||||
if('PUT'==settings.method){submitdata['_method']='put';}
|
||||
$(self).html(settings.indicator);$.post(settings.target,submitdata,function(str){$(self).html(str);self.editing=false;callback.apply(self,[self.innerHTML,settings]);if(!$.trim($(self).html())){$(self).html(settings.placeholder);}});}}
|
||||
return false;});});this.reset=function(){$(self).html(self.revert);self.editing=false;if(!$.trim($(self).html())){$(self).html(settings.placeholder);}}});};$.editable={types:{defaults:{element:function(settings,original){var input=$('<input type="hidden">');$(this).append(input);return(input);},content:function(string,settings,original){$(':input:first',this).val(string);},reset:function(settings,original){original.reset();},buttons:function(settings,original){var form=this;if(settings.submit){if(settings.submit.match(/>$/)){var submit=$(settings.submit).click(function(){if(submit.attr("type")!="submit"){form.submit();}});}else{var submit=$('<button type="submit">');submit.html(settings.submit);}
|
||||
$(this).append(submit);}
|
||||
if(settings.cancel){if(settings.cancel.match(/>$/)){var cancel=$(settings.cancel);}else{var cancel=$('<button type="cancel">');cancel.html(settings.cancel);}
|
||||
$(this).append(cancel);$(cancel).click(function(event){if($.isFunction($.editable.types[settings.type].reset)){var reset=$.editable.types[settings.type].reset;}else{var reset=$.editable.types['defaults'].reset;}
|
||||
reset.apply(form,[settings,original]);return false;});}}},text:{element:function(settings,original){var input=$('<input>');if(settings.width!='none'){input.width(settings.width);}
|
||||
if(settings.height!='none'){input.height(settings.height);}
|
||||
input.attr('autocomplete','off');$(this).append(input);return(input);}},textarea:{element:function(settings,original){var textarea=$('<textarea>');if(settings.rows){textarea.attr('rows',settings.rows);}else{textarea.height(settings.height);}
|
||||
if(settings.cols){textarea.attr('cols',settings.cols);}else{textarea.width(settings.width);}
|
||||
$(this).append(textarea);return(textarea);}},select:{element:function(settings,original){var select=$('<select>');$(this).append(select);return(select);},content:function(string,settings,original){if(String==string.constructor){eval('var json = '+string);for(var key in json){if(!json.hasOwnProperty(key)){continue;}
|
||||
if('selected'==key){continue;}
|
||||
var option=$('<option>').val(key).append(json[key]);$('select',this).append(option);}}
|
||||
$('select',this).children().each(function(){if($(this).val()==json['selected']||$(this).text()==original.revert){$(this).attr('selected','selected');};});}}},addInputType:function(name,input){$.editable.types[name]=input;}};})(jQuery);
|
32
xCAT-web/jq/jquery.min.js
vendored
Normal file
32
xCAT-web/jq/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -113,10 +113,10 @@ $MENU = array(
|
||||
),
|
||||
'config' => array(
|
||||
'label' => 'Configure',
|
||||
'default' => 'site',
|
||||
'default' => 'db',
|
||||
'list' => array(
|
||||
'prefs' => array('label' => 'Preferences', 'url' => "$TOPDIR/config/prefs.php"),
|
||||
'site' => array('label' => 'Cluster Settings', 'url' => "$TOPDIR/config/site.php"),
|
||||
'db' => array('label' => 'Cluster Settings', 'url' => "$TOPDIR/config/db.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"),
|
||||
@ -200,7 +200,7 @@ function insertMenuRow($current, $isTop, $items) {
|
||||
//-----------------------------------------------------------------------------
|
||||
// Inserts the html for each pages footer
|
||||
function insertFooter() {
|
||||
echo '<div class=PageFooter><p id=disclaimer>This interface is still under construction and not yet ready for use.</p></div></BODY></HTML>';
|
||||
echo '<div class=PageFooter><p id=disclaimer>This interface is still under construction and not yet ready for production use.</p></div></BODY></HTML>';
|
||||
}
|
||||
|
||||
|
||||
@ -211,12 +211,8 @@ echo '<div class=PageFooter><p id=disclaimer>This interface is still under const
|
||||
function docmd($cmd, $nr, $args){
|
||||
$request = simplexml_load_string('<xcatrequest></xcatrequest>');
|
||||
$request->addChild('command',$cmd);
|
||||
foreach ($args as $a) {
|
||||
$request->addChild('arg',$a);
|
||||
}
|
||||
if(!empty($nr)){
|
||||
$request->addChild('noderange',$nr);
|
||||
}
|
||||
if(!empty($nr)) { $request->addChild('noderange',$nr); }
|
||||
if (!empty($args)) { foreach ($args as $a) { $request->addChild('arg',$a); } }
|
||||
#echo $request->asXML();
|
||||
$xml = submit_request($request,0);
|
||||
return $xml;
|
||||
@ -251,12 +247,13 @@ function submit_request($req, $skipVerify){
|
||||
#echo htmlentities($response);
|
||||
$response = '<xcat>' . preg_replace($pattern,'', $response) . '</xcat>'; // remove the serverdone response and put an xcat tag around the rest
|
||||
$rsp = simplexml_load_string($response,'SimpleXMLElement', LIBXML_NOCDATA);
|
||||
//echo '<p>'; print_r($rsp); echo "</p>\n";
|
||||
$cleanexit = 1;
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
}else{
|
||||
echo "<p>xCAT Submit request Error: $errno - $errstr</p>\n";
|
||||
echo "<p>xCAT Submit request socket Error: $errno - $errstr</p>\n";
|
||||
}
|
||||
if(! $cleanexit){
|
||||
if(!$skipVerify){
|
||||
@ -268,6 +265,30 @@ function submit_request($req, $skipVerify){
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Use with submit_request() to get the data fields (output that is not node-oriented)
|
||||
function getXmlData(& $xml) {
|
||||
$data = array();
|
||||
foreach ($xml->children() as $response) foreach ($response->children() as $k => $v) {
|
||||
if ($k == 'data') { $data[] = (string) $v; }
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Use with submit_request() to get any errors that might have occurred
|
||||
// Returns the errorcode and adds any error strings to the $error array passed in
|
||||
function getXmlErrors(& $xml, & $errors) {
|
||||
$errorcode = 0;
|
||||
foreach ($xml->children() as $response) foreach ($response->children() as $k => $v) {
|
||||
if ($k == 'error') { $errors[] = (string) $v; }
|
||||
if ($k == 'errorcode') { $errorcode = (string) $v; }
|
||||
}
|
||||
return $errorcode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------------------------
|
||||
Function to run the commands on the remote nodes. Four arguments:
|
||||
@ -696,11 +717,9 @@ function getNodes($noderange, $attrs) {
|
||||
if (empty($noderange)) { $nodrange = '/.*'; }
|
||||
//$xml = docmd('nodels',$noderange,implode(' ',$attrs));
|
||||
$xml = docmd('nodels',$noderange,$attrs);
|
||||
//$output = $xml->xcatresponse->children(); // technically, we should iterate over the xcatresponses, because there can be more than one
|
||||
//foreach ($output as $o) {
|
||||
foreach ($xml->children() as $response) foreach ($response->children() as $o) {
|
||||
$nodename = (string)$o->name;
|
||||
$data = $o->data;
|
||||
$data = & $o->data;
|
||||
$attrval = (string)$data->contents;
|
||||
if (empty($attrval)) { continue; }
|
||||
$attrname = (string)$data->desc;
|
||||
@ -724,17 +743,17 @@ function getNodes($noderange, $attrs) {
|
||||
function getGroups() {
|
||||
$groups = array();
|
||||
$xml = docmd('tabdump','',array('nodelist'));
|
||||
$output = $xml->xcatresponse->children();
|
||||
//$output = $xml->xcatresponse->children();
|
||||
#$output = $xml->children(); // technically, we should iterate over the xcatresponses, because there can be more than one
|
||||
foreach ($output as $line) {
|
||||
//foreach ($output as $line) {
|
||||
foreach ($xml->children() as $response) foreach ($response->children() as $line) {
|
||||
$line = (string) $line;
|
||||
//echo "<p>line=$line</p>";
|
||||
$vals = array();
|
||||
preg_match('/^"([^"]*)","([^"]*)"/', $line, $vals); //todo: create function to parse tabdump output better
|
||||
if (count($vals) > 2) {
|
||||
//$node = $vals[1];
|
||||
$grplist = preg_split('/,/', $vals[2]);
|
||||
foreach ($grplist as $g) { $groups[$g] = 1; }
|
||||
}
|
||||
if (ereg("^#", $line)) { continue; } // skip the header
|
||||
$vals = splitTableFields($line);
|
||||
if (empty($vals[0]) || empty($vals[1])) continue; // node or groups missing
|
||||
$grplist = preg_split('/,/', $vals[1]);
|
||||
foreach ($grplist as $g) { $groups[$g] = 1; }
|
||||
}
|
||||
$grplist = array_keys($groups);
|
||||
sort($grplist);
|
||||
@ -805,4 +824,20 @@ function msg($severity, $msg)
|
||||
//-----------------------------------------------------------------------------
|
||||
function insertNotDoneYet() { echo "<p class=NotDone>This page is not done yet.</p>\n"; }
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Parse the columns of 1 line of tabdump output
|
||||
//Todo: the only thing this doesn't handle is escaped double quotes.
|
||||
function splitTableFields($line){
|
||||
$fields = array();
|
||||
$line = ",$line"; // prepend a comma. this makes the parsing more consistent
|
||||
for ($rest=$line; !empty($rest); ) {
|
||||
$vals = array();
|
||||
// either match everything in the 1st pair of quotes, or up to the next comma
|
||||
if (!preg_match('/^,"([^"]*)"(.*)$/', $rest, $vals)) { preg_match('/^,([^,]*)(.*)$/', $rest, $vals); }
|
||||
$fields[] = $vals[1];
|
||||
$rest = $vals[2];
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -26,7 +26,8 @@ insertButtons(
|
||||
);
|
||||
|
||||
// Get the attributes for all nodes
|
||||
$attrlist = array('nodepos.rack','nodepos.u','nodepos.chassis','nodepos.slot','nodepos.room','vpd.mtm','nodetype.arch','nodehm.power','nodehm.mgt','mp.mpa','mp.id');
|
||||
$attrlist = array('nodepos.rack','nodepos.u','vpd.mtm','nodehm.power','nodehm.mgt','mp.mpa','mp.id');
|
||||
echo "<p>To see nodes in this view, set the following attributes in the xCAT DB: " . implode(', ',$attrlist) . "</p>\n";
|
||||
$nodes = getNodes('/.*', $attrlist);
|
||||
$frames = array();
|
||||
|
||||
|
@ -86,23 +86,18 @@ insertFooter();
|
||||
function getGroupStatus() {
|
||||
$groups = array();
|
||||
$xml = docmd('tabdump','',array('nodelist'));
|
||||
$output = $xml->xcatresponse->children();
|
||||
#$output = $xml->children(); // technically, we should iterate over the xcatresponses, because there can be more than one
|
||||
foreach ($output as $line) {
|
||||
//echo "<p>line=$line</p>";
|
||||
$vals = array();
|
||||
preg_match('/^"([^"]*)","([^"]*)",(.*)$/', $line, $vals); //todo: create function to parse tabdump output better
|
||||
if (count($vals) > 3) {
|
||||
//$node = $vals[1];
|
||||
$grplist = preg_split('/,/', $vals[2]);
|
||||
$rest = $vals[3];
|
||||
$status = array();
|
||||
preg_match('/^"([^"]*)"/', $rest, $status);
|
||||
if (count($status) < 2) { $status[1] = 'unknown'; }
|
||||
foreach ($grplist as $g) {
|
||||
if (array_key_exists($g,$groups)) { $groups[$g] = minStatus($groups[$g], $status[1]); }
|
||||
else { $groups[$g] = $status[1]; }
|
||||
}
|
||||
foreach ($xml->children() as $response) foreach ($response->children() as $line) {
|
||||
$line = (string) $line;
|
||||
//echo "<p>"; print_r($line); "</p>\n";
|
||||
if (ereg("^#", $line)) { continue; } // skip the header
|
||||
$vals = splitTableFields($line);
|
||||
if (empty($vals[0]) || empty($vals[1])) continue; // node or groups missing
|
||||
$grplist = preg_split('/,/', $vals[1]);
|
||||
if (empty($vals[2])) { $status = 'unknown'; }
|
||||
else { $status = $vals[2]; }
|
||||
foreach ($grplist as $g) {
|
||||
if (array_key_exists($g,$groups)) { $groups[$g] = minStatus($groups[$g], $status); }
|
||||
else { $groups[$g] = $status; }
|
||||
}
|
||||
}
|
||||
return $groups;
|
||||
|
@ -89,10 +89,6 @@ if (isset($_COOKIE['history']) && array_search($_REQUEST['command'], $_COOKIE['h
|
||||
//echo "<p><b>Command Ouput:</b></br></p>"; //output will be returned from the runcmd function call
|
||||
//$rc = runcmd($command_string,1, $outp); //streaming mode - DOES NOT WORK YET
|
||||
$xml = docmd($command, $noderange, $args);
|
||||
//echo "<p>count=" . count($xml) . ", children=" . $xml->children() . "</p>";
|
||||
//echo "<p>"; print_r($xml); echo "</p>";
|
||||
//$output = $xml->xcatresponse->children();
|
||||
//echo "<p>"; print_r($output); echo "</p>";
|
||||
foreach ($xml->children() as $response) foreach ($response->children() as $line) { echo "$line<br>"; }
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user