Skip to content

Commit 8db10be

Browse files
committed
Merge pull request apache#897 from nitin-maharana/CloudStack-Nitin10
CLOUDSTACK-8919: Slow UI response while loading the list of networks in network tab.Instead of searching for each network, now it is searching for each zone. For basic zone, it will show the security group directly because by default securitygroupsenabled is true. For advanced zone, check the securitygroupsenabled option in each zone. If any one has value true, then show. * pr/897: CLOUDSTACK-8919: Slow UI response while loading the list of networks in network tab. Signed-off-by: Remi Bergsma <github@remi.nl>
2 parents 0b4cc5d + e8c4b2b commit 8db10be

1 file changed

Lines changed: 28 additions & 15 deletions

File tree

‎ui/scripts/network.js‎

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -376,37 +376,50 @@
376376
sectionSelect: {
377377
preFilter: function(args) {
378378
var sectionsToShow = ['networks'];
379+
var securityGroupsEnabledFound = false; //Until we found a zone where securitygroupsenabled is true.
379380

381+
//This call to show VPC and VPN Customer Gateway sections, if zone is advanced.
380382
$.ajax({
381383
url: createURL('listZones'),
382384
data: {
383385
networktype: 'Advanced'
384386
},
385387
async: false,
386388
success: function(json) {
387-
advZoneObjs = json.listzonesresponse.zone;
389+
advZoneObjs = json.listzonesresponse ? json.listzonesresponse.zone : null;
388390
if (advZoneObjs != null && advZoneObjs.length > 0) {
389391
sectionsToShow.push('vpc');
390392
sectionsToShow.push('vpnCustomerGateway');
393+
394+
//At the same time check if any advanced zone has securitygroupsenabled is true.
395+
//If so, show Security Group section.
396+
for (var i = 0; (i < advZoneObjs.length) && !securityGroupsEnabledFound; i++) {
397+
if (advZoneObjs[i].securitygroupsenabled) {
398+
securityGroupsEnabledFound = true;
399+
sectionsToShow.push('securityGroups');
400+
}
401+
}
391402
}
392403
}
393404
});
394405

395-
$.ajax({
396-
url: createURL('listNetworks', {
397-
ignoreProject: true
398-
}),
399-
data: {
400-
supportedServices: 'SecurityGroup',
401-
listAll: true
402-
},
403-
async: false,
404-
success: function(json) {
405-
if (json.listnetworksresponse.network != null && json.listnetworksresponse.network.length > 0) {
406-
sectionsToShow.push('securityGroups');
406+
//If we didn't find any advanced zone whose securitygroupsenabled is true.
407+
//Search in all Basic zones.
408+
if (!securityGroupsEnabledFound) {
409+
$.ajax({
410+
url: createURL('listZones'),
411+
data: {
412+
networktype: 'Basic'
413+
},
414+
async: false,
415+
success: function(json) {
416+
var basicZoneObjs = json.listzonesresponse ? json.listzonesresponse.zone : null;
417+
if (basicZoneObjs != null && basicZoneObjs.length > 0) {
418+
sectionsToShow.push('securityGroups');
419+
}
407420
}
408-
}
409-
});
421+
});
422+
}
410423

411424
return sectionsToShow;
412425
},

0 commit comments

Comments
 (0)