From 4b8b14923790534c5f8c721ff85c46f89faa2f19 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Mon, 1 Nov 2010 19:21:16 -0700 Subject: [PATCH] new UI - cluster page - show host header and primary storage header in middle menu even there is no host or no primary storage. --- ui/new/scripts/cloud.core2.cluster.js | 31 +++++++++++++-------------- ui/new/scripts/cloud.core2.js | 8 +++++-- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/ui/new/scripts/cloud.core2.cluster.js b/ui/new/scripts/cloud.core2.cluster.js index 18e8f15eeed..5ec471b4320 100644 --- a/ui/new/scripts/cloud.core2.cluster.js +++ b/ui/new/scripts/cloud.core2.cluster.js @@ -23,24 +23,23 @@ function afterLoadClusterJSP($midmenuItem1) { $("#midmenu_add2_link").unbind("click").hide(); $("#midmenu_add3_link").unbind("click").hide(); - clusterJsonToRightPanel($midmenuItem1); - - var clusterId = $midmenuItem1.data("jsonObj").id; - - var $midmenuContainer = $("#midmenu_container").empty(); - var $header1 = $("#midmenu_itemheader_without_margin").clone(); //without margin on top + clusterJsonToRightPanel($midmenuItem1); + var clusterId = $midmenuItem1.data("jsonObj").id; + var $midmenuContainer = $("#midmenu_container").empty(); + + var $container_host = $("
"); + $midmenuContainer.append($container_host); + var $header1 = $("#midmenu_itemheader_without_margin").clone().show(); //without margin on top $header1.find("#name").text("Host"); - $midmenuContainer.append($header1); - var count1 = listMidMenuItems2(("listHosts&type=Routing&clusterid="+clusterId), "listhostsresponse", "host", hostToMidmenu, hostToRightPanel, hostGetMidmenuId, false, true); - if(count1 > 0) - $header1.show(); - - var $header2 = $("#midmenu_itemheader_with_margin").clone(); //with margin on top + $container_host.append($header1); + listMidMenuItems2(("listHosts&type=Routing&clusterid="+clusterId), "listhostsresponse", "host", hostToMidmenu, hostToRightPanel, hostGetMidmenuId, false, true, $container_host); + + var $container_primarystorage = $("
"); + $midmenuContainer.append($container_primarystorage); + var $header2 = $("#midmenu_itemheader_with_margin").clone().show(); //with margin on top $header2.find("#name").text("Primary Storage"); - $midmenuContainer.append($header2); - var count2 = listMidMenuItems2(("listStoragePools&clusterid="+clusterId), "liststoragepoolsresponse", "storagepool", primarystorageToMidmenu, primarystorageToRightPanel, primarystorageGetMidmenuId, false, false); - if(count2 > 0) - $header2.show(); + $container_primarystorage.append($header2); + listMidMenuItems2(("listStoragePools&clusterid="+clusterId), "liststoragepoolsresponse", "storagepool", primarystorageToMidmenu, primarystorageToRightPanel, primarystorageGetMidmenuId, false, false, $container_primarystorage); } function clusterJsonToRightPanel($leftmenuItem1) { diff --git a/ui/new/scripts/cloud.core2.js b/ui/new/scripts/cloud.core2.js index 37b136da073..f6494685d3e 100644 --- a/ui/new/scripts/cloud.core2.js +++ b/ui/new/scripts/cloud.core2.js @@ -904,7 +904,7 @@ function getMidmenuId(jsonObj) { return "midmenuItem_" + jsonObj.id; } -function listMidMenuItems2(commandString, jsonResponse1, jsonResponse2, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu, clickFirstItem) { +function listMidMenuItems2(commandString, jsonResponse1, jsonResponse2, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu, clickFirstItem, $midMenuContainer) { if(isMultipleSelectionInMidMenu == true) enableMultipleSelectionInMidMenu(); else @@ -925,7 +925,11 @@ function listMidMenuItems2(commandString, jsonResponse1, jsonResponse2, toMidmen $midmenuItem1.data("toRightPanelFn", toRightPanelFn); toMidmenuFn(items[i], $midmenuItem1); bindClickToMidMenu($midmenuItem1, toRightPanelFn, getMidmenuIdFn); - $("#midmenu_container").append($midmenuItem1.show()); + + if($midMenuContainer == null) + $midMenuContainer = $("#midmenu_container"); + + $midMenuContainer.append($midmenuItem1.show()); if(clickFirstItem == true && i == 0) { //click the 1st item in middle menu as default $midmenuItem1.click(); if(isMultipleSelectionInMidMenu == true) {