From 6699e33fc05c840bd35c184ba67de4e2eceb0b0f Mon Sep 17 00:00:00 2001 From: phamt Date: Thu, 15 Jul 2010 23:22:13 +0000 Subject: [PATCH] Cleaned up code git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6775 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/custom/zvm.js | 24 +++++++ xCAT-UI/js/custom/zvmUtils.js | 120 +++++++++++++++++----------------- xCAT-UI/js/monitor/monitor.js | 29 ++------ 3 files changed, 89 insertions(+), 84 deletions(-) diff --git a/xCAT-UI/js/custom/zvm.js b/xCAT-UI/js/custom/zvm.js index 5289e001d..127414eb8 100644 --- a/xCAT-UI/js/custom/zvm.js +++ b/xCAT-UI/js/custom/zvm.js @@ -1361,4 +1361,28 @@ function loadProvisionPage(tabId) { } }); provForm.append(provisionBtn); +} + +/** + * Load the resources + * + * @return Nothing + */ +function loadResources() { + // Reset resource table + setDiskDataTable(''); + setNetworkDataTable(''); + + // Get hardware control points + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'nodels', + tgt : 'mgt==zvm', + args : 'zvm.hcp', + msg : '' + }, + success : getZResources + }); } \ No newline at end of file diff --git a/xCAT-UI/js/custom/zvmUtils.js b/xCAT-UI/js/custom/zvmUtils.js index 20b6e3e51..cd071f374 100644 --- a/xCAT-UI/js/custom/zvmUtils.js +++ b/xCAT-UI/js/custom/zvmUtils.js @@ -923,6 +923,66 @@ function updateCloneStatus(data) { } } +/** + * Get the resources + * + * @param data + * Data from HTTP request + * @return Nothing + */ +function getZResources(data) { + // Do not set cookie if there is no output + if (data.rsp) { + // Loop through each line + var node, hcp; + var hcpHash = new Object(); + for ( var i in data.rsp) { + node = data.rsp[i][0]; + hcp = data.rsp[i][1]; + hcpHash[hcp] = 1; + } + + // Create an array for hardware control points + var hcps = new Array(); + for ( var key in hcpHash) { + hcps.push(key); + // Get the short host name + hcp = key.split('.')[0]; + + // Get disk pools + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'lsvm', + tgt : hcp, + args : '--diskpoolnames', + msg : hcp + }, + + success : getDiskPool + }); + + // Get network names + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'lsvm', + tgt : hcp, + args : '--getnetworknames', + msg : hcp + }, + + success : getNetwork + }); + } + + // Set cookie + $.cookie('HCP', hcps); + } +} + /** * Get node attributes from HTTP request data * @@ -1287,66 +1347,6 @@ function setNetworkCookies(data) { } } -/** - * Get the resources for ZVM - * - * @param data - * Data from HTTP request - * @return Nothing - */ -function getZResources(data) { - // Do not set cookie if there is no output - if (data.rsp) { - // Loop through each line - var node, hcp; - var hcpHash = new Object(); - for ( var i in data.rsp) { - node = data.rsp[i][0]; - hcp = data.rsp[i][1]; - hcpHash[hcp] = 1; - } - - // Create an array for hardware control points - var hcps = new Array(); - for ( var key in hcpHash) { - hcps.push(key); - // Get the short host name - hcp = key.split('.')[0]; - - // Get disk pools - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'lsvm', - tgt : hcp, - args : '--diskpoolnames', - msg : hcp - }, - - success : getDiskPool - }); - - // Get network names - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'lsvm', - tgt : hcp, - args : '--getnetworknames', - msg : hcp - }, - - success : getNetwork - }); - } - - // Set cookie - $.cookie('HCP', hcps); - } -} - /** * Get the contents of each disk pool * diff --git a/xCAT-UI/js/monitor/monitor.js b/xCAT-UI/js/monitor/monitor.js index 94e147912..94c6fb277 100644 --- a/xCAT-UI/js/monitor/monitor.js +++ b/xCAT-UI/js/monitor/monitor.js @@ -71,7 +71,7 @@ function loadMonitorPage() { // Create info bar var resrcInfoBar = createInfoBar('Select a hardware to view its resources'); resrcForm.append(resrcInfoBar); - + // Create drop-down menu // Hardware available to provision - ipmi, blade, hmc, ivm, fsp, and zvm var div = $('
'); @@ -104,32 +104,13 @@ function loadMonitorPage() { // Generate new tab ID var newTabId = hw + 'ResourceTab'; if (!$('#' + newTabId).length) { - var loader = createLoader('zvmResourceLoader'); + var loader = createLoader(hw + 'ResourceLoader'); loader = $('
').append(loader); tab.add(newTabId, hw, loader); - if (hw == 'zvm') { - // Reset resource table - setDiskDataTable(''); - setNetworkDataTable(''); - - // Get hardware control points - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'nodels', - tgt : 'mgt==zvm', - args : 'zvm.hcp', - msg : '' - }, - success : getZResources - }); - } - // TODO: Add other platforms to this section - else { - $('#' + newTabId).append(); - } + // Load plugin code + includeJs("js/custom/" + hw + ".js"); + loadResources(); } // Select tab