From ed50cf6c14172fbc6daab72a908252bb20450c0b Mon Sep 17 00:00:00 2001 From: phamt Date: Fri, 10 Dec 2010 21:37:28 +0000 Subject: [PATCH] Added server browser to update page. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8375 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/nodes/updatenode.js | 214 +++++++++++++++++++++------------ xCAT-UI/js/provision/images.js | 5 +- xCAT-UI/js/ui.js | 4 +- 3 files changed, 138 insertions(+), 85 deletions(-) diff --git a/xCAT-UI/js/nodes/updatenode.js b/xCAT-UI/js/nodes/updatenode.js index 174755101..5a652543e 100644 --- a/xCAT-UI/js/nodes/updatenode.js +++ b/xCAT-UI/js/nodes/updatenode.js @@ -7,7 +7,7 @@ */ function loadUpdatenodePage(tgtNodes) { // Get OS images - $.ajax( { + $.ajax({ url : 'lib/cmd.php', dataType : 'json', data : { @@ -20,7 +20,7 @@ function loadUpdatenodePage(tgtNodes) { success : setOSImageCookies }); - // Get node OS (AIX, rh*, centos*, fedora*, or sles*) + // Get node OS var osHash = new Object(); var nodes = tgtNodes.split(','); for (var i in nodes) { @@ -58,31 +58,59 @@ function loadUpdatenodePage(tgtNodes) { // Create info bar var infoBar = createInfoBar('Update nodes in an xCAT environment'); updatenodeForm.append(infoBar); - + // Create target node or group input - var target = $('
'); - updatenodeForm.append(target); + var tgt = $('
'); + updatenodeForm.append(tgt); // Create options - var optsDIV = $('
'); - var optsLabel = $(''); - var optsList = $(''); - optsDIV.append(optsLabel); - optsDIV.append(optsList); - updatenodeForm.append(optsDIV); + var options = $('
'); + var optionsLabel = $(''); + var optionsList = $(''); + options.append(optionsLabel); + options.append(optionsList); + updatenodeForm.append(options); - // Create update all software checkbox (AIX) + // Create update all software checkbox (only AIX) if (osHash['AIX']) { + var updateAllOption = $('
  • '); var updateAllChkBox = $(''); - var updateAllOpt = $('
  • '); - optsList.append(updateAllOpt); - updateAllOpt.append(updateAllChkBox); - updateAllOpt.append('Install or update all software contained in the source directory'); - var allSwScrDirectory = $('
  • '); + updateAllOption.append(updateAllChkBox); + optionsList.append(updateAllOption); + updateAllOption.append('Install or update all software contained in the source directory'); + + // Create source directory input + var allSwScrDirectory = $('
  • '); + // Browse server directory and files + var allSWSrcDirBrowse = createButton('Browse'); + allSWSrcDirBrowse.serverBrowser({ + onSelect : function(path) { + $('#allSwSrcDirectory').val(path); + }, + onLoad : function() { + return $('#allSwSrcDirectory').val(); + }, + knownExt : [ 'exe', 'js', 'txt' ], + knownPaths : [ { + text : 'Install', + image : 'desktop.png', + path : '/install' + } ], + imageUrl : 'images/', + systemImageUrl : 'images/', + handlerUrl : 'lib/getpath.php', + title : 'Browse', + requestMethod : 'POST', + width : '500', + height : '300', + basePath : '/install', // Limit user to only install directory + multiselect : true + }); + allSwScrDirectory.append(allSWSrcDirBrowse); allSwScrDirectory.hide(); - optsList.append(allSwScrDirectory); - - // Show alternate source directory when checked + optionsList.append(allSwScrDirectory); + + // Show source directory when checked updateAllChkBox.bind('click', function(event) { if ($(this).is(':checked')) { allSwScrDirectory.show(); @@ -93,67 +121,93 @@ function loadUpdatenodePage(tgtNodes) { } // Create update software checkbox + var updateOption = $('
  • '); var updateChkBox = $(''); - var updateOpt = $('
  • '); - optsList.append(updateOpt); - updateOpt.append(updateChkBox); - updateOpt.append('Update existing software'); + optionsList.append(updateOption); + updateOption.append(updateChkBox); + updateOption.append('Update existing software'); // Create source directory input - var scrDirectory = $('
  • '); + var scrDirectory = $('
  • '); + // Browse server directory and files + var srcDirBrowse = createButton('Browse'); + srcDirBrowse.serverBrowser({ + onSelect : function(path) { + $('#srcDirectory').val(path); + }, + onLoad : function() { + return $('#srcDirectory').val(); + }, + knownExt : [ 'exe', 'js', 'txt' ], + knownPaths : [ { + text : 'Install', + image : 'desktop.png', + path : '/install' + } ], + imageUrl : 'images/', + systemImageUrl : 'images/', + handlerUrl : 'lib/getpath.php', + title : 'Browse', + requestMethod : 'POST', + width : '500', + height : '300', + basePath : '/install', // Limit user to only install directory + multiselect : true + }); + scrDirectory.append(srcDirBrowse); scrDirectory.hide(); - optsList.append(scrDirectory); + optionsList.append(scrDirectory); // Create other packages input - var otherPkgs = $('
  • '); + var otherPkgs = $('
  • '); otherPkgs.hide(); - optsList.append(otherPkgs); + optionsList.append(otherPkgs); - // Create RPM flags input - var rpmFlags = $('
  • '); - rpmFlags.hide(); - optsList.append(rpmFlags); + // Create RPM flags input (only AIX) + var aixRpmFlags = $('
  • '); + aixRpmFlags.hide(); + optionsList.append(aixRpmFlags); - // Create installp flags input - var installPFlags = $('
  • '); - installPFlags.hide(); - optsList.append(installPFlags); + // Create installp flags input (only AIX) + var aixInstallPFlags = $('
  • '); + aixInstallPFlags.hide(); + optionsList.append(aixInstallPFlags); - // Create emgr flags input - var emgrFlags = $('
  • '); - emgrFlags.hide(); - optsList.append(emgrFlags); + // Create emgr flags input (only AIX) + var aixEmgrFlags = $('
  • '); + aixEmgrFlags.hide(); + optionsList.append(aixEmgrFlags); - // Show alternate source directory when checked + // Show flags when checked updateChkBox.bind('click', function(event) { if ($(this).is(':checked')) { scrDirectory.show(); otherPkgs.show(); if (osHash['AIX']) { - rpmFlags.show(); - installPFlags.show(); - emgrFlags.show(); + aixRpmFlags.show(); + aixInstallPFlags.show(); + aixEmgrFlags.show(); } } else { scrDirectory.hide(); otherPkgs.hide(); if (osHash['AIX']) { - rpmFlags.hide(); - installPFlags.hide(); - emgrFlags.hide(); + aixRpmFlags.hide(); + aixInstallPFlags.hide(); + aixEmgrFlags.hide(); } } }); // Create postscripts input + var postOption = $('
  • '); var postChkBox = $(''); - var postOpt = $('
  • '); - optsList.append(postOpt); - postOpt.append(postChkBox); - postOpt.append('Run postscripts'); - var postscripts = $('
  • '); + optionsList.append(postOption); + postOption.append(postChkBox); + postOption.append('Run postscripts'); + var postscripts = $('
  • '); postscripts.hide(); - optsList.append(postscripts); + optionsList.append(postscripts); // Show alternate source directory when checked postChkBox.bind('click', function(event) { @@ -163,16 +217,16 @@ function loadUpdatenodePage(tgtNodes) { postscripts.hide(); } }); - optsList.append('
  • Distribute and synchronize files
  • '); - optsList.append('
  • Update the ssh keys and host keys for the service nodes and compute nodes
  • '); + optionsList.append('
  • Distribute and synchronize files
  • '); + optionsList.append('
  • Update the ssh keys and host keys for the service nodes and compute nodes
  • '); // Create update OS checkbox if (!osHash['AIX']) { + var osOption = $('
  • '); var osChkBox = $(''); - var osOpt = $('
  • '); - optsList.append(osOpt); - osOpt.append(osChkBox); - osOpt.append('Update the operating system'); + optionsList.append(osOption); + osOption.append(osChkBox); + osOption.append('Update the operating system'); var os = $('
  • ').hide(); var osLabel = $(''); @@ -186,7 +240,7 @@ function loadUpdatenodePage(tgtNodes) { }); os.append(osLabel); os.append(osInput); - optsList.append(os); + optionsList.append(os); // Show alternate source directory when checked osChkBox.bind('click', function(event) { @@ -224,68 +278,68 @@ function loadUpdatenodePage(tgtNodes) { // Generate arguments var chkBoxes = $("#" + newTabId + " input[type='checkbox']:checked"); - var optStr = ''; - var opt; + var optionsStr = ''; + var option; for ( var i = 0; i < chkBoxes.length; i++) { - opt = chkBoxes.eq(i).attr('name'); - optStr += '-' + opt; + option = chkBoxes.eq(i).attr('name'); + optionsStr += '-' + option; // If update all software is checked - if (opt == 'S') { + if (option == 'S') { var srcDir = $('#' + newTabId + ' input[name=allSwSrcDirectory]').val(); if (srcDir) { - optStr += ';-d ' + srcDir; + optionsStr += ';-d ' + srcDir; } } // If update software is checked - if (opt == 'S') { + if (option == 'S') { // Get source directory - var srcDir = $('#' + newTabId + ' input[name=srcDirectory]').val(); - if (srcDir) { - optStr += ';-d;' + srcDir; + var srcDirectory = $('#' + newTabId + ' input[name=srcDirectory]').val(); + if (srcDirectory) { + optionsStr += ';-d;' + srcDirectory; } // Get otherpkgs var otherpkgs = $('#' + newTabId + ' input[name=otherpkgs]').val(); if (otherpkgs) { - optStr += ';otherpkgs=' + otherpkgs; + optionsStr += ';otherpkgs=' + otherpkgs; } // Get rpm_flags var rpm_flags = $('#' + newTabId + ' input[name=rpm_flags]').val(); if (rpm_flags) { - optStr += ';rpm_flags=' + rpm_flags; + optionsStr += ';rpm_flags=' + rpm_flags; } // Get installp_flags var installp_flags = $('#' + newTabId + ' input[name=installp_flags]').val(); if (installp_flags) { - optStr += ';installp_flags=' + installp_flags; + optionsStr += ';installp_flags=' + installp_flags; } // Get emgr_flags var emgr_flags = $('#' + newTabId + ' input[name=emgr_flags]').val(); if (emgr_flags) { - optStr += ';emgr_flags=' + emgr_flags; + optionsStr += ';emgr_flags=' + emgr_flags; } } // If postscripts is checked - if (opt == 'P') { + if (option == 'P') { // Get postscripts - optStr += ';' + $('#' + newTabId + ' input[name=postscripts]').val(); + optionsStr += ';' + $('#' + newTabId + ' input[name=postscripts]').val(); } // If operating system is checked - if (opt == 'o') { + if (option == 'o') { // Get the OS - optStr += ';' + $('#' + newTabId + ' input[name=os]').val(); + optionsStr += ';' + $('#' + newTabId + ' input[name=os]').val(); } // Append ; to end of string if (i < (chkBoxes.length - 1)) { - optStr += ';'; + optionsStr += ';'; } } @@ -306,7 +360,7 @@ function loadUpdatenodePage(tgtNodes) { data : { cmd : 'updatenode', tgt : tgts, - args : optStr, + args : optionsStr, msg : 'out=' + statBarId + ';cmd=updatenode;tgt=' + tgts }, diff --git a/xCAT-UI/js/provision/images.js b/xCAT-UI/js/provision/images.js index a5e978688..a76c509ab 100644 --- a/xCAT-UI/js/provision/images.js +++ b/xCAT-UI/js/provision/images.js @@ -644,16 +644,15 @@ function loadCopyLinuxPage() { text : 'Install', image : 'desktop.png', path : '/install' - } ], // Limit user to only install directory + } ], imageUrl : 'images/', systemImageUrl : 'images/', handlerUrl : 'lib/getpath.php', title : 'Browse', - basePath : '', requestMethod : 'POST', width : '500', height : '300', - basePath : '/install' + basePath : '/install' // Limit user to only install directory }); /** diff --git a/xCAT-UI/js/ui.js b/xCAT-UI/js/ui.js index 63fb0ba04..7b599e159 100644 --- a/xCAT-UI/js/ui.js +++ b/xCAT-UI/js/ui.js @@ -424,7 +424,8 @@ function initPage() { includeJs("js/jquery/jquery.jstree.js"); includeJs("js/jquery/jquery.flot.js"); includeJs("js/jquery/tooltip.min.js"); - + includeJs("js/jquery/jquery.serverBrowser.js"); + // Page plugins includeJs("js/configure/configure.js"); includeJs("js/monitor/monitor.js"); @@ -463,7 +464,6 @@ function initPage() { headers.eq(1).css('background-color', '#A9D0F5'); loadConfigPage(); } else if (page == 'provision.php') { - includeJs("js/jquery/jquery.serverBrowser.js"); includeJs("js/provision/images.js"); headers.eq(2).css('background-color', '#A9D0F5'); loadProvisionPage();