From 4e6432573c2bcbfe0788048c8935948937721316 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Sat, 18 May 2024 21:19:22 +1200 Subject: [PATCH] add ui to show how many hops away peers and nodes are --- public/index.html | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 38a04b4..e093be3 100644 --- a/public/index.html +++ b/public/index.html @@ -222,7 +222,7 @@
{{ selectedPeer.name }}
-
@<{{ selectedPeer.destination_hash }}>
+
<{{ selectedPeer.destination_hash }}> {{ selectedPeerPath.hops }} {{ selectedPeerPath.hops === 1 ? 'hop' : 'hops' }} away
@@ -452,6 +452,7 @@
{{ selectedNode.name }}
+
<{{ selectedNode.destination_hash }}> {{ selectedNodePath.hops }} {{ selectedNodePath.hops === 1 ? 'hop' : 'hops' }} away
@@ -539,10 +540,12 @@ peers: {}, peersSearchTerm: "", selectedPeer: null, + selectedPeerPath: null, nodes: {}, nodesSearchTerm: "", selectedNode: null, + selectedNodePath: null, lxmfMessagesRequestSequence: 0, chatItems: [], @@ -966,6 +969,42 @@ console.log(e); } }, + async getPeerPath(destinationHash) { + + // clear previous known path + this.selectedPeerPath = null; + + try { + + // get path to destination + const response = await window.axios.get(`/api/v1/destination/${destinationHash}/path`); + + // update ui + this.selectedPeerPath = response.data.path; + + } catch(e) { + console.log(e); + } + + }, + async getNodePath(destinationHash) { + + // clear previous known path + this.selectedNodePath = null; + + try { + + // get path to destination + const response = await window.axios.get(`/api/v1/destination/${destinationHash}/path`); + + // update ui + this.selectedNodePath = response.data.path; + + } catch(e) { + console.log(e); + } + + }, getPeerNameFromAppData: function(appData) { try { // app data should be peer name, and our server provides it base64 encoded @@ -1283,11 +1322,13 @@ this.selectedNode = null; this.selectedPeer = peer; this.chatItems = []; + this.getPeerPath(peer.destination_hash); this.loadLxmfMessages(peer.destination_hash); }, onNodeClick: function(node) { this.selectedPeer = null; this.selectedNode = node; + this.getNodePath(node.destination_hash); this.loadNodePage(node.destination_hash, "/page/index.mu"); }, parseSeconds: function(secondsToFormat) { @@ -1431,6 +1472,9 @@ chatItem.is_actions_expanded = false; } }, + onDestinationPathClick: function(path) { + alert(path.description); + }, }, computed: { isMobile() {