mirror of
https://github.com/pablorevilla-meshtastic/meshview.git
synced 2026-07-17 23:22:29 +02:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d52dfeac1 | |||
| 31744aace9 | |||
| a3ce0640ab | |||
| 1ba64f8908 |
+19
-29
@@ -235,6 +235,7 @@ function labelFor(key, fallback){
|
|||||||
function buildNodePopup(node){
|
function buildNodePopup(node){
|
||||||
const labels = {
|
const labels = {
|
||||||
channel: labelFor("channel_label", "Channel"),
|
channel: labelFor("channel_label", "Channel"),
|
||||||
|
nodeId: labelFor("node_id", "Node ID"),
|
||||||
model: labelFor("model_label", "Model"),
|
model: labelFor("model_label", "Model"),
|
||||||
role: labelFor("role_label", "Role"),
|
role: labelFor("role_label", "Role"),
|
||||||
mqtt: labelFor("mqtt_gateway", "MQTT Gateway"),
|
mqtt: labelFor("mqtt_gateway", "MQTT Gateway"),
|
||||||
@@ -243,13 +244,16 @@ function buildNodePopup(node){
|
|||||||
yes: mapTranslations.yes || "Yes",
|
yes: mapTranslations.yes || "Yes",
|
||||||
no: mapTranslations.no || "No"
|
no: mapTranslations.no || "No"
|
||||||
};
|
};
|
||||||
|
const displayName = node.long_name || node.short_name || `Node ${node.node_id}`;
|
||||||
|
const shortName = node.short_name ? ` (${escapeHtml(node.short_name)})` : "";
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<b><a href="/node/${node.node_id}">${node.long_name}</a> (${node.short_name})</b><br>
|
<b><a href="/node/${node.node_id}">${escapeHtml(displayName)}</a>${shortName}</b><br>
|
||||||
|
|
||||||
<b>${labels.channel}</b> ${node.channel}<br>
|
<b>${labels.nodeId}</b> ${node.node_id}<br>
|
||||||
<b>${labels.model}</b> ${node.hw_model}<br>
|
<b>${labels.channel}</b> ${escapeHtml(node.channel || "N/A")}<br>
|
||||||
<b>${labels.role}</b> ${node.role}<br>
|
<b>${labels.model}</b> ${escapeHtml(node.hw_model || "N/A")}<br>
|
||||||
|
<b>${labels.role}</b> ${escapeHtml(node.role || "N/A")}<br>
|
||||||
<b>${labels.mqtt}</b> ${node.is_mqtt_gateway ? labels.yes : labels.no}<br>
|
<b>${labels.mqtt}</b> ${node.is_mqtt_gateway ? labels.yes : labels.no}<br>
|
||||||
|
|
||||||
${
|
${
|
||||||
@@ -260,7 +264,7 @@ function buildNodePopup(node){
|
|||||||
|
|
||||||
${
|
${
|
||||||
node.firmware
|
node.firmware
|
||||||
? `<b>${labels.firmware}</b> ${node.firmware}<br>`
|
? `<b>${labels.firmware}</b> ${escapeHtml(node.firmware)}<br>`
|
||||||
: ""
|
: ""
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -468,34 +472,18 @@ function renderNodesOnMap(){
|
|||||||
marker.nodeId = node.key;
|
marker.nodeId = node.key;
|
||||||
marker.originalColor = color;
|
marker.originalColor = color;
|
||||||
markerById[node.key] = marker;
|
markerById[node.key] = marker;
|
||||||
|
marker.bindPopup(buildNodePopup(node), {
|
||||||
|
autoPan: true,
|
||||||
|
closeButton: true
|
||||||
|
});
|
||||||
|
|
||||||
const popup = `
|
marker.on('click', e => {
|
||||||
<a href="/node/${node.node_id}">${node.long_name}</a> (${node.short_name})<br>
|
if(e.originalEvent){
|
||||||
|
L.DomEvent.stopPropagation(e.originalEvent);
|
||||||
<span data-translate-lang="channel_label"></span> ${node.channel}<br>
|
|
||||||
<span data-translate-lang="model_label"></span> ${node.hw_model}<br>
|
|
||||||
<span data-translate-lang="role_label"></span> ${node.role}<br>
|
|
||||||
<span data-translate-lang="mqtt_gateway"></span> ${
|
|
||||||
node.is_mqtt_gateway ? (mapTranslations.yes || "Yes") : (mapTranslations.no || "No")
|
|
||||||
}<br>
|
|
||||||
|
|
||||||
${
|
|
||||||
node.last_seen_us
|
|
||||||
? `<span data-translate-lang="last_seen"></span> ${timeAgoFromUs(node.last_seen_us)}<br>`
|
|
||||||
: ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
${
|
|
||||||
node.firmware
|
|
||||||
? `<span data-translate-lang="firmware"></span> ${node.firmware}<br>`
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
marker.on('click', () => {
|
|
||||||
onNodeClick(node);
|
|
||||||
marker.setPopupContent(buildNodePopup(node));
|
marker.setPopupContent(buildNodePopup(node));
|
||||||
marker.openPopup();
|
marker.openPopup();
|
||||||
|
onNodeClick(node);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -615,6 +603,8 @@ async function onNodeClick(node){
|
|||||||
}
|
}
|
||||||
|
|
||||||
map.on('click', e=>{
|
map.on('click', e=>{
|
||||||
|
if(e.originalEvent.defaultPrevented) return;
|
||||||
|
|
||||||
if(!e.originalEvent.target.classList.contains('leaflet-interactive')){
|
if(!e.originalEvent.target.classList.contains('leaflet-interactive')){
|
||||||
edgeLayer.clearLayers();
|
edgeLayer.clearLayers();
|
||||||
selectedNodeId=null;
|
selectedNodeId=null;
|
||||||
|
|||||||
Reference in New Issue
Block a user