From abdd6e7426e7e4b6fd1007a765c12705aa4e1912 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 29 Dec 2010 14:36:54 -0800 Subject: [PATCH] bug 7701: pod page - after adding host, cluster node will be added and expanded and host node will be added under cluster node. --- ui/scripts/cloud.core.pod.js | 20 ++++++++++++++++---- ui/scripts/cloud.core.resource.js | 8 ++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ui/scripts/cloud.core.pod.js b/ui/scripts/cloud.core.pod.js index 45fe4cdc7e5..540021ce04c 100644 --- a/ui/scripts/cloud.core.pod.js +++ b/ui/scripts/cloud.core.pod.js @@ -531,9 +531,7 @@ function bindAddHostButton($leftmenuItem1) { dataType: "json", success: function(json) { $thisDialog.find("#spinning_wheel").hide(); - $thisDialog.dialog("close"); - - showMiddleMenu(); + $thisDialog.dialog("close"); /* var $midmenuItem1 = $("#midmenu_item").clone(); @@ -552,7 +550,8 @@ function bindAddHostButton($leftmenuItem1) { } */ - clickClusterNodeAfterAddHost(clusterRadio, podId, newClusterName, existingClusterId, $thisDialog); + //clickClusterNodeAfterAddHost(clusterRadio, podId, newClusterName, existingClusterId, $thisDialog); + clickClusterArrowAfterAddHost(clusterRadio, podId, newClusterName, existingClusterId, $thisDialog); }, error: function(XMLHttpResponse) { handleError(XMLHttpResponse, function() { @@ -586,6 +585,19 @@ function clickClusterNodeAfterAddHost(clusterRadio, podId, newClusterName, exist } } +function clickClusterArrowAfterAddHost(clusterRadio, podId, newClusterName, existingClusterId, $thisDialog) { + if(clusterRadio == "new_cluster_radio") { //*** new cluster *** + $thisDialog.find("#new_cluster_name").val(""); + var $clusterNode = refreshClusterUnderPod($("#pod_" + podId), newClusterName, null, true); + $clusterNode.find("#cluster_arrow").click(); + } + else if(clusterRadio == "existing_cluster_radio") { //*** existing cluster *** + if (existingClusterId != null && existingClusterId != '-1') { + $("#cluster_"+existingClusterId).find("#cluster_arrow").click(); + } + } +} + function bindAddPrimaryStorageButton($leftmenuItem1) { var $button = $("#add_primarystorage_button"); $button.unbind("click").bind("click", function(event) { diff --git a/ui/scripts/cloud.core.resource.js b/ui/scripts/cloud.core.resource.js index 7155390c03d..7329515f47e 100644 --- a/ui/scripts/cloud.core.resource.js +++ b/ui/scripts/cloud.core.resource.js @@ -362,6 +362,7 @@ function refreshClusterUnderPod($podNode, newClusterName, existingClusterId, noC if(podId == null) //e.g. $podNode is not on the screen (when zone tree is hidden) ($podNode.length==0) return; + var $clusterNode; $.ajax({ data: createURL("command=listClusters&podid="+podId), dataType: "json", @@ -371,7 +372,7 @@ function refreshClusterUnderPod($podNode, newClusterName, existingClusterId, noC var container = $podNode.find("#clusters_container").empty(); if (items != null && items.length > 0) { for (var i = 0; i < items.length; i++) { - var $clusterNode = $("#leftmenu_cluster_node_template").clone(true); + $clusterNode = $("#leftmenu_cluster_node_template").clone(true); var item = items[i]; clusterJSONToTreeNode(item, $clusterNode); container.append($clusterNode.show()); @@ -383,11 +384,14 @@ function refreshClusterUnderPod($podNode, newClusterName, existingClusterId, noC $podNode.find("#pod_content").show(); if(existingClusterId != null && noClicking!=true) { - $("#cluster_"+existingClusterId).find("#cluster_name").click(); + $clusterNode = $("#cluster_"+existingClusterId); + $clusterNode.find("#cluster_name").click(); } } } }); + + return $clusterNode; } function selectRowInZoneTree($rowToSelect) {