From 107ae09acb7cac218ea081a9dbe676c02494e96c Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 7 Feb 2012 16:37:16 -0800 Subject: [PATCH] cloudstack 3.0 new UI - Instance detail page - show/hide Security Group tab upon zone's networktype and guest network's including SecurityGroup service or not. --- ui/scripts/instances.js | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index cabce11f21d..a99fb3c4e93 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -738,9 +738,42 @@ name: 'Instance details', viewAll: { path: 'storage.volumes', label: 'Volumes' }, tabFilter: function(args) { - var hiddenTabs = []; - if(g_directAttachSecurityGroupsEnabled != "true") - hiddenTabs.push("securityGroups"); + var hiddenTabs = []; + var zoneNetworktype; + $.ajax({ + url: createURL("listZones&id=" + args.context.instances[0].zoneid), + dataType: "json", + async: false, + success: function(json) { + zoneNetworktype = json.listzonesresponse.zone[0].networktype; + } + }); + if(zoneNetworktype == "Basic") { //Basic zone has only one guest network (only one NIC) + var includingSecurityGroupService = false; + $.ajax({ + url: createURL("listNetworks&id=" + args.context.instances[0].nic[0].networkid), + dataType: "json", + async: false, + success: function(json) { + var items = json.listnetworksresponse.network; + if(items != null && items.length > 0) { + var networkObj = items[0]; //basic zone has only one guest network + var serviceObjArray = networkObj.service; + for(var k = 0; k < serviceObjArray.length; k++) { + if(serviceObjArray[k].name == "SecurityGroup") { + includingSecurityGroupService = true; + break; + } + } + } + } + }); + if(includingSecurityGroupService == false) + hiddenTabs.push("securityGroups"); + } + else { //Advanced zone + hiddenTabs.push("securityGroups"); + } return hiddenTabs; }, actions: {