insert statistics image in infobox of node

This commit is contained in:
Little.Ben 2015-05-11 22:43:11 +02:00 committed by Nils Schneider
parent 5b320bf4a8
commit cbe21ee3df
3 changed files with 71 additions and 0 deletions
lib/infobox

View file

@ -133,6 +133,37 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
return au.enabled ? "aktiviert (" + au.branch + ")" : "deaktiviert"
}
function showStatImg(o, nodeId) {
return function (el) {
var content, caption
if (o.thumbnail) {
content = document.createElement("img")
content.src = o.thumbnail.replace("{NODE_ID}", nodeId)
}
if (o.caption) {
caption = o.caption.replace("{NODE_ID}", nodeId)
if (!content)
content = document.createTextNode(caption)
}
if (o.href) {
var link = document.createElement("a")
link.target = "_blank"
link.href = o.href.replace("{NODE_ID}", nodeId)
link.appendChild(content)
if (caption && o.thumbnail)
link.title = caption
el.appendChild(link)
} else
el.appendChild(content)
}
}
return function(config, el, router, d) {
var h2 = document.createElement("h2")
h2.textContent = d.nodeinfo.hostname
@ -161,6 +192,12 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
attributeEntry(attributes, "IP Adressen", showIPs(d))
attributeEntry(attributes, "Autom. Updates", showAutoupdate(d))
attributeEntry(attributes, "Clients", showClients(d))
if (config.nodeInfos)
config.nodeInfos.forEach( function (nodeInfo) {
attributeEntry(attributes, nodeInfo.name, showStatImg(nodeInfo, d.nodeinfo.node_id))
})
el.appendChild(attributes)
if (d.neighbours.length > 0) {