From 2dc989ab631640a16ac27f405a2a5f0991c50838 Mon Sep 17 00:00:00 2001 From: Moorviper Date: Thu, 25 Feb 2016 14:44:11 +0100 Subject: [PATCH] INFOBOX - Show Load avg at sidebar Show the average load in the sidebar under a load 1.0 it is colored green above its red --- lib/infobox/node.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/lib/infobox/node.js b/lib/infobox/node.js index 98e7dff..fa34b0f 100644 --- a/lib/infobox/node.js +++ b/lib/infobox/node.js @@ -134,6 +134,40 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"], return span } + function showLoadBar(className, v) { + var span = document.createElement("span") + span.classList.add("bar") + span.classList.add(className) + + var bar = document.createElement("span") + if (v >= 1) { + bar.style.width = ((v * 100) % 100) + "%" + bar.style.background = "rgba(255, 50, 50, 0.9)" + span.style.background = "rgba(255, 50, 50, 0.6)" + span.appendChild(bar) + } + else + { + bar.style.width = (v * 100) + "%" + span.appendChild(bar) + } + + var label = document.createElement("label") + label.textContent = (v) + span.appendChild(label) + + return span + } + + function showLOAD(d) { + if (!("loadavg" in d.statistics)) + return undefined + + return function (el) { + el.appendChild(showLoadBar("load-avg", d.statistics.loadavg)) + } + } + function showRAM(d) { if (!("memory_usage" in d.statistics)) return undefined @@ -206,6 +240,7 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"], attributeEntry(attributes, "Site", showSite(d, config)) attributeEntry(attributes, "Uptime", showUptime(d)) attributeEntry(attributes, "Teil des Netzes", showFirstseen(d)) + attributeEntry(attributes, "Load - avg", showLOAD(d)) attributeEntry(attributes, "Arbeitsspeicher", showRAM(d)) attributeEntry(attributes, "IP Adressen", showIPs(d)) attributeEntry(attributes, "Gewähltes Gateway", dictGet(d.statistics, ["gateway"]))