From 92d9f378776dd2c9e259ebd39a7612be3baf233d Mon Sep 17 00:00:00 2001 From: Sam Sweet Date: Thu, 27 Jun 2024 17:53:53 -0400 Subject: [PATCH] RED-150: Add table to view load on individual nodes on large-networks page (#4) --- public/large-network.js | 36 ++++++++++++++++++++++-- views/large-network.html | 59 ++++++++++++++++++++++++++++++++++------ 2 files changed, 85 insertions(+), 10 deletions(-) diff --git a/public/large-network.js b/public/large-network.js index fc456cf..95f0e41 100644 --- a/public/large-network.js +++ b/public/large-network.js @@ -46,17 +46,29 @@ queueTime: 0, totalQueueTime: 0, expiredTx: 0, - }, colorMode: 'state', animateTransactions: false, queueDetails: false, + nodeLoads: [], + sortKey: 'ip', + sortAsc: true, } }, async mounted() { console.log('Mounted') this.start() }, + computed: { + sortedNodes() { + return this.nodeLoads.sort((a, b) => { + let modifier = this.sortAsc ? 1 : -1 + if (a[this.sortKey] < b[this.sortKey]) return -1 * modifier + if (a[this.sortKey] > b[this.sortKey]) return 1 * modifier + return 0 + }) + }, + }, methods: { calculateNetworkPosition(nodeId) { let spread = 4 @@ -218,6 +230,7 @@ let totalLoad = 0 let totalQueueLength = 0 let totalQueueTime = 0.0 + this.nodeLoads = [] for (let nodeId in report.nodes.active) { const node = report.nodes.active[nodeId] @@ -230,6 +243,16 @@ queueLength.push(node.queueLength) totalQueueTime += node.txTimeInQueue queueTime.push(node.txTimeInQueue) + + this.nodeLoads.push({ + id: nodeId, + ip: node.nodeIpInfo.externalIp, + port: node.nodeIpInfo.externalPort, + loadInternal: node.currentLoad.nodeLoad.internal, + loadExternal: node.currentLoad.nodeLoad.external, + queueLength: node.queueLength, + queueTime: node.txTimeInQueue, + }) } this.networkStatus.tps = report.avgTps @@ -256,6 +279,14 @@ this.networkStatus.queueTime = this.average(queueTime) this.networkStatus.totalQueueTime = totalQueueTime }, + sortTable(key) { + if (this.sortKey === key) { + this.sortAsc = !this.sortAsc + } else { + this.sortKey = key + this.sortAsc = true + } + }, deleteCrashedNodes(nodes) { console.log('Running delete crash nodes', nodes) try { @@ -336,7 +367,8 @@ try { let changes = await this.fetchChanges() console.log( - `Total of ${Object.keys(changes.nodes.active).length}/${Object.keys(G.nodes.active).length + `Total of ${Object.keys(changes.nodes.active).length}/${ + Object.keys(G.nodes.active).length } nodes updated.` ) this.filterOutCrashedNodes(changes) diff --git a/views/large-network.html b/views/large-network.html index 9f20d6b..1c88d4f 100644 --- a/views/large-network.html +++ b/views/large-network.html @@ -1,23 +1,21 @@ + - + + @@ -228,16 +247,40 @@ App Versions + +
+
NODE LOADS
+ + + + + + + + + + + + + + + + + + + + + +
IPPortLoad InternalLoad ExternalQ LengthQ Time
{{ node.ip }}{{ node.port }}{{ node.loadInternal }}{{ node.loadExternal }}{{ node.queueLength }}{{ node.queueTime }}
+
- - - +