map UI changes
All checks were successful
Meshtastic Map - See local Meshtastic Nodes / deploy (push) Successful in 1s

This commit is contained in:
david 2025-04-23 13:05:48 -07:00
parent 28d09862c1
commit 8641463324

View File

@ -15,33 +15,44 @@
var map = L.map('map').setView([0, 0], 2); var map = L.map('map').setView([0, 0], 2);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
let myCoords = null; let myCoords = null;
const today = new Date();
const getNodeDesc = (node) =>{ const daysSince = (test) => {
if (test) {
const diffTime = Math.abs(test.getTime() - today.getTime());
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
return diffDays;
}
return "N/A"
}
const getNodeDesc = (node) => {
const deviceMetrics = node?.deviceMetrics const deviceMetrics = node?.deviceMetrics
const hopsAway = node?.hopsAway ?? 'N/A'; const hopsAway = node?.hopsAway ?? 'N/A';
const lastHeard = node?.lastHeard; const lastHeard = node?.lastHeard ? new Date(node?.lastHeard * 1000) : null
const num = node?.num; const num = node?.num;
const position = node?.position; const position = node?.position;
const snr = node?.snr ?? 'N/A'; const snr = node?.snr ?? 'N/A';
const user = node?.user; const user = node?.user;
const lat = position?.latitude const lat = position?.latitude
const lon = position?.longitude
return ` return `
Id: ${user.id}<br/> ${user.id}<br/>
Hops Away: ${hopsAway}<br/> ${user.shortName}<br/>
${hopsAway} hop<br/>
S/N: ${snr} dbM<br/> S/N: ${snr} dbM<br/>
Loc: ${lat}, ${lon} Last Heard: ${daysSince(lastHeard)} days
` `
} }
const updateNodes= async() => { const updateNodes = async () => {
const res = await fetch('/nodes'); const res = await fetch('/nodes');
const json = await res.json(); const json = await res.json();
const myNodeId = json['myNodeId'] const myNodeId = json['myNodeId']
// const myNodeNum = json['myNodeNum'] // const myNodeNum = json['myNodeNum']
const nodes = json['nodes'] const nodes = json['nodes']
let myNode = null; let myNode = null;
// const my // const my
// Object.entries(nodes).forEach() // Object.entries(nodes).forEach()
@ -71,7 +82,7 @@
} }
}) })
} }
updateNodes(); updateNodes();
center(); center();