');
+ area.append(tree_area);
+ tree_area.tree({});
+}
+
+/**
+ * create the physical graphical layout
+ *
+ * @param bpa : all bpa and there related fsps
+ * fsp : all fsp and there related lpars
+ * fspinfo : all fsps' hardwareinfo
+ * area: the element to append graphical layout
+ * @return
+ */
+function createGraphical(bpa, fsp, area){
+ var usedFsp = new Object();
+ var graphField = $('');
+ graphField.append('');
+ var graphTable = $('
');
+ var elementNum = 0;
+ var row;
+ for (var bpaName in bpa){
+ if (0 == elementNum % 3){
+ row = $('
';
+ row.append(td);
+ }
+
+ graphField.append(graphTable);
+
+ var graphical_area = $('');
+ var selectLparDiv = $('');
+ var temp = 0;
+ for (var i in selectLpar){
+ temp ++;
+ break;
+ }
+
+ //there is not selected lpars, show the info bar
+ if (0 == temp){
+ selectLparDiv.append(createInfoBar('Click CEC and select lpars to do operations.'));
+ }
+ //show selected lpars
+ else{
+ updateSelectLparDiv();
+ }
+ graphical_area.append(selectLparDiv);
+ graphical_area.append(graphField);
+ area.append(graphical_area);
+
+ $('.fspDiv2, .fspDiv4, .fspDiv42').tooltip({
+ showURL: false,
+ showBody: " - ",
+ fade: 250
+ });
+
+ $('.fspDiv2, .fspDiv4, .fspDiv42').bind('click', function(){
+ var fspName = $(this).attr('value');
+ showSelectDialog(fspList[fspName]['children']);
+ });
+}
+
+/**
+ * show the fsp's information in a dialog
+ *
+ * @param fspName : fsp's name
+ *
+ * @return
+ */
+function showSelectDialog(lpars){
+ var diaDiv = $('');
+
+ if (0 == lpars.length){
+ diaDiv.append(createInfoBar('There is not any lpars defined.'));
+ }
+ else{
+ //add the dialog content
+ var selectTable = $('
');
+ selectTable.append('
Name
Status
');
+ for (var lparIndex in lpars){
+ var row = $('
');
+ var lparName = lpars[lparIndex];
+ var color = statusMap(lparList[lparName]);
+
+ if (selectLpar[lparName]){
+ row.append('
');
+ }
+ else{
+ row.append('
');
+ }
+ row.append('
' + lparName + '
');
+ row.append('
' + lparList[lparName] + '
');
+ selectTable.append(row);
+ }
+ diaDiv.append(selectTable);
+ }
+
+ diaDiv.dialog({
+ modal: true,
+ width: 400,
+ close: function(event, ui){
+ $(this).remove();
+ },
+ buttons: {
+ cancel : function(){
+ $(this).dialog('close');
+ },
+ ok : function(){
+ $('#selectLparTable input[type=checkbox]').each(function(){
+ var lparName = $(this).attr('id');
+ if ('' == lparName){
+ //continue
+ return true;
+ }
+ if (true == $(this).attr('checked')){
+ selectLpar[lparName] = 1;
+ $('#graphTable #' + lparName).css('border-color', 'aqua');
+ }
+ else{
+ delete selectLpar[lparName];
+ $('#graphTable #' + lparName).css('border-color', 'transparent');
+ }
+ });
+ updateSelectLparDiv();
+ $(this).dialog('close');
+ }
+ }
+ });
+}
+
+/**
+ * update the lpars' background in cec, lpars area and selectLpar
+ *
+ * @param
+ * @return
+ *
+ **/
+function updateSelectLparDiv(){
+ var temp = 0;
+ $('#selectLparDiv').empty();
+
+ for (var LparName in selectLpar){
+ temp ++;
+ break;
+ }
+
+ if (0 == temp){
+ $('#selectLparDiv').append(createInfoBar('Click CEC and select lpars to do operations.'));
+ return;
+ }
+
+ temp =0;
+ //add buttons
+ var tempDiv = $('');
+ tempDiv.append(createActionMenu());
+ $('#selectLparDiv').append(tempDiv);
+ $('#selectLparDiv').append(' Lpars: ');
+ for(var lparName in selectLpar){
+ $('#selectLparDiv').append(lparName + ' ');
+ temp ++;
+ if (6 < temp){
+ $('#selectLparDiv').append('...');
+ break;
+ }
+ }
+
+ var reselectButton = createButton('Reselect');
+ $('#selectLparDiv').append(reselectButton);
+ reselectButton.bind('click', function(){
+ reselectLpars();
+ });
+
+}
+
+/**
+ * create the action menu
+ *
+ * @param getNodesFunction
+ * the function that can find selected nodes name
+ * @return
+ * action menu object
+ */
+function createActionMenu(){
+ // Create action bar
+ var actionBar = $('');
+
+ /**
+ * The following actions are available to perform against a given node:
+ * power, clone, delete, unlock, and advanced
+ */
+ /*
+ * Power
+ */
+ var powerLnk = $('Power');
+
+ /*
+ * Power on
+ */
+ var powerOnLnk = $('Power on');
+ powerOnLnk.bind('click', function(event) {
+ var tgtNodes = getSelectLpars();
+ $.ajax( {
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'rpower',
+ tgt : tgtNodes,
+ args : 'on',
+ msg : ''
+ }
+ });
+ });
+
+ /*
+ * Power off
+ */
+ var powerOffLnk = $('Power off');
+ powerOffLnk.bind('click', function(event) {
+ var tgtNodes = getSelectLpars();
+ $.ajax( {
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'rpower',
+ tgt : tgtNodes,
+ args : 'off',
+ msg : ''
+ }
+ });
+ });
+
+ /*
+ * 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');
+
+ // 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(tgtNodes[i]);
+ }
+ });
+
+ /*
+ * Delete
+ */
+ var deleteLnk = $('Delete');
+ deleteLnk.bind('click', function(event) {
+ });
+
+ /*
+ * Unlock
+ */
+ var unlockLnk = $('Unlock');
+ unlockLnk.bind('click', function(event) {
+ });
+
+ /*
+ * Run script
+ */
+ var scriptLnk = $('Run script');
+ scriptLnk.bind('click', function(event) {
+ });
+
+ /*
+ * Update node
+ */
+ var updateLnk = $('Update');
+ updateLnk.bind('click', function(event) {
+ });
+
+ /*
+ * Set boot state
+ */
+ var setBootStateLnk = $('Set boot state');
+ setBootStateLnk.bind('click', function(event) {
+ });
+
+ /*
+ * Boot to network
+ */
+ var boot2NetworkLnk = $('Boot to network');
+ boot2NetworkLnk.bind('click', function(event) {
+ });
+
+ /*
+ * Open the Rcons page
+ */
+ var rcons = $('Open Rcons');
+ rcons.bind('click', function(event){
+ var tgtNodes = getSelectLpars();
+ if (tgtNodes) {
+ loadRconsPage(tgtNodes);
+ }
+ });
+
+ /*
+ * Advanced
+ */
+ var advancedLnk = $('Advanced');
+
+ // Power actions
+ var powerActions = [ powerOnLnk, powerOffLnk ];
+ var powerActionMenu = createMenu(powerActions);
+
+ // Advanced actions
+ var advancedActions;
+ advancedActions = [ boot2NetworkLnk, scriptLnk, setBootStateLnk, updateLnk, rcons ];
+ var advancedActionMenu = createMenu(advancedActions);
+
+ /**
+ * Create an action menu
+ */
+ var actionsDIV = $('');
+ var actions = [ [ powerLnk, powerActionMenu ], cloneLnk, deleteLnk, unlockLnk, [ advancedLnk, advancedActionMenu ] ];
+ var actionMenu = createMenu(actions);
+ actionMenu.superfish();
+ actionsDIV.append(actionMenu);
+ actionBar.append(actionsDIV);
+
+ return actionBar;
+}
+
+/**
+ * create the physical graphical layout
+ *
+ * @param bpaName : fsp's key
+ * fsp : all fsp and there related lpars
+ * fspinfo : all fsps' hardwareinfo
+ * @return
+ * fspDiv's html
+ */
+function createFspDiv(fspName, mtm, fsp){
+ //create fsp title
+ var title = '
' + fspName;
+ var lparStatusRow = '';
+ if (hardwareInfo[mtm]){
+ title += '(' + hardwareInfo[mtm][0] + ')';
+ }
+
+ title += '
';
+
+ for (var lparIndex in fsp[fspName]['children']){
+ var lparName = fsp[fspName]['children'][lparIndex];
+ var color = statusMap(lparList[lparName]);
+ title += lparName + ' ';
+ lparStatusRow += '
1
';
+ }
+
+ //select the backgroud
+ var divClass = '';
+ if (hardwareInfo[mtm][1]){
+ divClass += 'fspDiv' + hardwareInfo[mtm][1];
+ }
+ else{
+ divClass += 'fspDiv4';
+ }
+
+ //create return value
+ var retHtml = '
';
+ retHtml += '
' + lparStatusRow + '
';
+ return retHtml;
+}
+
+/**
+ * map the lpar's status into a color
+ *
+ * @param status : lpar's status in nodelist table
+
+ * @return
+ * corresponding color name
+ */
+function statusMap(status){
+ var color = 'gainsboro';
+
+ switch(status){
+ case 'alive':
+ case 'ready':
+ case 'pbs':
+ case 'sshd':
+ case 'booting':{
+ color = 'green';
+ }
+ break;
+ case 'noping':
+ case 'unreachable':{
+ color = 'red';
+ }
+ break;
+ case 'ping':{
+ color = 'yellow';
+ }
+ break;
+ default:
+ break;
+ }
+
+ return color;
+}
+
+/**
+ * select all lpars checkbox in the dialog
+ *
+ * @param
+
+ * @return
+ *
+ */
+function selectAllLpars(checkbox){
+ var temp = checkbox.attr('checked');
+ $('#selectLparTable input[type = checkbox]').attr('checked', temp);
+}
+
+/**
+ * export all lpars' name from selectLpar
+ *
+ * @param
+
+ * @return lpars' string
+ *
+ */
+function getSelectLpars(){
+ var ret = '';
+ for (var lparName in selectLpar){
+ ret += lparName + ',';
+ }
+
+ return ret.substring(0, ret.length-1);
+}
+
+/**
+ * show all lpars' for users to delete
+ *
+ * @param
+
+ * @return
+ */
+function reselectLpars(){
+ var temp = new Array();
+
+ for (var lparName in selectLpar){
+ temp.push(lparName);
+ }
+
+ showSelectDialog(temp);
+}
\ No newline at end of file
diff --git a/xCAT-UI/js/ui.js b/xCAT-UI/js/ui.js
index 4b0113d4e..48c1c299f 100644
--- a/xCAT-UI/js/ui.js
+++ b/xCAT-UI/js/ui.js
@@ -454,7 +454,7 @@ function initPage() {
includeJs("js/nodes/nodeset.js");
includeJs("js/nodes/rnetboot.js");
includeJs("js/nodes/updatenode.js");
-
+ includeJs("js/nodes/physical.js");
headers.eq(0).css('background-color', '#A9D0F5');
loadNodesPage();
} else if (page == 'configure.php') {