Skip to content

Commit

Permalink
Closes-Bug: #1456145 - Security Groups - Address dropdown - limiting …
Browse files Browse the repository at this point in the history
…the data

loaded to 200 and providing the option for the user to search. This way the
performance of the dropdown is improved.
Also, fixed the same policy page for Soure and Destination fields.

Change-Id: I14350bcaba25c73754f91fe140c959d428bb84e5
  • Loading branch information
manojgn committed May 27, 2015
1 parent de8b00c commit 83f3b32
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 36 deletions.
24 changes: 12 additions & 12 deletions webroot/config/networkpolicies/ui/js/policy_config.js
Expand Up @@ -1443,19 +1443,19 @@ function select2Query(query) {
}
data.results.push(this.data[i]);
}
addNewTermDataSource(grpName, query.term, data.results);
var pageSize =200;
var typeNo = 2;
if(grpName == "Networks") {children = data.results[2]['children']; typeNo = 2;}
else if(grpName == "CIDR") {children = data.results[1]['children'];typeNo = 1;}
else if(grpName == "Policies") {children = data.results[3]['children'];typeNo = 3;}
var more = false;
if (data.results[typeNo]['children'].length >= query.page*pageSize) {
more = true;
if(query.term != '') {
addNewTermDataSource(grpName, query.term, data.results);
}
data.results[typeNo]['children'] = data.results[typeNo]['children'].slice((query.page-1)*pageSize, query.page*pageSize);
if (more) {
data.results[typeNo]['children'].push({id:"search" + typeNo, text:"Search to find more entries", disabled : true})
var pageSize = 200;
for(var i=1 ; i < data.results.length ; i++){
var more = false;
if (data.results[i]['children'].length >= query.page*pageSize) {
more = true;
}
data.results[i]['children'] = data.results[i]['children'].slice((query.page-1) * pageSize, query.page * pageSize);
if (more) {
data.results[i]['children'].push({id:"search" + i, text:"Search to find more entries", disabled : true})
}
}
} else {
process = function(datum, collection) {
Expand Down
62 changes: 38 additions & 24 deletions webroot/config/securitygroup/ui/js/sg_config.js
Expand Up @@ -884,32 +884,11 @@ function setFocusSelectedItem(grpName, term, data) {
function select2Query(query) {
//using predefined process method to make work select2 selection
var t = query.term,filtered = { results: [] }, process;
process = function(datum, collection) {
var group, attr;
datum = datum[0];
if (datum.children) {
group = {};
for (attr in datum) {
if (datum.hasOwnProperty(attr)) group[attr]=datum[attr];
}
group.children=[];
$(datum.children).each2(function(i, childDatum) { process(childDatum, group.children); });
if (group.children.length || query.matcher(t, '', datum)) {
collection.push(group);
}
} else {
if (query.matcher(t, '', datum)) {
collection.push(datum);
}
}
};
if(t != ""){
$(dsSrcDest).each2(function(i, datum) { process(datum, filtered.results); })
}


var data = {results: []};
var grpName = getSelectedGroupName();
if(query.term != undefined && query.term != "") {
if(query.term != undefined) {
data.results.push({ id : query.term, text : query.term, parent : grpName});
this.data = [];
$.extend(true, this.data, dsSrcDest);
Expand All @@ -924,8 +903,43 @@ function select2Query(query) {
}
data.results.push(this.data[i]);
}
addNewTermDataSource(grpName, query.term, data.results);
if(query.term != '') {
addNewTermDataSource(grpName, query.term, data.results);
}
var pageSize = 200;
for(var i=1 ; i < data.results.length ; i++){
var more = false;
if (data.results[i]['children'].length >= query.page*pageSize) {
more = true;
}
data.results[i]['children'] = data.results[i]['children'].slice((query.page-1) * pageSize, query.page * pageSize);
if (more) {
data.results[i]['children'].push({id:"search" + i, text:"Search to find more entries", disabled : true})
}
}
} else{
process = function(datum, collection) {
var group, attr;
datum = datum[0];
if (datum.children) {
group = {};
for (attr in datum) {
if (datum.hasOwnProperty(attr)) group[attr]=datum[attr];
}
group.children=[];
$(datum.children).each2(function(i, childDatum) { process(childDatum, group.children); });
if (group.children.length || query.matcher(t, '', datum)) {
collection.push(group);
}
} else {
if (query.matcher(t, '', datum)) {
collection.push(datum);
}
}
};
if(t != ""){
$(dsSrcDest).each2(function(i, datum) { process(datum, filtered.results); })
}
data.results = dsSrcDest;
}
query.callback(data);
Expand Down

0 comments on commit 83f3b32

Please sign in to comment.