From e791bc78422f30fbab82fa2cebaf8717eece068d Mon Sep 17 00:00:00 2001 From: xq2005 Date: Wed, 21 Jul 2010 03:35:31 +0000 Subject: [PATCH] modified by xu qing put it under the configure page as an additional tab git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6809 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/configure/configure.js | 5 + xCAT-UI/js/configure/update.js | 264 ++++++++++++++++++++++++++++++ xCAT-UI/js/ui.js | 2 +- xCAT-UI/lib/ui.php | 1 - 4 files changed, 270 insertions(+), 2 deletions(-) create mode 100644 xCAT-UI/js/configure/update.js diff --git a/xCAT-UI/js/configure/configure.js b/xCAT-UI/js/configure/configure.js index da426c86d..b1656445f 100644 --- a/xCAT-UI/js/configure/configure.js +++ b/xCAT-UI/js/configure/configure.js @@ -74,6 +74,9 @@ function loadConfigPage() { // Configure xCAT datable tables tab.add('configTablesTab', 'Tables', loader); + // Add the update tab + tab.add('updateTab', 'Update'); + // Get list of tables and their descriptions $.ajax( { url : 'lib/cmd.php', @@ -87,6 +90,8 @@ function loadConfigPage() { success : loadTableNames }); + + loadUpdatePage(); } /** diff --git a/xCAT-UI/js/configure/update.js b/xCAT-UI/js/configure/update.js new file mode 100644 index 000000000..f83381130 --- /dev/null +++ b/xCAT-UI/js/configure/update.js @@ -0,0 +1,264 @@ +/** + * Load update page + * + * @return Nothing + */ + function loadUpdatePage() { + + repositoryDiv = $('
'); + rpmDiv = $('
'); + updateDiv = $('
'); + + $('#updateTab').append(repositoryDiv); + $('#updateTab').append(rpmDiv); + $('#updateTab').append(updateDiv); + + repositoryDiv.append("

Repository

"); + + $.ajax( { + url : 'lib/systemcmd.php', + dataType : 'json', + data : { + cmd : 'ostype' + }, + + success : showRepository + }); + + rpmDiv.append("

xCAT Update Info

"); + + $.ajax({ + url: 'lib/systemcmd.php', + dataType : 'json', + data : { + cmd : 'rpm -q xCAT-client perl-xCAT xCAT-server xCAT xCAT-rmc xCAT-UI' + }, + + success : showRpmInfo + }); + } + +/** + * Show the Rpm Repository, it can use user's last choice and input + * + * @return Nothing + */ +function showRepository(data) { + var DevelRepository = ""; + var StableRepository = ""; + var Show = ""; + + //get the corresponding repository by OS Type + if ("aix" == data.rsp) + { + 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/"; + } + + //dispaly the Devel Repository, remember user's last selection + Show = Show + ""; + Show = Show + DevelRepository + "(Devel)
"; + + $('#repository').append(Show); + + //dispaly the Stable Repository, remember user's last selection + Show = ""; + Show = Show + StableRepository + "(Stable)
"; + + $('#repository').append(Show); + + //dispaly the Input Repository, remember user's last selection + if (($.cookie('xcatrepository')) + && (1 != $.cookie('xcatrepository')) + && (2 != $.cookie('xcatrepository'))) + { + Show = "Other:"; + Show += ""; + } + else + { + Show = "Other:"; + Show += ""; + } + + $('#repository').append(Show); +} + +function showRpmInfo(data) +{ + var Rpms = null; + var Show = ""; + var RpmNames = new Array("xCAT-client","perl-xCAT","xCAT-server","xCAT","xCAT-rmc","xCAT-UI"); + var temp = 0; + if(null == data.rsp) + { + $('#rpm').append("Get Rpm Info Error!"); + return; + } + + Rpms = data.rsp.split(/\n/); + //no rpm installed, return + if (1 > Rpms.length) + { + $('#rpm').append("No Rpm installed!"); + return; + } + + Show = ""; + Show += ""; + Show += ""; + Show += ""; + Show += ""; + + for (temp = 0; temp < Rpms.length; temp++) + { + //empty line continue + if ("" == Rpms[temp]) + { + continue; + } + + //the rpm is not installed, continue + if (-1 != Rpms[temp].indexOf("not")) + { + continue; + } + + //show the version in table + Show += ""; + Show += ""; + Show += ""; + Show += ""; + } + Show += "
Package NameVersion
" + RpmNames[temp] + "" + Rpms[temp].substr(RpmNames[temp].length + 1) + "
"; + Show += "" + $('#rpm').append(Show); + + //add the update button + var updateButton = createButton('Update'); + $('#rpm').append(updateButton); + updateButton.bind('click', function(){ + updateRpm(); + }); +} + +function updateSelectAll() +{ + var check_status = $('#selectall').attr('checked'); + $('input:checkbox').attr('checked', check_status); +} + +function updateRpm() +{ + var rpmPath = $('input[type=radio]:checked').val(); + var rpmPathType = "0"; + var rpms = ""; + var temp = ""; + + if(undefined == rpmPath) + { + rpmPath = ""; + } + + //select other and we should use the value in the input + if ("" == rpmPath) + { + //user input the repo, and we must stroe it in the cookie + rpmPath = $('#repositoryaddr').val(); + rpmPathType = rpmPath; + } + else + { + if(-1 == rpmPath.toLowerCase().indexOf("devel")) + { + rpmPathType = "2"; + } + else + { + rpmPathType = "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); + } + + if ("" == rpms) + { + $('#update').empty(); + $('#update').append("Please select the rpm!"); + return; + } + + if ("" == rpmPath) + { + $('#update').empty(); + $('#update').append("Please select or input the repository!"); + return; + } + + //remember users' choice and input + $.cookie('xcatrepository', rpmPathType, { path: '/xcat', expires: 10 }); + + $('#update').empty(); + $('#update').append("

update " + rpms + " from " + rpmPath + "

"); + $('#update').append(""); + + // send the update command to server + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'webrun', + tgt : '', + args : 'update;' + rpms + ";" + rpmPath, + msg : '' + }, + + success : ShowUpdateResult + }); +} + +function ShowUpdateResult(data) +{ + var temp = 0; + $('#loadingpic').remove(); + $('#update').append("Update finished."); + for (temp = 0; temp < data.rsp.length; temp++) + { + $('#update').append(data.rsp[temp] + ""); + } +} \ No newline at end of file diff --git a/xCAT-UI/js/ui.js b/xCAT-UI/js/ui.js index f0d4a6648..9e09bb345 100644 --- a/xCAT-UI/js/ui.js +++ b/xCAT-UI/js/ui.js @@ -400,10 +400,10 @@ function initPage() { includeJs("js/jquery/hoverIntent.js"); includeJs("js/jquery/jquery.tree.js"); includeJs("js/configure/configure.js"); + includeJs("js/configure/update.js"); includeJs("js/monitor/monitor.js"); includeJs("js/nodes/nodes.js"); includeJs("js/provision/provision.js"); - includeJs("js/update/update.js"); // Get the page being loaded var url = window.location.pathname; diff --git a/xCAT-UI/lib/ui.php b/xCAT-UI/lib/ui.php index ca90051dc..06a94adc7 100644 --- a/xCAT-UI/lib/ui.php +++ b/xCAT-UI/lib/ui.php @@ -32,7 +32,6 @@ function loadPage(){
  • Configure
  • Provision
  • Monitor
  • -
  • Update
  • ';