diff --git a/ui/scripts/network.js b/ui/scripts/network.js index b56dd9b0e88..23c0e5a2b29 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -284,9 +284,56 @@ path: 'network.ipAddresses', label: 'IP addresses', preFilter: function(args) { - if (args.context.networks[0].state == 'Destroyed') return false; - - return true; + if (args.context.networks[0].state == 'Destroyed') + return false; + + var services = args.context.networks[0].service; + if(services == null) + return false; + + if(args.context.networks[0].type == "Isolated") { + for(var i=0; i < services.length; i++) { + var service = services[i]; + if(service.name == "SourceNat") { + return true; + } + } + } + else if(args.context.networks[0].type == "Shared") { + var havingSecurityGroupService = false; + var havingElasticIpCapability = false; + var havingElasticLbCapability = false; + + for(var i=0; i < services.length; i++) { + var service = services[i]; + if(service.name == "SecurityGroup") { + havingSecurityGroupService = true; + } + else if(service.name == "StaticNat") { + $(service.capability).each(function(){ + if(this.name == "ElasticIp" && this.value == "true") { + havingElasticIpCapability = true; + return false; //break $.each() loop + } + }); + } + else if(service.name == "Lb") { + $(service.capability).each(function(){ + if(this.name == "ElasticLb" && this.value == "true") { + havingElasticLbCapability = true; + return false; //break $.each() loop + } + }); + } + } + + if(havingSecurityGroupService == true && havingElasticIpCapability == true && havingElasticLbCapability == true) + return true; + else + return false; + } + + return false; } }, actions: {