From 609ba1a3cdd46cf7fe0e982f4e09a0498f2f6248 Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Thu, 15 Dec 2022 16:01:57 +0200 Subject: [PATCH] UI getSelf regirected moved to REST /api/getself removed dead code --- contrib/ui/mesh-ui/ui/assets/mesh-ui.js | 30 ++++++++---- contrib/ui/mesh-ui/ui/index.html | 2 +- contrib/ui/mesh-ui/webview.go | 61 ------------------------- 3 files changed, 22 insertions(+), 71 deletions(-) diff --git a/contrib/ui/mesh-ui/ui/assets/mesh-ui.js b/contrib/ui/mesh-ui/ui/assets/mesh-ui.js index 809c7e56..cae90647 100644 --- a/contrib/ui/mesh-ui/ui/assets/mesh-ui.js +++ b/contrib/ui/mesh-ui/ui/assets/mesh-ui.js @@ -1,15 +1,6 @@ var $ = id => document.getElementById(id) var $$ = clazz => document.getElementsByClassName(clazz) -function setFieldValue(id, value) { - //console.log(`setFieldValue(${id}, ${value})`); - if (id === 'peers') { - return; - } - var field = $(id); - field.innerHTML = value; -} - function setPingValue(peer, value) { var cellText; var peerCell = $(peer); @@ -294,6 +285,23 @@ ui.lookupCountryCodeByAddress = (address) => { return ui._allPeers[c][peer].countryCode; } +ui.getSelfInfo = () => + fetch('api/getself') + .then((response) => response.json()) + +ui.updateSelfInfo = () => + ui.getSelfInfo() + .then((info) => { + $("ipv6").innerText = info.address; + $("pub_key").innerText = info.key; + $("priv_key").innerText = info.private_key; + $("ipv6").innerText = info.address; + $("version").innerText = info.build_version; + }).catch((error) => { + $("ipv6").innerText = error.message; + }); + + function main() { fetch('country.json') @@ -302,8 +310,12 @@ function main() { window.addEventListener("load", () => { $("showAllPeersBtn").addEventListener("click", ui.showAllPeers); + ui.getAllPeers().then(() => ui.updateConnectedPeers()); setInterval(ui.updateConnectedPeers, 5000); + + ui.updateSelfInfo(); + setInterval(ui.updateSelfInfo, 5000); }); } diff --git a/contrib/ui/mesh-ui/ui/index.html b/contrib/ui/mesh-ui/ui/index.html index d7862701..6765dff6 100755 --- a/contrib/ui/mesh-ui/ui/index.html +++ b/contrib/ui/mesh-ui/ui/index.html @@ -14,7 +14,7 @@ - +