diff --git a/ui/scripts/cloud.core.js b/ui/scripts/cloud.core.js index f6494685d3e..59c8449f73c 100644 --- a/ui/scripts/cloud.core.js +++ b/ui/scripts/cloud.core.js @@ -640,6 +640,12 @@ function showMiddleMenu() { $("#middle_menu, #search_panel, #middle_menu_pagination").show(); $("#right_panel").removeClass("main_contentarea_without_midmenu").addClass("main_contentarea_with_midmenu"); } +function isMiddleMenuShown() { + if($("#middle_menu").css("display") == "none") + return false; + else + return true; +} // adding middle menu item *** function beforeAddingMidMenuItem() { diff --git a/ui/scripts/cloud.core.pod.js b/ui/scripts/cloud.core.pod.js index 36f8ea0aee6..b408a222849 100644 --- a/ui/scripts/cloud.core.pod.js +++ b/ui/scripts/cloud.core.pod.js @@ -256,7 +256,7 @@ function initAddPrimaryStorageButton($midmenuAddLink2, currentPageInRightPanel) dialogAddPool = $("#dialog_add_pool"); dialogAddPool.find("#info_container").hide(); - var zoneId, podId, clusterId; + var zoneId, podId, sourceClusterId; if(currentPageInRightPanel == "pod_page") { var podObj = $("#tab_content_details").data("jsonObj"); var podObj = $("#tab_content_details").data("jsonObj"); @@ -269,7 +269,7 @@ function initAddPrimaryStorageButton($midmenuAddLink2, currentPageInRightPanel) var hostObj = $("#tab_content_details").data("jsonObj"); zoneId = hostObj.zoneid; podId = hostObj.podid; - clusterId = hostObj.clusterid; + sourceClusterId = hostObj.clusterid; dialogAddPool.find("#zone_name").text(fromdb(hostObj.zonename)); dialogAddPool.find("#pod_name").text(fromdb(hostObj.podname)); } @@ -277,7 +277,7 @@ function initAddPrimaryStorageButton($midmenuAddLink2, currentPageInRightPanel) var primarystorageObj = $("#tab_content_details").data("jsonObj"); zoneId = primarystorageObj.zoneid; podId = primarystorageObj.podid; - clusterId = primarystorageObj.clusterid; + sourceClusterId = primarystorageObj.clusterid; dialogAddPool.find("#zone_name").text(fromdb(primarystorageObj.zonename)); dialogAddPool.find("#pod_name").text(fromdb(primarystorageObj.podname)); } @@ -290,7 +290,7 @@ function initAddPrimaryStorageButton($midmenuAddLink2, currentPageInRightPanel) var items = json.listclustersresponse.cluster; if(items != null && items.length > 0) { for(var i=0; i" + fromdb(items[i].name) + ""); else clusterSelect.append(""); @@ -360,12 +360,16 @@ function initAddPrimaryStorageButton($midmenuAddLink2, currentPageInRightPanel) success: function(json) { $thisDialog.find("#spinning_wheel").hide(); $thisDialog.dialog("close"); - - var $container = $("#midmenu_container").find("#midmenu_primarystorage_container"); - if($container.length == 0) { //not on cluster node (still on pod node) - $("#cluster_"+clusterId).find("#cluster_name").click(); + + if(isMiddleMenuShown() == false) { //not on cluster node (still on pod node, so middle menu is hidden) + var $clusterNode = $("#cluster_"+clusterId); + if($clusterNode.length > 0) + $("#cluster_"+clusterId).find("#cluster_name").click(); + else //pod node is close. Expand pod node. + refreshClusterUnderPod($("#pod_" + podId), null, clusterId); } else { + var $container = $("#midmenu_container").find("#midmenu_primarystorage_container"); var $noItemsAvailable = $container.siblings("#midmenu_container_no_items_available"); if($noItemsAvailable.length > 0) { $noItemsAvailable.slideUp("slow", function() { diff --git a/ui/scripts/cloud.core.resource.js b/ui/scripts/cloud.core.resource.js index 56f720ba932..730c316d41e 100644 --- a/ui/scripts/cloud.core.resource.js +++ b/ui/scripts/cloud.core.resource.js @@ -155,7 +155,7 @@ function buildZoneTree() { }); } -function refreshClusterUnderPod($podNode, newClusterName) { +function refreshClusterUnderPod($podNode, newClusterName, existingClusterId) { var podId = $podNode.data("podId"); $.ajax({ data: createURL("command=listClusters&podid="+podId+maxPageSize), @@ -173,10 +173,14 @@ function refreshClusterUnderPod($podNode, newClusterName) { if(newClusterName != null && fromdb(item.name) == newClusterName) { $clusterNode.find("#cluster_name").click(); - } + } } $podNode.find("#pod_arrow").removeClass("white_nonexpanded_close").addClass("expanded_open"); - $podNode.find("#pod_content").show(); + $podNode.find("#pod_content").show(); + + if(existingClusterId != null) { + $("#cluster_"+existingClusterId).find("#cluster_name").click(); + } } } });