Link size fix
diff --git a/views/ngXosViews/mcordTopology/src/js/main.js b/views/ngXosViews/mcordTopology/src/js/main.js
index 4b66991..a3a534c 100644
--- a/views/ngXosViews/mcordTopology/src/js/main.js
+++ b/views/ngXosViews/mcordTopology/src/js/main.js
@@ -42,6 +42,7 @@
let links = [];
let traffic = 0;
let linkWidth = 1;
+ let trafficCorrection = 5;
const filterBBU = (instances) => {
return lodash.filter(instances, i => i.name.indexOf('BBU') >= 0);
@@ -62,16 +63,36 @@
links = TopologyElements.links;
Traffic.get()
- .then((_traffic) => {
- let delta = (_traffic - traffic);
- traffic = _traffic
- linkWidth = _traffic / (delta || traffic);
+ .then((newTraffic) => {
- if(linkWidth < 1){
- linkWidth = 1;
+ // calculating link size
+ // it should change between 1 and 10
+ if(!traffic){
+ linkWidth = 2;
+ }
+ else if(newTraffic === traffic){
+ linkWidth = linkWidth;
+ }
+ else{
+ let delta = newTraffic - traffic;
+
+ if(delta > 0){
+ linkWidth = linkWidth + (delta / trafficCorrection);
+ }
+ else{
+ linkWidth = linkWidth - ((delta * -1) / trafficCorrection);
+ }
+
+ console.log(`previous traffic: ${traffic}`, `current traffic: ${newTraffic}`, `linkWidth: ${linkWidth}`);
+ console.log('************************');
}
- console.log(`traffic: ${_traffic}`, `linkWidth: ${linkWidth}`);
+ if(linkWidth < 0.2){
+ linkWidth = 0.2
+ };
+
+ traffic = newTraffic;
+
return XosApi.Instance_List_GET()
})
.then((instances) => {
diff --git a/xos/core/xoslib/static/js/xosMcordTopology.js b/xos/core/xoslib/static/js/xosMcordTopology.js
index d6b2afc..ee82e51 100644
--- a/xos/core/xoslib/static/js/xosMcordTopology.js
+++ b/xos/core/xoslib/static/js/xosMcordTopology.js
@@ -31,6 +31,7 @@
var links = [];
var traffic = 0;
var linkWidth = 1;
+ var trafficCorrection = 5;
var filterBBU = function filterBBU(instances) {
return lodash.filter(instances, function (i) {
@@ -50,16 +51,33 @@
nodes = TopologyElements.nodes;
links = TopologyElements.links;
- Traffic.get().then(function (_traffic) {
- var delta = _traffic - traffic;
- traffic = _traffic;
- linkWidth = _traffic / (delta || traffic);
+ Traffic.get().then(function (newTraffic) {
- if (linkWidth < 1) {
- linkWidth = 1;
+ // calculating link size
+ // it should change between 1 and 10
+ if (!traffic) {
+ linkWidth = 2;
+ } else if (newTraffic === traffic) {
+ linkWidth = linkWidth;
+ } else {
+ var delta = newTraffic - traffic;
+
+ if (delta > 0) {
+ linkWidth = linkWidth + delta / trafficCorrection;
+ } else {
+ linkWidth = linkWidth - delta * -1 / trafficCorrection;
+ }
+
+ console.log('previous traffic: ' + traffic, 'current traffic: ' + newTraffic, 'linkWidth: ' + linkWidth);
+ console.log('************************');
}
- console.log('traffic: ' + _traffic, 'linkWidth: ' + linkWidth);
+ if (linkWidth < 0.2) {
+ linkWidth = 0.2;
+ };
+
+ traffic = newTraffic;
+
return XosApi.Instance_List_GET();
}).then(function (instances) {
addBbuNodes(filterBBU(instances));