From 014dea2dd00701da33cada8e1b47211891c9bd57 Mon Sep 17 00:00:00 2001 From: "Blake J. Harnden" Date: Tue, 15 May 2018 08:46:53 -0700 Subject: [PATCH] web app update to attempt to re-use deleted node ids --- webapp/static/corenetwork.js | 9 +++++++++ webapp/static/coreui.js | 12 ++++++++++-- webapp/templates/index.html | 8 ++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/webapp/static/corenetwork.js b/webapp/static/corenetwork.js index 82f90d5e..6a8fd497 100644 --- a/webapp/static/corenetwork.js +++ b/webapp/static/corenetwork.js @@ -43,6 +43,7 @@ class NodeHelper { this.defaultNode = 0; this.ptpNode = 12; + this.wlanNode = 6; } isNetworkNode(node) { @@ -198,6 +199,7 @@ class CoreNetwork { deleteNode(nodeId) { // remove node from graph + this.nodeId = nodeId - 1; this.nodes.remove(nodeId); // remove node links @@ -262,6 +264,13 @@ class CoreNetwork { nextNodeId() { this.nodeId += 1; + while (true) { + const node = this.nodes.get(this.nodeId); + if (node === null) { + break; + } + this.nodeId += 1; + } return this.nodeId; } diff --git a/webapp/static/coreui.js b/webapp/static/coreui.js index e6a4920f..f86a97f6 100644 --- a/webapp/static/coreui.js +++ b/webapp/static/coreui.js @@ -157,12 +157,13 @@ class NodeContext { this.nodeEditModal = nodeEditModal; this.servicesModal = servicesModal; this.$nodeContext = $('#node-context'); - this.$deleteButton = this.$nodeContext.find('button[data-option="delete"]'); + this.$linkRfButton = $('#node-linkrf-button'); + this.$deleteButton = $('#node-delete-button'); this.onClick(); } show(nodeId, x, y) { - const node = this.coreNetwork.nodes.get(nodeId); + const node = this.coreNetwork.getCoreNode(nodeId); console.log('context node: ', node); this.coreRest.isRunning() .then(isRunning => { @@ -172,6 +173,13 @@ class NodeContext { this.$deleteButton.removeAttr('disabled'); } + console.log('node type: ', node.type); + if (node.type === CoreNodeHelper.wlanNode) { + this.$linkRfButton.removeClass('d-none'); + } else { + this.$linkRfButton.addClass('d-none'); + } + this.$nodeContext.data('node', nodeId); this.$nodeContext.css({ position: 'absolute', diff --git a/webapp/templates/index.html b/webapp/templates/index.html index db730cfd..e88f9766 100644 --- a/webapp/templates/index.html +++ b/webapp/templates/index.html @@ -116,8 +116,12 @@
- - + + +