Network Topology graph "twitches"
the graph is redrawn which causes visual glitching. Depending on the graph complexity. my patch resolved this issue so I compare between previous data and received data, if that changed it will redrawn, otherwise it keeps running. Change-Id: I813dfb329f46cda9afacce89c9a8b84eb2827115 Closes-Bug: #1716834
This commit is contained in:
parent
7f3fc39602
commit
e5dae9b353
@ -20,6 +20,59 @@ horizon.networktopologycommon = {
|
||||
}
|
||||
};
|
||||
|
||||
function isEqual(data1, data2) {
|
||||
var list1=[],list2=[];
|
||||
function compare2Objects (data1, data2) {
|
||||
var item;
|
||||
|
||||
if (isNaN(data1) && isNaN(data2) && typeof data1 === 'number' && typeof data2 === 'number') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Compare primitives and functions.
|
||||
// Check if both arguments link to the same object.
|
||||
// Especially useful on the step where we compare prototypes
|
||||
if (data1 === data2) {
|
||||
return true;
|
||||
}
|
||||
for (item in data1) {
|
||||
if (data2.hasOwnProperty(item) !== data1.hasOwnProperty(item)) {
|
||||
return false;
|
||||
}
|
||||
else if (typeof data2[item] !== typeof data1[item]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (typeof (data1[item])) {
|
||||
case 'object':
|
||||
if (!compare2Objects (data1[item], data2[item])) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (data1[item] !== data2[item]) {
|
||||
list1.push(data1[item]);
|
||||
list2.push(data2[item]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if(!compare2Objects(data1, data2)){
|
||||
return false;
|
||||
}else{
|
||||
list1 = list1.sort();
|
||||
list2 = list2.sort();
|
||||
for(var i in list1){
|
||||
if(list2[i]!=list1[i])
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Common data loader for network topology views
|
||||
*/
|
||||
@ -30,7 +83,7 @@ horizon.networktopologyloader = {
|
||||
reload_duration: 10000,
|
||||
// timer controlling update intervals
|
||||
update_timer: null,
|
||||
|
||||
previous_data : {},
|
||||
init:function() {
|
||||
var self = this;
|
||||
if($('#networktopology').length === 0) {
|
||||
@ -48,9 +101,12 @@ horizon.networktopologyloader = {
|
||||
angular.element('#networktopology').data('networktopology') + '?' + angular.element.now(),
|
||||
function(data) {
|
||||
self.model = data;
|
||||
$('#networktopology').trigger('change');
|
||||
if(!isEqual(data,self.previous_data)) {
|
||||
angular.copy(data, self.previous_data);
|
||||
$('#networktopology').trigger('change');
|
||||
}
|
||||
self.update_timer = setTimeout(function(){
|
||||
self.update();
|
||||
self.update();
|
||||
}, self.reload_duration);
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user