aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/js/nms-map-handlers.js
diff options
context:
space:
mode:
authorKristian Lyngstol <kly@kly.no>2016-03-16 19:31:48 +0000
committerKristian Lyngstol <kly@kly.no>2016-03-16 19:31:48 +0000
commit314bc052854aabb44dd9272ddd82176be5c469d5 (patch)
treef24943727a66aa32cb231830cd5f1f214d12ceb5 /web/nms.gathering.org/js/nms-map-handlers.js
parent77525f31852c93f7e336b0172a9f87674941fd09 (diff)
NMS: Implement improved ping map
e69-2 is looking good. Now with a separate age-entity. Not really used for anything fancy right now, but could be.
Diffstat (limited to 'web/nms.gathering.org/js/nms-map-handlers.js')
-rw-r--r--web/nms.gathering.org/js/nms-map-handlers.js31
1 files changed, 14 insertions, 17 deletions
diff --git a/web/nms.gathering.org/js/nms-map-handlers.js b/web/nms.gathering.org/js/nms-map-handlers.js
index 0126c38..e6b9103 100644
--- a/web/nms.gathering.org/js/nms-map-handlers.js
+++ b/web/nms.gathering.org/js/nms-map-handlers.js
@@ -162,9 +162,6 @@ function trafficUpdater()
}
}
-/*
- * Init-function for uplink map
- */
function trafficTotInit()
{
var m = 1024 * 1024 / 8;
@@ -250,23 +247,20 @@ function tempInit()
function pingUpdater()
{
- if (!nms.ping_data || !nms.ping_data["switches"]) {
+ if (nmsData.switches == undefined || nmsData.switches.switches == undefined) {
return;
}
- for (var sw in nms.switches_now["switches"]) {
- var c = blue;
- if (nms.ping_data['switches'] && nms.ping_data['switches'][sw])
- c = gradient_from_latency(nms.ping_data["switches"][sw]["latency"]);
- setSwitchColor(sw, c);
- }
- for (var ln in nms.switches_now["linknets"]) {
- var c1 = blue;
- var c2 = c1;
- if (nms.ping_data['linknets'] && nms.ping_data['linknets'][ln]) {
- c1 = gradient_from_latency(nms.ping_data["linknets"][ln][0]);
- c2 = gradient_from_latency(nms.ping_data["linknets"][ln][1]);
+ for (var sw in nmsData.switches.switches) {
+ try {
+ if (nmsData.ping.switches[sw].age > 0) {
+ c = red;
+ } else {
+ c = gradient_from_latency(nmsData.ping.switches[sw].latency);
+ }
+ nmsMap.setSwitchColor(sw, c);
+ } catch (e) {
+ nmsMap.setSwitchColor(sw, blue);
}
- setLinknetColors(ln, c1, c2);
}
}
@@ -278,6 +272,9 @@ function pingInit()
setLegend(3,gradient_from_latency(60),"60ms");
setLegend(4,gradient_from_latency(100),"100ms");
setLegend(5,gradient_from_latency(undefined) ,"No response");
+ nmsData.addHandler("ping","mapHandler",pingUpdater);
+ nmsData.addHandler("switches","mapHandler",pingUpdater);
+ nmsData.addHandler("ticker", "mapHandler", pingUpdater);
}
function commentUpdater()