diff --git a/src/public/index.html b/src/public/index.html index 5cc2263..82c892c 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -86,10 +86,14 @@ visibility: visible; } - .z-sidebar { + .z-search { z-index: 1000; } + .z-sidebar { + z-index: 1001; + } + @@ -121,8 +125,32 @@ +
-
@@ -590,6 +618,9 @@ isShowingHardwareModels: false, hardwareModelStats: null, + nodes: [], + searchText: "", + selectedNode: null, selectedNodeDeviceMetrics: [], selectedNodeMqttMetrics: [], @@ -603,6 +634,11 @@ // load data this.loadHardwareModelStats(); + // handle map click callback from outside of vue + window._onMapClick = () => { + this.searchText = ""; + }; + // handle node callback from outside of vue window._onNodeClick = (node) => { this.selectedNode = node; @@ -610,6 +646,11 @@ this.loadNodeMqttMetrics(node.node_id); }; + // handle nodes updated callback from outside of vue + window._onNodesUpdated = (nodes) => { + this.nodes = nodes; + }; + }, methods: { loadHardwareModelStats: function() { @@ -900,6 +941,29 @@ }, }, + computed: { + searchedNodes() { + + // search nodes + const nodes = this.nodes.filter((node) => { + const matchesId = node.node_id?.toLowerCase()?.includes(this.searchText.toLowerCase()); + const matchesHexId = node.node_id_hex?.toLowerCase()?.includes(this.searchText.toLowerCase()); + const matchesLongName = node.long_name?.toLowerCase()?.includes(this.searchText.toLowerCase()); + const matchesShortName = node.short_name?.toLowerCase()?.includes(this.searchText.toLowerCase()); + return matchesId || matchesHexId || matchesLongName || matchesShortName; + }); + + // order alphabetically by long name + nodes.sort((nodeA, nodeB) => { + const nodeALongName = nodeA.long_name || ""; + const nodeBLongName = nodeB.long_name || ""; + return nodeALongName.localeCompare(nodeBLongName); + }); + + return nodes; + + }, + }, }).mount('#app'); @@ -974,9 +1038,15 @@ // neighboursLayerGroup.addTo(map); // legend.addTo(map); - // remove outline when map clicked + // handle map clicks map.on('click', function() { + + // remove outline when map clicked clearNodeOutline(); + + // send callback to vue + window._onMapClick(); + }); function isMobile() { @@ -1178,9 +1248,6 @@ // clear nodes cache nodes = []; - // update stats - document.getElementById("stats-label").textContent = `${updatedNodes.length} nodes`; - // add nodes for(var node of updatedNodes){ @@ -1316,6 +1383,8 @@ } + window._onNodesUpdated(nodes); + } function setLoading(loading){