Skip to content

Commit

Permalink
fix: Update network graph when node added/removed
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Jan 3, 2020
1 parent ac6d8be commit 7b4801c
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/components/Mesh.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,32 @@ export default {
}
})
this.socket.on(this.socketEvents.nodeRemoved, node => {
self.$set(self.nodes, node.node_id, node)
self.refresh()
})
this.socket.on(this.socketEvents.nodeUpdated, data => {
var node = self.convertNode(data)
if (!self.nodes[data.node_id]) {
self.nodes.push(node)
// node added
var refresh = !self.nodes[data.node_id] || self.nodes[data.node_id].failed
// add missing nodes if new node added
while (self.nodes.length < data.node_id) {
self.nodes.push({
node_id: self.nodes.length,
failed: true,
status: 'Removed'
})
}
self.$set(self.nodes, data.node_id, node)
// update links if new node has been added
if (refresh) {
self.refresh()
}
})
this.socket.on(this.socketEvents.api, data => {
Expand Down

0 comments on commit 7b4801c

Please sign in to comment.