Skip to content

Commit

Permalink
feat: hide/show location in mesh nodes (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando authored Apr 27, 2020
1 parent 9b0b2c4 commit cd9cf84
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/components/ControlPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,9 @@ export default {
if (self.debug.length > MAX_DEBUG_LINES) self.debug.shift()
var textarea = document.getElementById('debug_window')
textarea.scrollTop = textarea.scrollHeight
if (textarea) { // textarea could be hidden
textarea.scrollTop = textarea.scrollHeight
}
}
})
Expand Down
20 changes: 18 additions & 2 deletions src/components/Mesh.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
</v-flex>
<v-flex xs3 md2>
<v-text-field label="Distance" v-model.number="force" min="100" type="number"></v-text-field>
</v-flex>
<v-flex xs3 md2>
<v-switch label="Show location" v-model="showLocation"></v-switch>
</v-flex>
<v-flex xs5 md6>
<v-btn color="success" @click="downloadSVG">Download SVG</v-btn>
Expand Down Expand Up @@ -95,6 +98,13 @@ export default {
components: {
D3Network
},
watch: {
showLocation () {
for (const n of this.nodes) {
n.name = this.nodeName(n)
}
}
},
computed: {
activeNodes () {
return this.nodes.filter(n => n.node_id !== 0 && n.status !== 'Removed')
Expand Down Expand Up @@ -138,7 +148,8 @@ export default {
links: [],
fab: false,
selectedNode: null,
showProperties: false
showProperties: false,
showLocation: false
}
},
methods: {
Expand All @@ -156,12 +167,17 @@ export default {
return {
id: n.node_id,
_cssClass: this.nodeClass(n),
name: n.name ? n.name : n.product,
name: this.nodeName(n),
node_id: n.node_id,
status: n.status,
data: n
}
},
nodeName (n) {
if (n.data) n = n.data // works both with node object and mesh node object
var name = n.name || n.product || 'node ' + n.node_id
return name + (this.showLocation && n.loc ? ` (${n.loc})` : '')
},
nodeClass (n) {
if (n.node_id === 1) {
return 'controller'
Expand Down

0 comments on commit cd9cf84

Please sign in to comment.