From feec15d49ac2c593a0c8805c135eedd82e3378bd Mon Sep 17 00:00:00 2001 From: xq2005 Date: Mon, 5 Jul 2010 05:21:05 +0000 Subject: [PATCH] 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 --- xCAT-UI/ui.old/js/xcat.js | 67 ++++++++++++++++++++++++++++ xCAT-UI/ui.old/lib/display.php | 35 +++++++++++++++ xCAT-UI/ui.old/update.php | 46 +++++++++++++++++-- xCAT-UI/ui.old/updateprocess.php | 76 ++++++++++++++++++++++++++++++++ 4 files changed, 221 insertions(+), 3 deletions(-) create mode 100644 xCAT-UI/ui.old/updateprocess.php diff --git a/xCAT-UI/ui.old/js/xcat.js b/xCAT-UI/ui.old/js/xcat.js index 73fa00603..f115933e6 100644 --- a/xCAT-UI/ui.old/js/xcat.js +++ b/xCAT-UI/ui.old/js/xcat.js @@ -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(''); + $('#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'); diff --git a/xCAT-UI/ui.old/lib/display.php b/xCAT-UI/ui.old/lib/display.php index e16e96e0e..8e6e09aea 100644 --- a/xCAT-UI/ui.old/lib/display.php +++ b/xCAT-UI/ui.old/lib/display.php @@ -984,4 +984,39 @@ function showxCATInfo() { echo ""; } +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 (""); + echo (""); + echo ("" . $RpmName . ""); + echo ("" . $verstr . ""); + echo (""); + } + } +} + + +function showUpdateInfo() { + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + showUpdateRow("xCAT-client"); + showUpdateRow("perl-xCAT"); + showUpdateRow("xCAT-server"); + showUpdateRow("xCAT"); + showUpdateRow("xCAT-rmc"); + showUpdateRow("xCAT-UI"); + + echo '
Package NameVersion
'; +} ?> diff --git a/xCAT-UI/ui.old/update.php b/xCAT-UI/ui.old/update.php index b34aa0712..aeee5a7bd 100644 --- a/xCAT-UI/ui.old/update.php +++ b/xCAT-UI/ui.old/update.php @@ -3,7 +3,47 @@ * update.php * */ -echo "

update

"; - - + require_once "lib/security.php"; + require_once "lib/functions.php"; + require_once "lib/display.php"; + displayMapper(array('home'=>'main.php', 'help' =>'', 'update'=>'')); ?> +
+

Repository

+" . $DevelRepository . "(Devel)
"; + echo "" . $StableRepository . "(Stable)
"; + if(isset($_COOKIE["xcatrepository"])) + { + echo "Other:"; + echo ""; + } + else + { + echo "Other:"; + echo ""; + } +?> +
+
+
+

xCAT Update Info

+ + +
+
+
diff --git a/xCAT-UI/ui.old/updateprocess.php b/xCAT-UI/ui.old/updateprocess.php new file mode 100644 index 000000000..40ec988cd --- /dev/null +++ b/xCAT-UI/ui.old/updateprocess.php @@ -0,0 +1,76 @@ +Please input a filepath."; + exit; +} +$sRpmNames = $_REQUEST['rpmname']; +if ("" == $sRpmNames) +{ + echo ""; + exit; +} + +if (!checkRpmPath($sRpmPath)) +{ + echo "
  • Repository Path Error!!
  • "; + echo ""; + return; +} + +//set cookie must in front of any output +if (isset($_REQUEST["remember"])) +{ + setcookie("xcatrepository", $sRpmPath, time() + 864000, "/"); +} +else +{ + setcookie("xcatrepository", "", time() - 172800, "/"); +} + +echo "
    It will update " . $sRpmNames ." from " . $sRpmPath . ".
    "; +?>