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.

This commit is contained in:
Jessica Wang 2012-02-07 16:37:16 -08:00
parent 4a0a2fbf8e
commit 107ae09acb

View File

@ -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: {