From db6264cd4394697b9f56f973df9974427f2ac41b Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Thu, 5 May 2011 18:45:46 -0700 Subject: [PATCH] bug 6873: CloudStack UI - Enable/Disable Cluster/Pod/Zone action: only refresh allocationstate grid row and action menu after action succeeds. --- ui/scripts/cloud.core.cluster.js | 19 +++++---- ui/scripts/cloud.core.pod.js | 49 +++++++++++----------- ui/scripts/cloud.core.zone.js | 70 ++++++++++++++------------------ 3 files changed, 64 insertions(+), 74 deletions(-) diff --git a/ui/scripts/cloud.core.cluster.js b/ui/scripts/cloud.core.cluster.js index 3652fa87129..982ceea6ede 100644 --- a/ui/scripts/cloud.core.cluster.js +++ b/ui/scripts/cloud.core.cluster.js @@ -64,12 +64,6 @@ function clusterJsonToDetailsTab() { } }); - clusterJsonToDetailsTab2(jsonObj); -} - -function clusterJsonToDetailsTab2(jsonObj) { - var $midmenuItem1 = $("#right_panel_content").data("$midmenuItem1"); - var $thisTab = $("#right_panel_content").find("#tab_content_details"); $thisTab.find("#grid_header_title").text(fromdb(jsonObj.name)); $thisTab.find("#id").text(fromdb(jsonObj.id)); @@ -81,6 +75,13 @@ function clusterJsonToDetailsTab2(jsonObj) { $thisTab.find("#allocationstate").text(fromdb(jsonObj.allocationstate)); //actions *** + clusterBuildActionMenu(jsonObj); +} + +function clusterBuildActionMenu(jsonObj) { + var $midmenuItem1 = $("#right_panel_content").data("$midmenuItem1"); + var $thisTab = $("#right_panel_content").find("#tab_content_details"); + var $actionLink = $thisTab.find("#action_link"); bindActionLink($actionLink); @@ -118,7 +119,8 @@ var clusterActionMap = { inProcessText: "label.action.enable.cluster.processing", afterActionSeccessFn: function(json, $midmenuItem1, id) { var jsonObj = json.updateclusterresponse.cluster; - clusterJsonToDetailsTab2(jsonObj); + $("#right_panel_content").find("#tab_content_details").find("#allocationstate").text(fromdb(jsonObj.allocationstate)); + clusterBuildActionMenu(jsonObj); } } , @@ -128,7 +130,8 @@ var clusterActionMap = { inProcessText: "label.action.disable.cluster.processing", afterActionSeccessFn: function(json, $midmenuItem1, id) { var jsonObj = json.updateclusterresponse.cluster; - clusterJsonToDetailsTab2(jsonObj); + $("#right_panel_content").find("#tab_content_details").find("#allocationstate").text(fromdb(jsonObj.allocationstate)); + clusterBuildActionMenu(jsonObj); } } , diff --git a/ui/scripts/cloud.core.pod.js b/ui/scripts/cloud.core.pod.js index 3a302319870..4daa29b3ec8 100644 --- a/ui/scripts/cloud.core.pod.js +++ b/ui/scripts/cloud.core.pod.js @@ -116,35 +116,33 @@ function podJsonToDetailsTab() { } }); - podJsonToDetailsTab2(jsonObj); -} - -function podJsonToDetailsTab2(jsonObj) { - var $leftmenuItem1 = $("#right_panel_content").data("$leftmenuItem1"); - var $thisTab = $("#right_panel_content #tab_content_details"); $thisTab.find("#tab_container").hide(); - $thisTab.find("#tab_spinning_wheel").show(); - + $thisTab.find("#tab_spinning_wheel").show(); $thisTab.find("#id").text(fromdb(jsonObj.id)); - $thisTab.find("#grid_header_title").text(fromdb(jsonObj.name)); - + $thisTab.find("#grid_header_title").text(fromdb(jsonObj.name)); $thisTab.find("#name").text(fromdb(jsonObj.name)); - $thisTab.find("#name_edit").val(fromdb(jsonObj.name)); - + $thisTab.find("#name_edit").val(fromdb(jsonObj.name)); $thisTab.find("#netmask").text(fromdb(jsonObj.netmask)); - $thisTab.find("#netmask_edit").val(fromdb(jsonObj.netmask)); - + $thisTab.find("#netmask_edit").val(fromdb(jsonObj.netmask)); $thisTab.find("#ipRange").text(getIpRange(jsonObj.startip, jsonObj.endip)); $thisTab.find("#startIpRange_edit").val(fromdb(jsonObj.startip)); - $thisTab.find("#endIpRange_edit").val(fromdb(jsonObj.endip)); - + $thisTab.find("#endIpRange_edit").val(fromdb(jsonObj.endip)); $thisTab.find("#gateway").text(fromdb(jsonObj.gateway)); - $thisTab.find("#gateway_edit").val(fromdb(jsonObj.gateway)); - + $thisTab.find("#gateway_edit").val(fromdb(jsonObj.gateway)); $thisTab.find("#allocationstate").text(fromdb(jsonObj.allocationstate)); - - //actions *** + + //actions *** + podBuildActionMenu(jsonObj); + + $thisTab.find("#tab_spinning_wheel").hide(); + $thisTab.find("#tab_container").show(); +} + +function podBuildActionMenu(jsonObj) { + var $leftmenuItem1 = $("#right_panel_content").data("$leftmenuItem1"); + var $thisTab = $("#right_panel_content #tab_content_details"); + var $actionLink = $thisTab.find("#action_link"); bindActionLink($actionLink); @@ -157,10 +155,7 @@ function podJsonToDetailsTab2(jsonObj) { else if(jsonObj.allocationstate == "Enabled") buildActionLinkForTab("label.action.disable.pod", podActionMap, $actionMenu, $leftmenuItem1, $thisTab); - buildActionLinkForTab("label.action.delete.pod", podActionMap, $actionMenu, $leftmenuItem1, $thisTab); - - $thisTab.find("#tab_spinning_wheel").hide(); - $thisTab.find("#tab_container").show(); + buildActionLinkForTab("label.action.delete.pod", podActionMap, $actionMenu, $leftmenuItem1, $thisTab); } function podJsonToNetworkTab() { @@ -1107,7 +1102,8 @@ var podActionMap = { inProcessText: "label.action.enable.pod.processing", afterActionSeccessFn: function(json, $midmenuItem1, id) { var jsonObj = json.updatepodresponse.pod; - podJsonToDetailsTab2(jsonObj); + $("#right_panel_content").find("#tab_content_details").find("#allocationstate").text(fromdb(jsonObj.allocationstate)); + podBuildActionMenu(jsonObj); } } , @@ -1117,7 +1113,8 @@ var podActionMap = { inProcessText: "label.action.disable.pod.processing", afterActionSeccessFn: function(json, $midmenuItem1, id) { var jsonObj = json.updatepodresponse.pod; - podJsonToDetailsTab2(jsonObj); + $("#right_panel_content").find("#tab_content_details").find("#allocationstate").text(fromdb(jsonObj.allocationstate)); + podBuildActionMenu(jsonObj); } } , diff --git a/ui/scripts/cloud.core.zone.js b/ui/scripts/cloud.core.zone.js index 67443460388..30b22edc69e 100644 --- a/ui/scripts/cloud.core.zone.js +++ b/ui/scripts/cloud.core.zone.js @@ -127,40 +127,30 @@ function zoneJsonToDetailsTab() { } if(jsonObj.networktype == "Basic") - $("#tab_network, #tab_content_details #vlan_container, #guestcidraddress_container").hide(); - + $("#tab_network, #tab_content_details #vlan_container, #guestcidraddress_container").hide(); else if(jsonObj.networktype == "Advanced") $("#tab_network, #tab_content_details #vlan_container, #guestcidraddress_container").show(); - zoneJsonToDetailsTab2(jsonObj); -} - -function zoneJsonToDetailsTab2(jsonObj) { - var $leftmenuItem1 = $("#right_panel_content").data("$leftmenuItem1"); - - var $thisTab = $("#right_panel_content").find("#tab_content_details"); - $thisTab.find("#tab_container").hide(); - $thisTab.find("#tab_spinning_wheel").show(); - + $thisTab.find("#tab_container").hide(); + $thisTab.find("#tab_spinning_wheel").show(); $thisTab.find("#id").text(fromdb(jsonObj.id)); - $thisTab.find("#grid_header_title").text(fromdb(jsonObj.name)); - + $thisTab.find("#grid_header_title").text(fromdb(jsonObj.name)); $thisTab.find("#name").text(fromdb(jsonObj.name)); - $thisTab.find("#name_edit").val(fromdb(jsonObj.name)); - + $thisTab.find("#name_edit").val(fromdb(jsonObj.name)); $thisTab.find("#dns1").text(fromdb(jsonObj.dns1)); - $thisTab.find("#dns1_edit").val(fromdb(jsonObj.dns1)); - + $thisTab.find("#dns1_edit").val(fromdb(jsonObj.dns1)); $thisTab.find("#dns2").text(fromdb(jsonObj.dns2)); - $thisTab.find("#dns2_edit").val(fromdb(jsonObj.dns2)); - + $thisTab.find("#dns2_edit").val(fromdb(jsonObj.dns2)); $thisTab.find("#internaldns1").text(fromdb(jsonObj.internaldns1)); - $thisTab.find("#internaldns1_edit").val(fromdb(jsonObj.internaldns1)); - + $thisTab.find("#internaldns1_edit").val(fromdb(jsonObj.internaldns1)); $thisTab.find("#internaldns2").text(fromdb(jsonObj.internaldns2)); - $thisTab.find("#internaldns2_edit").val(fromdb(jsonObj.internaldns2)); - - $thisTab.find("#networktype").text(fromdb(jsonObj.networktype)); + $thisTab.find("#internaldns2_edit").val(fromdb(jsonObj.internaldns2)); + $thisTab.find("#networktype").text(fromdb(jsonObj.networktype)); + setBooleanReadField(jsonObj.securitygroupsenabled, $thisTab.find("#securitygroupsenabled")); + $thisTab.find("#guestcidraddress").text(fromdb(jsonObj.guestcidraddress)); + $thisTab.find("#guestcidraddress_edit").val(fromdb(jsonObj.guestcidraddress)); + $thisTab.find("#domain").text(fromdb(jsonObj.domain)); + $thisTab.find("#allocationstate").text(fromdb(jsonObj.allocationstate)); if(jsonObj.networktype == "Advanced") { var vlan = jsonObj.vlan; $thisTab.find("#vlan").text(fromdb(vlan)); @@ -176,17 +166,18 @@ function zoneJsonToDetailsTab2(jsonObj) { } } } - - setBooleanReadField(jsonObj.securitygroupsenabled, $thisTab.find("#securitygroupsenabled")); - - $thisTab.find("#guestcidraddress").text(fromdb(jsonObj.guestcidraddress)); - $thisTab.find("#guestcidraddress_edit").val(fromdb(jsonObj.guestcidraddress)); - $thisTab.find("#domain").text(fromdb(jsonObj.domain)); + //actions *** + zoneBuildActionMenu(jsonObj); - $thisTab.find("#allocationstate").text(fromdb(jsonObj.allocationstate)); - - //actions *** + $thisTab.find("#tab_spinning_wheel").hide(); + $thisTab.find("#tab_container").show(); +} + +function zoneBuildActionMenu(jsonObj) { + var $leftmenuItem1 = $("#right_panel_content").data("$leftmenuItem1"); + var $thisTab = $("#right_panel_content").find("#tab_content_details"); + var $actionLink = $thisTab.find("#action_link"); bindActionLink($actionLink); @@ -199,10 +190,7 @@ function zoneJsonToDetailsTab2(jsonObj) { else if(jsonObj.allocationstate == "Enabled") buildActionLinkForTab("label.action.disable.zone", zoneActionMap, $actionMenu, $leftmenuItem1, $thisTab); - buildActionLinkForTab("label.action.delete.zone", zoneActionMap, $actionMenu, $leftmenuItem1, $thisTab); - - $thisTab.find("#tab_spinning_wheel").hide(); - $thisTab.find("#tab_container").show(); + buildActionLinkForTab("label.action.delete.zone", zoneActionMap, $actionMenu, $leftmenuItem1, $thisTab); } function zoneClearDetailsTab() { @@ -389,7 +377,8 @@ var zoneActionMap = { inProcessText: "label.action.enable.zone.processing", afterActionSeccessFn: function(json, $leftmenuItem1, id) { var jsonObj = json.updatezoneresponse.zone; - zoneJsonToDetailsTab2(jsonObj); + $("#right_panel_content").find("#tab_content_details").find("#allocationstate").text(fromdb(jsonObj.allocationstate)); + zoneBuildActionMenu(jsonObj); } }, "label.action.disable.zone": { @@ -398,7 +387,8 @@ var zoneActionMap = { inProcessText: "label.action.disable.zone.processing", afterActionSeccessFn: function(json, $leftmenuItem1, id) { var jsonObj = json.updatezoneresponse.zone; - zoneJsonToDetailsTab2(jsonObj); + $("#right_panel_content").find("#tab_content_details").find("#allocationstate").text(fromdb(jsonObj.allocationstate)); + zoneBuildActionMenu(jsonObj); } }, "label.action.delete.zone": {