modify by xu qing

on xcat.js display.php update.php updateprocess.php
for update the rpm on web interface

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6642 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
xq2005 2010-07-05 05:21:05 +00:00
parent a322bc1e95
commit feec15d49a
4 changed files with 221 additions and 3 deletions

View File

@ -498,5 +498,72 @@ function loadNodeStatus()
});
}
function fun_js_select_all()
{
var check_status = $('#selectall').attr('checked');
$('input:checkbox').attr('checked', check_status);
}
function fun_js_update()
{
var rpm_path = $('input[type=radio]:checked').val();
var rpms = "";
var temp = "";
//select other and we should use the value in the input
if ("" == rpm_path)
{
//user input the repo, and we must stroe it in the cookie
rpm_path = $('#repositoryaddr').val() + "&remember=1";
}
$("input[type=checkbox]:checked").each(function(){
temp = $(this).val();
if("" == temp)
{
//continue;
return true;
}
var pattern = new RegExp("^" + temp + ",|," + temp + ",");;
if (pattern.test(rpms))
{
return true;
}
rpms = rpms + temp + ",";
});
if(0 < rpms.length)
{
rpms = rpms.slice(0, -1);
}
$('#updateProcess').empty().html('<img src="img/throbber.gif">');
$('#updateProcess').load("updateprocess.php?repo=" + rpm_path + "&rpmname=" + rpms);
}
function fun_js_lsdef_edit()
{
$('.attrvalue').editable(function(value, settings){return value;},
{
indicator : "updating...",
type : 'text',
tooltip : 'Click to edit...',
placeholder : '',
onblur : 'submit'
}
);
$('.selected').editable(function(value, settings){
$(this).next(".attrvalue").attr("id", "lsdef_" + value);
},
{
loadurl : 'lsdefList.php',
indicator : "updating...",
type : 'select',
tooltip : 'Click to select...',
placeholder : '',
onblur : 'submit'
});
};
// load progress bar
myBar.loaded('xcat.js');

View File

@ -984,4 +984,39 @@ function showxCATInfo() {
echo "</div>";
}
function showUpdateRow($RpmName){
$ret = shell_exec("rpm -q " . $RpmName);
$aRpm = explode("\n",$ret);
foreach ($aRpm as $TempRpm)
{
if($TempRpm){
$verstr= substr($TempRpm, strlen($RpmName) + 1);
echo ("<tr>");
echo ("<td><input type=\"checkbox\" value=\"" . $RpmName . "\"></td>");
echo ("<td>" . $RpmName . "</td>");
echo ("<td>" . $verstr . "</td>");
echo ("</tr>");
}
}
}
function showUpdateInfo() {
echo "<div><table id=rpmtable style='margin-left: 30px'>";
echo "<tr>";
echo "<td><input type=\"checkbox\" id=\"selectall\" value=\"\" onclick=\"fun_js_select_all()\"></td>";
echo "<td>Package Name</td>";
echo "<td>Version</td>";
echo "</tr>";
showUpdateRow("xCAT-client");
showUpdateRow("perl-xCAT");
showUpdateRow("xCAT-server");
showUpdateRow("xCAT");
showUpdateRow("xCAT-rmc");
showUpdateRow("xCAT-UI");
echo '</table></div>';
}
?>

View File

@ -3,7 +3,47 @@
* update.php
*
*/
echo "<p>update </p>";
require_once "lib/security.php";
require_once "lib/functions.php";
require_once "lib/display.php";
displayMapper(array('home'=>'main.php', 'help' =>'', 'update'=>''));
?>
<div class="mContent">
<h1>Repository</h1>
<?php
$DevelRepository = "";
$StableRepository = "";
#supposed only AIX & LINUX
if ("aix" == strtolower(PHP_OS))
{
$DevelRepository = "http://xcat.sourceforge.net/aix/devel/xcat-core/";
$StableRepository = "http://xcat.sourceforge.net/aix/xcat-core/";
}
else
{
$DevelRepository = "http://xcat.sourceforge.net/yum/devel/xcat-core/";
$StableRepository = "http://xcat.sourceforge.net/yum/xcat-core/";
}
echo "<input type=\"radio\" name= \"reporadio\" value=\"" . $DevelRepository . "\">" . $DevelRepository . "(<strong>Devel</strong>)<br/>";
echo "<input type=\"radio\" name=\"reporadio\" value=\"" . $StableRepository . "\">" . $StableRepository . "(<strong>Stable</strong>)<br/>";
if(isset($_COOKIE["xcatrepository"]))
{
echo "<input type=\"radio\" checked=\"true\" name=\"reporadio\" value=\"\">Other:";
echo "<input style=\"width: 500px\" id=repositoryaddr value=\"" . $_COOKIE["xcatrepository"] ."\"<br/>";
}
else
{
echo "<input type=\"radio\" name=\"reporadio\" value=\"\">Other:";
echo "<input style=\"width: 500px\" id=repositoryaddr value=\"http://\"<br/>";
}
?>
</div>
<div id="temp"></div>
<div id="update" class="mContent">
<h1>xCAT Update Info</h1>
<?php showUpdateInfo(); ?>
<button onclick='fun_js_update()'>Update</button>
</div>
<div id=updateProcess>
</div>

View File

@ -0,0 +1,76 @@
<?php
/*
* Created on 2010-6-3
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
require_once "lib/functions.php";
require_once "lib/security.php";
require_once "lib/display.php";
function checkRpmPath($sUrl)
{
$hFileHandle = fopen($sUrl, 'r');
if ($hFileHandle)
{
fclose($hFileHandle);
return true;
}
else
{
return false;
}
}
//check rpm_path & rpm_name in request
if(!isset($_REQUEST['repo']))
{
echo "Please input a filepath.";
exit;
}
if (!isset($_REQUEST['rpmname']))
{
echo "Please select package.";
exit;
}
$sRpmPath = $_REQUEST['repo'];
if ("" == $sRpmPath)
{
echo "<label style=\"color:red\">Please input a filepath.</label>";
exit;
}
$sRpmNames = $_REQUEST['rpmname'];
if ("" == $sRpmNames)
{
echo "<label style=\"color:red\">Please select package.</label>";
exit;
}
if (!checkRpmPath($sRpmPath))
{
echo "<li style=\"color:red\">Repository Path Error!!</li>";
echo "</ul></div>";
return;
}
//set cookie must in front of any output
if (isset($_REQUEST["remember"]))
{
setcookie("xcatrepository", $sRpmPath, time() + 864000, "/");
}
else
{
setcookie("xcatrepository", "", time() - 172800, "/");
}
echo "<div class=\"mContent\">It will update <b>" . $sRpmNames ."</b> from <b>" . $sRpmPath . "</b>.<ul>";
echo "<li>Repository Path Check OK!</li>";
$Ret = docmd("webrun", array(), array("update", $sRpmNames, $sRpmPath));
var_dump($Ret);
echo "</ul></div>";
?>