Skip to content

Commit

Permalink
Merge "Closes-Bug: #1466902 Issue is Searching through results in sel…
Browse files Browse the repository at this point in the history
…ect2 dropdown is slow in the following pages: 1. [Add/Edit popup] "Source" & "Destination" column dropdowns in "Configure > Networking > Policies" page 2. [Add/Edit popup] "Address" column dropdown in "Configure > Networking > Security Groups" page Found the issue is that $.extend is taking lot of time. So, tweaked the logic to not to use $.extend" into R2.20
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jun 19, 2015
2 parents db83e1c + d26f513 commit a2c1982
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
20 changes: 11 additions & 9 deletions webroot/config/networkpolicies/ui/js/policy_config.js
Expand Up @@ -1431,17 +1431,19 @@ function select2Query(query) {
if(query.term != undefined) {
data.results.push({ id : query.term, text : query.term, parent : grpName});
this.data = [];
$.extend(true, this.data, dsSrcDest);
for(var i = 0; i < this.data.length;i++) {
var children = [] ;
$.extend(true, children, this.data[i].children);;
var filteredResults = [];
for(var i = 0; i < dsSrcDest.length;i++) {
var children = dsSrcDest[i]['children'];
filteredResults[i] = {
text: dsSrcDest[i]['text'],
children: []
};
for(var j = 0; j < children.length; j++) {
if(children[j].text.indexOf(query.term) == -1 && children[j].disabled != true) {
var newIndex = getIndexOf(this.data[i].children, children[j].value);
this.data[i].children.splice(newIndex, 1);
}
if(children[j].text.indexOf(query.term) != -1 || children[j].disabled == true) {
filteredResults[i].children.push(dsSrcDest[i].children[j]);
}
}
data.results.push(this.data[i]);
data.results.push(filteredResults[i]);
}
if(query.term != '') {
addNewTermDataSource(grpName, query.term, data.results);
Expand Down
18 changes: 10 additions & 8 deletions webroot/config/securitygroup/ui/js/sg_config.js
Expand Up @@ -891,17 +891,19 @@ function select2Query(query) {
if(query.term != undefined) {
data.results.push({ id : query.term, text : query.term, parent : grpName});
this.data = [];
$.extend(true, this.data, dsSrcDest);
for(var i = 0; i < this.data.length;i++) {
var children = [] ;
$.extend(true, children, this.data[i].children);;
var filteredResults = [];
for(var i = 0; i < dsSrcDest.length;i++) {
var children = dsSrcDest[i]['children'];
filteredResults[i] = {
text: dsSrcDest[i]['text'],
children: []
};
for(var j = 0; j < children.length; j++) {
if(children[j].text.indexOf(query.term) == -1 && children[j].disabled != true) {
var newIndex = getIndexOf(this.data[i].children, children[j].value);
this.data[i].children.splice(newIndex, 1);
if(children[j].text.indexOf(query.term) != -1 || children[j].disabled == true) {
filteredResults[i].children.push(dsSrcDest[i].children[j]);
}
}
data.results.push(this.data[i]);
data.results.push(filteredResults[i]);
}
if(query.term != '') {
addNewTermDataSource(grpName, query.term, data.results);
Expand Down

0 comments on commit a2c1982

Please sign in to comment.