From 3dcb90eaf58ce9c32532ae5524abf70100d34daa Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Fri, 27 May 2016 19:51:59 +0200 Subject: front: Tweak/fix ping scores Specially bad was the foo == bar == undef thing which broke completely. Also, this makes sure that we don't cap out at 200 if the ping reply is 1000ms... --- web/js/nms-map-handlers.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'web/js') diff --git a/web/js/nms-map-handlers.js b/web/js/nms-map-handlers.js index daafff3..21f2bb2 100644 --- a/web/js/nms-map-handlers.js +++ b/web/js/nms-map-handlers.js @@ -332,12 +332,16 @@ function pingInfo(sw) try { var v4 = nmsData.ping.switches[sw].latency4; var v6 = nmsData.ping.switches[sw].latency6; + if (v4 == undefined) + v4 = undefined; + if (v6 == undefined) + v6 = undefined; ret.data[0].value = v4; ret.data[0].description = "IPv4 latency(ms)"; ret.data[1] = {}; ret.data[1].value = v6; ret.data[1].description = "IPv6 latency(ms)"; - if (v4 == v6 == undefined) { + if (v4 == undefined && v6 == undefined) { ret.score = 1000; ret.why = "No IPv4 or IPv6 ping reply"; } else if(v6 == undefined) { @@ -346,10 +350,13 @@ function pingInfo(sw) } else if (v4 == undefined) { ret.score = 199; ret.why = "No IPv4 ping reply"; - } else { - v4 = parseInt(v4); - v6 = parseInt(v6); - ret.score = (v4 > v6 ? v4 : v6) * 10; + } + + v4 = parseFloat(v4) * 10; + v6 = parseFloat(v6) * 10; + if (v4 > ret.score || v6 > ret.score) { + ret.why = "Latency"; + ret.score = parseInt(v4 > v6 ? v4 : v6); } if (nmsData.ping.switches[sw].age4 > 5 || nmsData.ping.switches[sw].age6 > 5) { ret.why = "Old ping"; -- cgit v1.2.3