Merge branch 'master' into prometheus-charts
This commit is contained in:
commit
e685fe385f
16
README.md
16
README.md
|
@ -84,6 +84,22 @@ property and optionally `url` and `config` properties. If no `url` is supplied
|
||||||
`name` is assumed to name a
|
`name` is assumed to name a
|
||||||
[Leaflet-provider](http://leaflet-extras.github.io/leaflet-providers/preview/).
|
[Leaflet-provider](http://leaflet-extras.github.io/leaflet-providers/preview/).
|
||||||
|
|
||||||
|
## fixedCenter (array, optional)
|
||||||
|
|
||||||
|
This option allows to fix the map at one specific coordinate depending on following case-sensitive parameters:
|
||||||
|
|
||||||
|
- `lat` latitude of the center point
|
||||||
|
- `lng` longitude of the center point
|
||||||
|
- `radius` visible radius around the center in km
|
||||||
|
|
||||||
|
Examples for `fixedCenter`:
|
||||||
|
|
||||||
|
"fixedCenter": {
|
||||||
|
"lat": 50.80,
|
||||||
|
"lng": 12.07,
|
||||||
|
"radius": 30
|
||||||
|
}
|
||||||
|
|
||||||
## nodeInfos (array, optional)
|
## nodeInfos (array, optional)
|
||||||
|
|
||||||
This option allows to show node statistics depending on following case-sensitive parameters:
|
This option allows to show node statistics depending on following case-sensitive parameters:
|
||||||
|
|
81
helper.js
81
helper.js
|
@ -73,6 +73,13 @@ function localStorageTest() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function listReplace(s, subst) {
|
||||||
|
for (key in subst) {
|
||||||
|
s = s.replace(key, subst[key])
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
/* Helpers working with nodes */
|
/* Helpers working with nodes */
|
||||||
|
|
||||||
function offline(d) {
|
function offline(d) {
|
||||||
|
@ -138,3 +145,77 @@ function attributeEntry(el, label, value) {
|
||||||
|
|
||||||
return td
|
return td
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createIframe(opt, width, height) {
|
||||||
|
el = document.createElement("iframe")
|
||||||
|
width = typeof width !== 'undefined' ? width : '525px';
|
||||||
|
height = typeof height !== 'undefined' ? width : '350px';
|
||||||
|
|
||||||
|
if (opt.src)
|
||||||
|
el.src = opt.src
|
||||||
|
else
|
||||||
|
el.src = opt
|
||||||
|
|
||||||
|
if (opt.frameBorder)
|
||||||
|
el.frameBorder = opt.frameBorder
|
||||||
|
else
|
||||||
|
el.frameBorder = 1
|
||||||
|
|
||||||
|
if (opt.width)
|
||||||
|
el.width = opt.width
|
||||||
|
else
|
||||||
|
el.width = width
|
||||||
|
|
||||||
|
if (opt.height)
|
||||||
|
el.height = opt.height
|
||||||
|
else
|
||||||
|
el.height = height
|
||||||
|
|
||||||
|
el.scrolling = "no"
|
||||||
|
el.seamless = "seamless"
|
||||||
|
|
||||||
|
return el
|
||||||
|
}
|
||||||
|
|
||||||
|
function showStat(o, subst) {
|
||||||
|
var content, caption
|
||||||
|
subst = typeof subst !== 'undefined' ? subst : {};
|
||||||
|
|
||||||
|
if (o.thumbnail) {
|
||||||
|
content = document.createElement("img")
|
||||||
|
content.src = listReplace(o.thumbnail, subst)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o.caption) {
|
||||||
|
caption = listReplace(o.caption, subst)
|
||||||
|
|
||||||
|
if (!content)
|
||||||
|
content = document.createTextNode(caption)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o.iframe) {
|
||||||
|
content = createIframe(o.iframe)
|
||||||
|
if (o.iframe.src)
|
||||||
|
content.src = listReplace(o.iframe.src, subst)
|
||||||
|
else
|
||||||
|
content.src = listReplace(o.iframe, subst)
|
||||||
|
}
|
||||||
|
|
||||||
|
var p = document.createElement("p")
|
||||||
|
|
||||||
|
if (o.href) {
|
||||||
|
var link = document.createElement("a")
|
||||||
|
link.target = "_blank"
|
||||||
|
link.href = listReplace(o.href, subst)
|
||||||
|
link.appendChild(content)
|
||||||
|
|
||||||
|
if (caption && o.thumbnail)
|
||||||
|
link.title = caption
|
||||||
|
|
||||||
|
p.appendChild(link)
|
||||||
|
} else
|
||||||
|
p.appendChild(content)
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,9 @@
|
||||||
define(function () {
|
define(function () {
|
||||||
function showStatImg(o, source, target) {
|
function showStatImg(o, source, target) {
|
||||||
var content, caption
|
var subst = {}
|
||||||
|
subst["{SOURCE}"] = source
|
||||||
if (o.thumbnail) {
|
subst["{TARGET}"] = target
|
||||||
content = document.createElement("img")
|
return showStat(o, subst)
|
||||||
content.src = o.thumbnail.replace("{SOURCE}", source).replace("{TARGET}", target)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (o.caption) {
|
|
||||||
caption = o.caption.replace("{SOURCE}", source).replace("{TARGET}", target)
|
|
||||||
|
|
||||||
if (!content)
|
|
||||||
content = document.createTextNode(caption)
|
|
||||||
}
|
|
||||||
|
|
||||||
var p = document.createElement("p")
|
|
||||||
|
|
||||||
if (o.href) {
|
|
||||||
var link = document.createElement("a")
|
|
||||||
link.target = "_blank"
|
|
||||||
link.href = o.href.replace("{SOURCE}", source).replace("{TARGET}", target)
|
|
||||||
link.appendChild(content)
|
|
||||||
|
|
||||||
if (caption && o.thumbnail)
|
|
||||||
link.title = caption
|
|
||||||
|
|
||||||
p.appendChild(link)
|
|
||||||
} else
|
|
||||||
p.appendChild(content)
|
|
||||||
|
|
||||||
return p
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return function (config, el, router, d) {
|
return function (config, el, router, d) {
|
||||||
|
|
|
@ -219,37 +219,11 @@ define(["moment", "numeral", "tablesort", "infobox/charts", "tablesort.numeric"]
|
||||||
return au.enabled ? "aktiviert (" + au.branch + ")" : "deaktiviert"
|
return au.enabled ? "aktiviert (" + au.branch + ")" : "deaktiviert"
|
||||||
}
|
}
|
||||||
|
|
||||||
function showStatImg(o, nodeId) {
|
function showStatImg(o, d) {
|
||||||
var content, caption
|
var subst = {}
|
||||||
|
subst["{NODE_ID}"] = d.nodeinfo.node_id ? d.nodeinfo.node_id : "unknown"
|
||||||
if (o.thumbnail) {
|
subst["{NODE_NAME}"] = d.nodeinfo.hostname ? d.nodeinfo.hostname : "unknown"
|
||||||
content = document.createElement("img")
|
return showStat(o, subst)
|
||||||
content.src = o.thumbnail.replace("{NODE_ID}", nodeId)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (o.caption) {
|
|
||||||
caption = o.caption.replace("{NODE_ID}", nodeId)
|
|
||||||
|
|
||||||
if (!content)
|
|
||||||
content = document.createTextNode(caption)
|
|
||||||
}
|
|
||||||
|
|
||||||
var p = document.createElement("p")
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
p.appendChild(link)
|
|
||||||
} else
|
|
||||||
p.appendChild(content)
|
|
||||||
|
|
||||||
return p
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return function(config, el, router, d) {
|
return function(config, el, router, d) {
|
||||||
|
@ -294,7 +268,7 @@ define(["moment", "numeral", "tablesort", "infobox/charts", "tablesort.numeric"]
|
||||||
var h4 = document.createElement("h4")
|
var h4 = document.createElement("h4")
|
||||||
h4.textContent = nodeInfo.name
|
h4.textContent = nodeInfo.name
|
||||||
el.appendChild(h4)
|
el.appendChild(h4)
|
||||||
el.appendChild(showStatImg(nodeInfo, d.nodeinfo.node_id))
|
el.appendChild(showStatImg(nodeInfo, d))
|
||||||
})
|
})
|
||||||
|
|
||||||
if (d.neighbours.length > 0) {
|
if (d.neighbours.length > 0) {
|
||||||
|
|
|
@ -447,7 +447,10 @@ define(["map/clientlayer", "map/labelslayer",
|
||||||
var lines = addLinksToMap(linkDict, linkScale, data.graph.links, router)
|
var lines = addLinksToMap(linkDict, linkScale, data.graph.links, router)
|
||||||
groupLines = L.featureGroup(lines).addTo(map)
|
groupLines = L.featureGroup(lines).addTo(map)
|
||||||
|
|
||||||
|
if (typeof config.fixedCenter === "undefined")
|
||||||
barycenter = calcBarycenter(data.nodes.all.filter(has_location))
|
barycenter = calcBarycenter(data.nodes.all.filter(has_location))
|
||||||
|
else
|
||||||
|
barycenter = L.circle(L.latLng(new L.LatLng(config.fixedCenter.lat, config.fixedCenter.lng)), config.fixedCenter.radius * 1000)
|
||||||
|
|
||||||
var nodesOnline = subtract(data.nodes.all.filter(online), data.nodes.new)
|
var nodesOnline = subtract(data.nodes.all.filter(online), data.nodes.new)
|
||||||
var nodesOffline = subtract(data.nodes.all.filter(offline), data.nodes.lost)
|
var nodesOffline = subtract(data.nodes.all.filter(offline), data.nodes.lost)
|
||||||
|
|
|
@ -23,43 +23,17 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc
|
||||||
var uplinkTable = document.createElement("table")
|
var uplinkTable = document.createElement("table")
|
||||||
uplinkTable.classList.add("proportion")
|
uplinkTable.classList.add("proportion")
|
||||||
|
|
||||||
var gwTable = document.createElement("table")
|
var gwNodesTable = document.createElement("table")
|
||||||
gwTable.classList.add("proportion")
|
gwNodesTable.classList.add("proportion")
|
||||||
|
|
||||||
|
var gwClientsTable = document.createElement("table")
|
||||||
|
gwClientsTable.classList.add("proportion")
|
||||||
|
|
||||||
var siteTable = document.createElement("table")
|
var siteTable = document.createElement("table")
|
||||||
siteTable.classList.add("proportion")
|
siteTable.classList.add("proportion")
|
||||||
|
|
||||||
function showStatGlobal(o) {
|
function showStatGlobal(o) {
|
||||||
var content, caption
|
return showStat(o)
|
||||||
|
|
||||||
if (o.thumbnail) {
|
|
||||||
content = document.createElement("img")
|
|
||||||
content.src = o.thumbnail
|
|
||||||
}
|
|
||||||
|
|
||||||
if (o.caption) {
|
|
||||||
caption = o.caption
|
|
||||||
|
|
||||||
if (!content)
|
|
||||||
content = document.createTextNode(caption)
|
|
||||||
}
|
|
||||||
|
|
||||||
var p = document.createElement("p")
|
|
||||||
|
|
||||||
if (o.href) {
|
|
||||||
var link = document.createElement("a")
|
|
||||||
link.target = "_blank"
|
|
||||||
link.href = o.href
|
|
||||||
link.appendChild(content)
|
|
||||||
|
|
||||||
if (caption && o.thumbnail)
|
|
||||||
link.title = caption
|
|
||||||
|
|
||||||
p.appendChild(link)
|
|
||||||
} else
|
|
||||||
p.appendChild(content)
|
|
||||||
|
|
||||||
return p
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function count(nodes, key, f) {
|
function count(nodes, key, f) {
|
||||||
|
@ -80,6 +54,25 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc
|
||||||
return Object.keys(dict).map(function (d) { return [d, dict[d], key, f] })
|
return Object.keys(dict).map(function (d) { return [d, dict[d], key, f] })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function countClients(nodes, key, f) {
|
||||||
|
var dict = {}
|
||||||
|
|
||||||
|
nodes.forEach( function (d) {
|
||||||
|
var v = dictGet(d, key.slice(0))
|
||||||
|
|
||||||
|
if (f !== undefined)
|
||||||
|
v = f(v)
|
||||||
|
|
||||||
|
if (v === null)
|
||||||
|
return
|
||||||
|
|
||||||
|
dict[v] = d.statistics.clients + (v in dict ? dict[v] : 0)
|
||||||
|
})
|
||||||
|
|
||||||
|
return Object.keys(dict).map(function (d) { return [d, dict[d], key, f] })
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function addFilter(filter) {
|
function addFilter(filter) {
|
||||||
return function () {
|
return function () {
|
||||||
filterManager.addFilter(filter)
|
filterManager.addFilter(filter)
|
||||||
|
@ -137,8 +130,9 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc
|
||||||
var fwDict = count(nodes, ["nodeinfo", "software", "firmware", "release"])
|
var fwDict = count(nodes, ["nodeinfo", "software", "firmware", "release"])
|
||||||
var hwDict = count(nodes, ["nodeinfo", "hardware", "model"])
|
var hwDict = count(nodes, ["nodeinfo", "hardware", "model"])
|
||||||
var geoDict = count(nodes, ["nodeinfo", "location"], function (d) {
|
var geoDict = count(nodes, ["nodeinfo", "location"], function (d) {
|
||||||
return d ? "ja" : "nein"
|
return d && d.longitude && d.latitude ? "ja" : "nein"
|
||||||
})
|
})
|
||||||
|
|
||||||
var autoDict = count(nodes, ["nodeinfo", "software", "autoupdater"], function (d) {
|
var autoDict = count(nodes, ["nodeinfo", "software", "autoupdater"], function (d) {
|
||||||
if (d === null)
|
if (d === null)
|
||||||
return null
|
return null
|
||||||
|
@ -147,11 +141,22 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc
|
||||||
else
|
else
|
||||||
return "(deaktiviert)"
|
return "(deaktiviert)"
|
||||||
})
|
})
|
||||||
|
|
||||||
var uplinkDict = count(nodes, ["flags", "uplink"], function (d) {
|
var uplinkDict = count(nodes, ["flags", "uplink"], function (d) {
|
||||||
return d ? "ja" : "nein"
|
return d ? "ja" : "nein"
|
||||||
})
|
})
|
||||||
|
|
||||||
var gwDict = count(nodes, ["statistics", "gateway"], function (d) {
|
var gwNodesDict = count(nodes, ["statistics", "gateway"], function (d) {
|
||||||
|
if (d === null)
|
||||||
|
return null
|
||||||
|
|
||||||
|
if (d in nodeDict)
|
||||||
|
return nodeDict[d].nodeinfo.hostname
|
||||||
|
|
||||||
|
return d
|
||||||
|
})
|
||||||
|
|
||||||
|
var gwClientsDict = countClients(onlineNodes, ["statistics", "gateway"], function (d) {
|
||||||
if (d === null)
|
if (d === null)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
@ -175,71 +180,45 @@ define(["chroma-js", "virtual-dom", "numeral-intl", "filters/genericnode", "verc
|
||||||
fillTable("Firmware", fwTable, fwDict.sort(function (a, b) { return vercomp(b[0], a[0]) }))
|
fillTable("Firmware", fwTable, fwDict.sort(function (a, b) { return vercomp(b[0], a[0]) }))
|
||||||
fillTable("Hardware", hwTable, hwDict.sort(function (a, b) { return b[1] - a[1] }))
|
fillTable("Hardware", hwTable, hwDict.sort(function (a, b) { return b[1] - a[1] }))
|
||||||
fillTable("Koordinaten", geoTable, geoDict.sort(function (a, b) { return b[1] - a[1] }))
|
fillTable("Koordinaten", geoTable, geoDict.sort(function (a, b) { return b[1] - a[1] }))
|
||||||
fillTable("Autom. Updates", autoTable, autoDict.sort(function (a, b) { return b[1] - a[1] }))
|
|
||||||
fillTable("Uplink", uplinkTable, uplinkDict.sort(function (a, b) { return b[1] - a[1] }))
|
fillTable("Uplink", uplinkTable, uplinkDict.sort(function (a, b) { return b[1] - a[1] }))
|
||||||
fillTable("Gewähltes Gateway", gwTable, gwDict.sort(function (a, b) { return b[1] - a[1] }))
|
fillTable("Autom. Updates", autoTable, autoDict.sort(function (a, b) { return b[1] - a[1] }))
|
||||||
|
fillTable("Nodes an Gateway", gwNodesTable, gwNodesDict.sort(function (a, b) { return b[1] - a[1] }))
|
||||||
|
fillTable("Clients an Gateway", gwClientsTable, gwClientsDict.sort(function (a, b) { return b[1] - a[1] }))
|
||||||
fillTable("Site", siteTable, siteDict.sort(function (a, b) { return b[1] - a[1] }))
|
fillTable("Site", siteTable, siteDict.sort(function (a, b) { return b[1] - a[1] }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
self.render = function (el) {
|
self.render = function (el) {
|
||||||
var h2
|
var h2
|
||||||
h2 = document.createElement("h2")
|
self.renderSingle(el, "Status", statusTable)
|
||||||
h2.textContent = "Status"
|
self.renderSingle(el, "Nodes an Gateway", gwNodesTable)
|
||||||
el.appendChild(h2)
|
self.renderSingle(el, "Clients an Gateway", gwClientsTable)
|
||||||
el.appendChild(statusTable)
|
self.renderSingle(el, "Firmwareversionen", fwTable)
|
||||||
|
self.renderSingle(el, "Uplink", uplinkTable)
|
||||||
h2 = document.createElement("h2")
|
self.renderSingle(el, "Hardwaremodelle", hwTable)
|
||||||
h2.textContent = "Firmwareversionen"
|
self.renderSingle(el, "Auf der Karte sichtbar", geoTable)
|
||||||
el.appendChild(h2)
|
self.renderSingle(el, "Autoupdater", autoTable)
|
||||||
el.appendChild(fwTable)
|
self.renderSingle(el, "Site", siteTable)
|
||||||
|
|
||||||
if(config.siteNames || config.showSites) {
|
|
||||||
h2 = document.createElement("h2")
|
|
||||||
h2.textContent = "Orte"
|
|
||||||
el.appendChild(h2)
|
|
||||||
el.appendChild(siteTable)
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 = document.createElement("h2")
|
|
||||||
h2.textContent = "Hardwaremodelle"
|
|
||||||
el.appendChild(h2)
|
|
||||||
el.appendChild(hwTable)
|
|
||||||
|
|
||||||
h2 = document.createElement("h2")
|
|
||||||
h2.textContent = "Auf der Karte sichtbar"
|
|
||||||
el.appendChild(h2)
|
|
||||||
el.appendChild(geoTable)
|
|
||||||
|
|
||||||
h2 = document.createElement("h2")
|
|
||||||
h2.textContent = "Autoupdater"
|
|
||||||
el.appendChild(h2)
|
|
||||||
el.appendChild(autoTable)
|
|
||||||
|
|
||||||
h2 = document.createElement("h2")
|
|
||||||
h2.textContent = "Uplink"
|
|
||||||
el.appendChild(h2)
|
|
||||||
el.appendChild(uplinkTable)
|
|
||||||
|
|
||||||
h2 = document.createElement("h2")
|
|
||||||
h2.textContent = "Gewählter Gateway"
|
|
||||||
el.appendChild(h2)
|
|
||||||
el.appendChild(gwTable)
|
|
||||||
|
|
||||||
h2 = document.createElement("h2")
|
|
||||||
h2.textContent = "Site"
|
|
||||||
el.appendChild(h2)
|
|
||||||
el.appendChild(siteTable)
|
|
||||||
|
|
||||||
if (config.globalInfos)
|
if (config.globalInfos)
|
||||||
config.globalInfos.forEach( function (globalInfo) {
|
config.globalInfos.forEach(function (globalInfo) {
|
||||||
h2 = document.createElement("h2")
|
h2 = document.createElement("h2")
|
||||||
h2.textContent = globalInfo.name
|
h2.textContent = globalInfo.name
|
||||||
el.appendChild(h2)
|
el.appendChild(h2)
|
||||||
|
|
||||||
el.appendChild(showStatGlobal(globalInfo))
|
el.appendChild(showStatGlobal(globalInfo))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.renderSingle = function (el, heading, table) {
|
||||||
|
var h2
|
||||||
|
h2 = document.createElement("h2")
|
||||||
|
h2.textContent = heading
|
||||||
|
h2.onclick = function () {
|
||||||
|
table.classList.toggle("hidden")
|
||||||
|
}
|
||||||
|
el.appendChild(h2)
|
||||||
|
el.appendChild(table)
|
||||||
|
}
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
"node": true
|
"node": true
|
||||||
},
|
},
|
||||||
"globals": {
|
"globals": {
|
||||||
|
"showStat": false,
|
||||||
"attributeEntry": false,
|
"attributeEntry": false,
|
||||||
"dictGet": false,
|
"dictGet": false,
|
||||||
"getJSON": false,
|
"getJSON": false,
|
||||||
|
|
|
@ -128,6 +128,10 @@ table.attributes td {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.container table.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
line-height: 1.67em;
|
line-height: 1.67em;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue