From 2f72eaa2eb1475d977dde47822b737980864f78f Mon Sep 17 00:00:00 2001 From: xq2005 Date: Fri, 12 Nov 2010 07:46:42 +0000 Subject: [PATCH] add basic operations on graphical layout page git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8138 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/css/style.css | 1 + xCAT-UI/js/nodes/nodes.js | 2 +- xCAT-UI/js/nodes/physical.js | 151 ++++++++++++++++++----------------- 3 files changed, 78 insertions(+), 76 deletions(-) diff --git a/xCAT-UI/css/style.css b/xCAT-UI/css/style.css index ad20ba2ab..51bb9a4d0 100644 --- a/xCAT-UI/css/style.css +++ b/xCAT-UI/css/style.css @@ -118,6 +118,7 @@ body { -webkit-border-radius: .5em; border-radius: .5em; width: 1000px; + min-height: 600px; margin: 10px auto; background-color: white; overflow: auto; diff --git a/xCAT-UI/js/nodes/nodes.js b/xCAT-UI/js/nodes/nodes.js index a6bed64b0..b3adfb8fc 100644 --- a/xCAT-UI/js/nodes/nodes.js +++ b/xCAT-UI/js/nodes/nodes.js @@ -89,7 +89,7 @@ function loadNodesPage() { data : { cmd : 'nodels', tgt : 'all', - args : 'nodetype.nodetype;ppc.parent;vpd.mtm;nodelist.status', + args : 'nodetype.nodetype;ppc.parent;vpd.mtm;nodelist.status;nodehm.mgt', msg : '' }, diff --git a/xCAT-UI/js/nodes/physical.js b/xCAT-UI/js/nodes/physical.js index be06c530a..6e9ae33d5 100644 --- a/xCAT-UI/js/nodes/physical.js +++ b/xCAT-UI/js/nodes/physical.js @@ -4,7 +4,7 @@ var bpaList; var fspList; var lparList; var nodeList; -var selectLpar = new Object(); +var selectNode = new Object(); /** * extract all nodes userful data into a hash, which is used for creating graphical * @@ -39,6 +39,11 @@ function extractGraphicalData(data){ case 'vpd.mtm': { nodeList[nodeName]['mtm'] = nodes[i][1]; } + break; + case 'nodehm.mgt': { + nodeList[nodeName]['mgt'] = nodes[i][1]; + } + break; default : break; } @@ -185,25 +190,25 @@ function createGraphical(bpa, fsp, area){ row.append(td); } - var selectLparDiv = $('
'); + var selectNodeDiv = $('
'); var temp = 0; - for (var i in selectLpar){ + for (var i in selectNode){ temp ++; break; } //there is not selected lpars, show the info bar if (0 == temp){ - selectLparDiv.append(createInfoBar('Hover CEC and select lpars to do operations.')); + selectNodeDiv.append(createInfoBar('Hover CEC and select lpars to do operations.')); } //show selected lpars else{ - updateSelectLparDiv(); + updateSelectNodeDiv(); } //add buttons area.append(createActionMenu()); - area.append(selectLparDiv); + area.append(selectNodeDiv); area.append(graphTable); $('.tooltip input[type = checkbox]').bind('click', function(){ @@ -212,15 +217,15 @@ function createGraphical(bpa, fsp, area){ return; } if (true == $(this).attr('checked')){ - selectLpar[lparName] = 1; + selectNode[lparName] = 1; $('#graphTable [name=' + lparName + ']').css('border-color', 'aqua'); } else{ - delete selectLpar[lparName]; + delete selectNode[lparName]; $('#graphTable [name=' + lparName + ']').css('border-color', '#BDBDBD'); } - updateSelectLparDiv(); + updateSelectNodeDiv(); }); $('.fspDiv2, .fspDiv4, .fspDiv42').tooltip({ @@ -256,14 +261,14 @@ function showSelectDialog(lpars){ } else{ //add the dialog content - var selectTable = $('
'); + var selectTable = $('
'); selectTable.append('NameStatus'); for (var lparIndex in lpars){ var row = $(''); var lparName = lpars[lparIndex]; var color = statusMap(lparList[lparName]); - if (selectLpar[lparName]){ + if (selectNode[lparName]){ row.append(''); } else{ @@ -287,22 +292,22 @@ function showSelectDialog(lpars){ $(this).dialog('close'); }, ok : function(){ - $('#selectLparTable input[type=checkbox]').each(function(){ + $('#selectNodeTable input[type=checkbox]').each(function(){ var lparName = $(this).attr('name'); if ('' == lparName){ //continue return true; } if (true == $(this).attr('checked')){ - selectLpar[lparName] = 1; + selectNode[lparName] = 1; $('#graphTable [name=' + lparName + ']').css('border-color', 'aqua'); } else{ - delete selectLpar[lparName]; - $('#graphTable [name=' + lparName + ']').css('border-color', 'transparent'); + delete selectNode[lparName]; + $('#graphTable [name=' + lparName + ']').css('border-color', '#BDBDBD'); } }); - updateSelectLparDiv(); + updateSelectNodeDiv(); $(this).dialog('close'); } } @@ -310,32 +315,32 @@ function showSelectDialog(lpars){ } /** - * update the lpars' background in cec, lpars area and selectLpar + * update the lpars' background in cec, lpars area and selectNode * * @param * @return * **/ -function updateSelectLparDiv(){ +function updateSelectNodeDiv(){ var temp = 0; - $('#selectLparDiv').empty(); + $('#selectNodeDiv').empty(); //add buttons - $('#selectLparDiv').append('Lpars: '); - for(var lparName in selectLpar){ - $('#selectLparDiv').append(lparName + ' '); + $('#selectNodeDiv').append('Lpars: '); + for(var lparName in selectNode){ + $('#selectNodeDiv').append(lparName + ' '); temp ++; if (6 < temp){ - $('#selectLparDiv').append('...'); + $('#selectNodeDiv').append('...'); break; } } var reselectButton = createButton('Reselect'); - $('#selectLparDiv').append(reselectButton); + $('#selectNodeDiv').append(reselectButton); reselectButton.bind('click', function(){ - reselectLpars(); + reselectNodes(); }); } @@ -356,17 +361,11 @@ function createActionMenu(){ * The following actions are available to perform against a given node: * power, clone, delete, unlock, and advanced */ - /* - * Power - */ var powerLnk = $('Power'); - - /* - * Power on - */ + //Power on var powerOnLnk = $('Power on'); powerOnLnk.bind('click', function(event) { - var tgtNodes = getSelectLpars(); + var tgtNodes = getSelectNodes(); $.ajax( { url : 'lib/cmd.php', dataType : 'json', @@ -379,12 +378,10 @@ function createActionMenu(){ }); }); - /* - * Power off - */ + //Power off var powerOffLnk = $('Power off'); powerOffLnk.bind('click', function(event) { - var tgtNodes = getSelectLpars(); + var tgtNodes = getSelectNodes(); $.ajax( { url : 'lib/cmd.php', dataType : 'json', @@ -397,14 +394,11 @@ function createActionMenu(){ }); }); - /* - * Clone - */ + //Clone var cloneLnk = $('Clone'); cloneLnk.bind('click', function(event) { - var tgtNodes = getSelectLpars('nodesDataTable').split(','); - for ( var i = 0; i < tgtNodes.length; i++) { - var mgt = getNodeAttr(tgtNodes[i], 'mgt'); + for (var name in selectNode) { + var mgt = nodeList[name]['mgt']; // Create an instance of the plugin var plugin; @@ -429,66 +423,73 @@ function createActionMenu(){ break; } - plugin.loadClonePage(tgtNodes[i]); + plugin.loadClonePage(name); } }); - /* - * Delete - */ + //Delete var deleteLnk = $('Delete'); deleteLnk.bind('click', function(event) { + var tgtNodes = getSelectNodes(); + if (tgtNodes) { + deleteNode(tgtNodes); + } }); - /* - * Unlock - */ + //Unlock var unlockLnk = $('Unlock'); unlockLnk.bind('click', function(event) { + var tgtNodes = getSelectNodes(); + if (tgtNodes) { + loadUnlockPage(tgtNodes); + } }); - /* - * Run script - */ + //Run script var scriptLnk = $('Run script'); scriptLnk.bind('click', function(event) { + var tgtNodes = getSelectNodes(); + if (tgtNodes) { + loadScriptPage(tgtNodes); + } }); - /* - * Update node - */ + //Update node var updateLnk = $('Update'); updateLnk.bind('click', function(event) { + var tgtNodes = getSelectNodes(); + if (tgtNodes) { + loadUpdatenodePage(tgtNodes); + } }); - /* - * Set boot state - */ + //Set boot state var setBootStateLnk = $('Set boot state'); setBootStateLnk.bind('click', function(event) { + var tgtNodes = getSelectNodes(); + if (tgtNodes) { + loadNodesetPage(tgtNodes); + } }); - /* - * Boot to network - */ + //Boot to network var boot2NetworkLnk = $('Boot to network'); boot2NetworkLnk.bind('click', function(event) { + var tgtNodes = getSelectNodes(); + if (tgtNodes) { + loadNetbootPage(tgtNodes); + } }); - /* - * Open the Rcons page - */ + //Open the Rcons page var rcons = $('Open Rcons'); rcons.bind('click', function(event){ - var tgtNodes = getSelectLpars(); + var tgtNodes = getSelectNodes(); if (tgtNodes) { loadRconsPage(tgtNodes); } }); - /* - * Advanced - */ var advancedLnk = $('Advanced'); // Power actions @@ -628,20 +629,20 @@ function statusMap(status){ */ function selectAllLpars(checkbox){ var temp = checkbox.attr('checked'); - $('#selectLparTable input[type = checkbox]').attr('checked', temp); + $('#selectNodeTable input[type = checkbox]').attr('checked', temp); } /** - * export all lpars' name from selectLpar + * export all lpars' name from selectNode * * @param * @return lpars' string * */ -function getSelectLpars(){ +function getSelectNodes(){ var ret = ''; - for (var lparName in selectLpar){ + for (var lparName in selectNode){ ret += lparName + ','; } @@ -655,10 +656,10 @@ function getSelectLpars(){ * @return */ -function reselectLpars(){ +function reselectNodes(){ var temp = new Array(); - for (var lparName in selectLpar){ + for (var lparName in selectNode){ temp.push(lparName); }