Moved Zigbee neighbour info to API
This commit is contained in:
parent
784844b85f
commit
ce73bd70fe
3 changed files with 82 additions and 17 deletions
|
|
@ -33,24 +33,28 @@
|
|||
<div id="network_graph"></div>
|
||||
|
||||
<script>
|
||||
var nodes = [
|
||||
{{#nodes}}{"id": "{{.getIeeeAddress()}}", "name": "{{.getIeeeAddress()}}"},
|
||||
{{/nodes}}
|
||||
]
|
||||
fetch('/api/zigbee')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
var nodes = [];
|
||||
var links = [];
|
||||
|
||||
var links = [
|
||||
{{#nodes}}{{#.getNeighbors()}}{"source": "", "target": "{{.getNetworkAddress()}}"},
|
||||
{{/.getNeighbors()}}{{/nodes}}
|
||||
]
|
||||
data.forEach(node => {
|
||||
nodes.add({"id": node.address, "name": node.address});
|
||||
nodes.neighbours.forEach(neighbour => {
|
||||
links.add({"source": node.address, "target": neighbour})
|
||||
}
|
||||
});
|
||||
|
||||
const Graph = ForceGraph()
|
||||
(document.getElementById('network_graph'))
|
||||
.linkDirectionalParticles(2)
|
||||
.graphData({
|
||||
nodes: nodes,
|
||||
links: links
|
||||
}
|
||||
);
|
||||
const Graph = ForceGraph()
|
||||
(document.getElementById('network_graph'))
|
||||
.linkDirectionalParticles(2)
|
||||
.graphData({
|
||||
nodes: nodes,
|
||||
links: links
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
|
||||
<h2>Connected Nodes</h2>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue