infobox/link: linkinfos {SOURCE_NAME} and {TARGET_NAME} support (#82)

This commit is contained in:
kb-light 2017-02-11 01:21:20 +01:00 committed by PetaByteBoy // Milan Pässler
parent 5f98da2717
commit a7756c44e8

View file

@ -1,8 +1,10 @@
define(function () { define(function () {
function showStatImg(o, source, target) { function showStatImg(o, d) {
var subst = {} var subst = {}
subst["{SOURCE}"] = source subst["{SOURCE}"] = d.source.node_id
subst["{TARGET}"] = target subst["{SOURCE_NAME}"] = d.source.node.nodeinfo.hostname ? d.source.node.nodeinfo.hostname : "unknown"
subst["{TARGET}"] = d.target.node_id
subst["{TARGET_NAME}"] = d.target.node.nodeinfo.hostname ? d.target.node.nodeinfo.hostname : "unknown"
return showStat(o, subst) return showStat(o, subst)
} }
@ -35,15 +37,12 @@ define(function () {
attributeEntry(attributes, "Hardware", (hw1 != null ? hw1 : "unbekannt") + " " + (hw2 != null ? hw2 : "unbekannt")) attributeEntry(attributes, "Hardware", (hw1 != null ? hw1 : "unbekannt") + " " + (hw2 != null ? hw2 : "unbekannt"))
el.appendChild(attributes) el.appendChild(attributes)
if (config.linkInfos) { if (config.linkInfos)
var source = d.source.node_id
var target = d.target.node_id
config.linkInfos.forEach( function (linkInfo) { config.linkInfos.forEach( function (linkInfo) {
var h4 = document.createElement("h4") var h4 = document.createElement("h4")
h4.textContent = linkInfo.name h4.textContent = linkInfo.name
el.appendChild(h4) el.appendChild(h4)
el.appendChild(showStatImg(linkInfo, source, target)) el.appendChild(showStatImg(linkInfo, d))
}) })
}
} }
}) })