diff --git a/xCAT-UI/js/nodes/nodes.js b/xCAT-UI/js/nodes/nodes.js index 67654005c..cad22d1ea 100644 --- a/xCAT-UI/js/nodes/nodes.js +++ b/xCAT-UI/js/nodes/nodes.js @@ -213,21 +213,19 @@ function loadSummaryDetail(ev, seriesIndex, pointIndex, data){ case 'os': case 'arch': case 'provmethod': - case 'nodetype':{ + case 'nodetype': table = 'nodetype'; - } - break; - case 'status': { + break; + case 'status': table = 'nodelist'; - } - break; + break; } var args = table + '.' + temp + '=='; if (data[0] != 'unknown') { args += data[0]; } - + drawNodesArea('', args, ''); } @@ -288,91 +286,97 @@ function drawNodesArea(targetgroup, cmdargs, message){ // Clear nodes division $('#nodes').empty(); - // Create loader - var loader = $('
').append(createLoader()); - // Create a tab for this group var tab = new Tab('nodesPageTabs'); setNodesTab(tab); tab.init(); $('#nodes').append(tab.object()); tab.add('summaryTab', 'Summary', '', false); - tab.add('nodesTab', 'Nodes', loader, false); + tab.add('nodesTab', 'Nodes', '', false); tab.add('graphTab', 'Graphic', '', false); - - $('#nodesPageTabs').bind('tabsselect', function(event, ui){ - // For the graphical tab, check the graphical data first - if (ui.index == 2){ - createPhysicalLayout(nodesList); - } - }); - - // Load group's summary pie charts - loadPieSummary(targetgroup); - - // To improve performance, get all nodes within selected group - // Get node definitions only for first 50 nodes - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'nodels', - tgt : targetgroup, - args : cmdargs, - msg : message - }, - - /** - * Get node definitions for first 50 nodes - * - * @param data - * Data returned from HTTP request - * @return Nothing - */ - success : function(data) { - var rsp = data.rsp; - var group = data.msg; - - // Save nodes in a list so it can be accessed later - nodesList = new Array(); - for (var i in rsp) { - if (rsp[i][0]) { - nodesList.push(rsp[i][0]); - } - } - - // Sort nodes list - nodesList.sort(); - - // Get first 50 nodes - var nodes = ''; - for (var i = 0; i < nodesList.length; i++) { - if (i > 49) { - break; - } - - nodes += nodesList[i] + ','; - } - - // Remove last comma - nodes = nodes.substring(0, nodes.length-1); - - // Get nodes definitions + + // Load nodes table when tab is selected + $('#nodesPageTabs').bind('tabsselect', function(event, ui){ + if (!$('#nodesTab').children().length && ui.index == 1) { + // Create loader + $('#nodesTab').append($('
').append(createLoader())); + + // To improve performance, get all nodes within selected group + // Get node definitions only for first 50 nodes $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { - cmd : 'lsdef', - tgt : '', - args : nodes, - msg : targetgroup + cmd : 'nodels', + tgt : targetgroup, + args : cmdargs, + msg : message }, - success : loadNodes + /** + * Get node definitions for first 50 nodes + * + * @param data + * Data returned from HTTP request + * @return Nothing + */ + success : function(data) { + var rsp = data.rsp; + var group = data.msg; + + // Save nodes in a list so it can be accessed later + nodesList = new Array(); + for (var i in rsp) { + if (rsp[i][0]) { + nodesList.push(rsp[i][0]); + } + } + + // Sort nodes list + nodesList.sort(); + + // Get first 50 nodes + var nodes = ''; + for (var i = 0; i < nodesList.length; i++) { + if (i > 49) { + break; + } + + nodes += nodesList[i] + ','; + } + + // Remove last comma + nodes = nodes.substring(0, nodes.length-1); + + // Get nodes definitions + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'lsdef', + tgt : '', + args : nodes, + msg : targetgroup + }, + + success : loadNodes + }); + + } }); - } }); + + // Load graphical layout when tab is selected + $('#nodesPageTabs').bind('tabsselect', function(event, ui){ + // For the graphical tab, check the graphical data first + if (!$('#graphTab').children().length && ui.index == 2) { + createPhysicalLayout(nodesList); + } + }); + + // Load group's summary pie charts (default) + loadPieSummary(targetgroup); } /** @@ -394,8 +398,8 @@ function mkAddNodeLink() { + '' + ''); @@ -840,7 +844,7 @@ function loadNodes(data) { // Provision var provLnk = 'Provision'; - var provMenu = createMenu([ boot2NetworkLnk, setBootStateLnk, rcons, provisionLnk]); + var provMenu = createMenu([boot2NetworkLnk, setBootStateLnk, rcons, provisionLnk]); // Create an action menu var actionsMenu = createMenu([ [ actionsLnk, actsMenu ], [ configLnk, configMenu ], [ provLnk, provMenu ] ]); @@ -3321,8 +3325,14 @@ function jump2Provision(tgtNodes){ */ function adjustColumnSize() { var cols = $('#' + nodesTableId).find('tbody tr:eq(0) td'); - for (var i in cols) { - var header = $('#' + nodesTableId + '_wrapper .dataTables_scrollHead .datatable thead tr th').eq(i); - header.css('width', cols.eq(i).outerWidth()); - } + + // If the column size is zero, wait until table is initialized + if (!cols.eq(1).outerWidth()) { + adjustColumnSize(); + } else { + for (var i in cols) { + var headers = $('#' + nodesTableId + '_wrapper .dataTables_scrollHead .datatable thead tr th').eq(i); + headers.css('width', cols.eq(i).outerWidth()); + } + } } \ No newline at end of file diff --git a/xCAT-UI/js/nodes/physical.js b/xCAT-UI/js/nodes/physical.js index 2c41c7864..6b0bf913f 100644 --- a/xCAT-UI/js/nodes/physical.js +++ b/xCAT-UI/js/nodes/physical.js @@ -456,17 +456,12 @@ function updateSelectNodeDiv(){ * @return action menu object */ function createActionMenu(){ - //create action bar + // Create action bar var actionBar = $('
'); - /** - * The following actions are available to perform against a given node: - * power, clone, delete, unlock, and advanced - */ - var powerLnk = $('Power'); - //power on + // Power on var powerOnLnk = $('Power on'); - powerOnLnk.bind('click', function(event) { + powerOnLnk.click(function() { var tgtNodes = getSelectNodes(); $.ajax({ url : 'lib/cmd.php', @@ -479,10 +474,10 @@ function createActionMenu(){ } }); }); - - //power off + + // Power off var powerOffLnk = $('Power off'); - powerOffLnk.bind('click', function(event) { + powerOffLnk.click(function() { var tgtNodes = getSelectNodes(); $.ajax({ url : 'lib/cmd.php', @@ -495,133 +490,96 @@ function createActionMenu(){ } }); }); - - //clone - var cloneLnk = $('Clone'); - cloneLnk.bind('click', function(event) { - /* - for (var name in selectNode) { - var mgt = graphicalNodeList[name]['mgt']; - - //create an instance of the plugin - var plugin; - switch(mgt) { - case "blade": - plugin = new bladePlugin(); - break; - case "fsp": - plugin = new fspPlugin(); - break; - case "hmc": - plugin = new hmcPlugin(); - break; - case "ipmi": - plugin = new ipmiPlugin(); - break; - case "ivm": - plugin = new ivmPlugin(); - break; - case "zvm": - plugin = new zvmPlugin(); - break; - } - - plugin.loadClonePage(name); - } - */ - }); - - //delete + + // Delete var deleteLnk = $('Delete'); - deleteLnk.bind('click', function(event) { + deleteLnk.click(function() { var tgtNodes = getSelectNodes(); if (tgtNodes) { loadDeletePage(tgtNodes); } }); - //unlock + // Unlock var unlockLnk = $('Unlock'); - unlockLnk.bind('click', function(event) { + unlockLnk.click(function() { var tgtNodes = getSelectNodes(); if (tgtNodes) { loadUnlockPage(tgtNodes); } }); - //run script + // Run script var scriptLnk = $('Run script'); - scriptLnk.bind('click', function(event) { + scriptLnk.click(function() { var tgtNodes = getSelectNodes(); if (tgtNodes) { loadScriptPage(tgtNodes); } }); - //update node + // Update var updateLnk = $('Update'); - updateLnk.bind('click', function(event) { + updateLnk.click(function() { var tgtNodes = getSelectNodes(); if (tgtNodes) { loadUpdatenodePage(tgtNodes); } }); - //set boot state + // Set boot state var setBootStateLnk = $('Set boot state'); - setBootStateLnk.bind('click', function(event) { + setBootStateLnk.click(function() { var tgtNodes = getSelectNodes(); if (tgtNodes) { loadNodesetPage(tgtNodes); } }); - //boot to network + // Boot to network var boot2NetworkLnk = $('Boot to network'); - boot2NetworkLnk.bind('click', function(event) { + boot2NetworkLnk.click(function() { var tgtNodes = getSelectNodes(); if (tgtNodes) { loadNetbootPage(tgtNodes); } }); - - //remote console - var rcons = $('Open console'); - rcons.bind('click', function(event){ + + // Remote console + var rconLnk = $('Open console'); + rconLnk.bind('click', function(event){ var tgtNodes = getSelectNodes(); if (tgtNodes) { loadRconsPage(tgtNodes); } }); - //edit properties + // Edit properties var editProps = $('Edit properties'); editProps.bind('click', function(event){ for (var node in selectNode) { loadEditPropsPage(node); } }); + + // Actions + var actionsLnk = 'Actions'; + var actsMenu = createMenu([deleteLnk, powerOnLnk, powerOffLnk, scriptLnk]); - var advancedLnk = $('Advanced'); + // Configurations + var configLnk = 'Configuration'; + var configMenu = createMenu([unlockLnk, updateLnk, editProps]); - //power actions - var powerActions = [ powerOnLnk, powerOffLnk ]; - var powerActionMenu = createMenu(powerActions); + // Provision + var provLnk = 'Provision'; + var provMenu = createMenu([boot2NetworkLnk, setBootStateLnk, rconLnk]); - //advanced actions - var advancedActions; - advancedActions = [ boot2NetworkLnk, scriptLnk, setBootStateLnk, updateLnk, rcons, editProps ]; - var advancedActionMenu = createMenu(advancedActions); - - /** - * create an action menu - */ - var actionsDIV = $('
'); - var actions = [ [ powerLnk, powerActionMenu ], deleteLnk, unlockLnk, [ advancedLnk, advancedActionMenu ] ]; - var actionMenu = createMenu(actions); - actionMenu.superfish(); - actionsDIV.append(actionMenu); - actionBar.append(actionsDIV); + // Create an action menu + var actionsMenu = createMenu([ [ actionsLnk, actsMenu ], [ configLnk, configMenu ], [ provLnk, provMenu ] ]); + actionsMenu.superfish(); + actionsMenu.css('display', 'inline-block'); + actionBar.append(actionsMenu); + actionBar.css('margin-top', '10px'); return actionBar; }