From 1fb0dbb72b0adb08db2aced322a7b71093bfe3dd Mon Sep 17 00:00:00 2001 From: agessaman Date: Fri, 7 Aug 2026 13:44:31 -0700 Subject: [PATCH] chore(web_viewer): drop debug console logging from templates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removes 26 console.log calls, including contacts.html dumping whole data structures and sample contact records on every render. Variables and callback parameters that existed only to feed those logs go with them (deviceTypes, anyNewDevices, an availableEdges debug block, and a realtime status handler whose body was nothing but a log), so no new no-unused-vars warnings are introduced — the count drops 60 to 59. console.warn and console.error are kept. One console.log survives in realtime.html: the decoder key-count line is a one-time startup message with real diagnostic value, and removing it would mean deleting two counters and their increments inside a loop. Also normalizes the mesh page's user-visible "Neighbours" strings to match the project's American spelling. The option value stays "neighbors", so evidence-mode filtering is untouched. --- modules/web_viewer/templates/base.html | 6 +--- modules/web_viewer/templates/contacts.html | 29 -------------------- modules/web_viewer/templates/mesh.html | 32 +++++----------------- modules/web_viewer/templates/realtime.html | 14 ++-------- 4 files changed, 10 insertions(+), 71 deletions(-) diff --git a/modules/web_viewer/templates/base.html b/modules/web_viewer/templates/base.html index 3445a38..8b6145c 100644 --- a/modules/web_viewer/templates/base.html +++ b/modules/web_viewer/templates/base.html @@ -727,21 +727,18 @@ setupSocketEvents() { this.socket.on('connect', () => { - console.log('Connected to server'); this.connected = true; this.updateConnectionStatus('Connected', 'connected'); this.lastActivity = new Date(); this.updateLastActivity(); }); - this.socket.on('disconnect', (reason) => { - console.log('Disconnected from server:', reason); + this.socket.on('disconnect', () => { this.connected = false; this.updateConnectionStatus('Disconnected', 'disconnected'); }); this.socket.on('status', (data) => { - console.log('Server status:', data.message); this.showNotification(data.message, 'info'); }); @@ -752,7 +749,6 @@ // Modern ping/pong pattern this.socket.on('pong', () => { - console.log('Pong received from server'); this.lastActivity = new Date(); this.updateLastActivity(); }); diff --git a/modules/web_viewer/templates/contacts.html b/modules/web_viewer/templates/contacts.html index f1c4bec..2bf32c3 100644 --- a/modules/web_viewer/templates/contacts.html +++ b/modules/web_viewer/templates/contacts.html @@ -1136,8 +1136,6 @@ class ModernContactsManager { // Try to get server-provided daily stats first const serverStats = this.contactsData.server_stats || {}; - console.log('Contacts data structure:', typeof this.contactsData, 'has server_stats:', 'server_stats' in this.contactsData); - console.log('Server stats received:', serverStats); const adverts24h = (serverStats.advertisements_24h !== undefined) ? serverStats.advertisements_24h : this.filteredData.filter(contact => { const lastSeen = new Date(contact.last_seen); const now = new Date(); @@ -1153,29 +1151,7 @@ class ModernContactsManager { const advertsAll = (serverStats.total_advertisements !== undefined) ? serverStats.total_advertisements : this.filteredData.reduce((sum, contact) => sum + (contact.advert_count || 0), 0); - console.log('Final advertisement counts:', { - '24h': adverts24h, - '7d': adverts7d, - 'All': advertsAll, - 'using_server_stats': (serverStats.advertisements_24h !== undefined) && - (serverStats.advertisements_7d !== undefined) && - (serverStats.total_advertisements !== undefined) - }); - // Calculate new device metrics (devices first seen in the last 7 days) - // Debug: Log device types to see what we're working with - const deviceTypes = [...new Set(this.filteredData.map(contact => contact.device_type))]; - console.log('Available device types:', deviceTypes); - console.log('Sample contact data:', this.filteredData[0]); - - // Also check for any devices first heard in the last week regardless of type - const anyNewDevices = this.filteredData.filter(contact => { - const firstHeard = new Date(contact.first_heard); - return firstHeard >= oneWeekAgo; - }); - console.log('Any new devices in last week:', anyNewDevices.length); - console.log('Sample new device:', anyNewDevices[0]); - // Try different possible device type values const newCompanions = this.filteredStats.new_companions ?? this.filteredData.filter(contact => { const firstHeard = new Date(contact.first_heard); @@ -1209,11 +1185,6 @@ class ModernContactsManager { ); }).length; - // Debug: Log the counts - console.log('New companions:', newCompanions); - console.log('New repeaters:', newRepeaters); - console.log('New room servers:', newRoomServers); - // Update contact metrics document.getElementById('contacts-24h').textContent = contacts24h; document.getElementById('contacts-7d').textContent = contacts7d; diff --git a/modules/web_viewer/templates/mesh.html b/modules/web_viewer/templates/mesh.html index 6057287..b97563e 100644 --- a/modules/web_viewer/templates/mesh.html +++ b/modules/web_viewer/templates/mesh.html @@ -243,10 +243,10 @@
- - +
@@ -297,7 +297,7 @@
- Confirmed neighbour (zero-hop) + Confirmed neighbor (zero-hop)
@@ -759,7 +759,7 @@ function getEvidenceLabel(edge) { if (edge.evidence === 'neighbors') { const snr = formatSnr(edge.snr); - return snr ? `Confirmed neighbour (avg SNR ${snr})` : 'Confirmed neighbour (zero-hop)'; + return snr ? `Confirmed neighbor (avg SNR ${snr})` : 'Confirmed neighbor (zero-hop)'; } if (edge.evidence === 'multibyte') { return edge.path_count @@ -957,8 +957,8 @@ function getHomeComponentBounds() { if (!botLocation) return null; // Every evidence mode tags its edges, so this works in "All Evidence" too. - // Confirmed neighbours count as trusted (they are measured, not inferred), - // and are the only tagged edges present in "Neighbours Only" mode. + // Confirmed neighbors count as trusted (they are measured, not inferred), + // and are the only tagged edges present in "Neighbors Only" mode. const mbEdges = filteredEdges.filter( e => e.evidence === 'multibyte' || e.evidence === 'neighbors' ); @@ -1212,8 +1212,6 @@ return; } - console.log(`Highlighting path with ${pathRepeaters.length} repeaters:`, pathRepeaters.map(r => r.node_id)); - // Highlight edges between consecutive nodes in the path // Need to match the edgeKey format used when storing edges: `${edge.from_prefix}-${edge.to_prefix}` const pathEdgeKeys = new Set(); @@ -1257,25 +1255,11 @@ // Normalize to lowercase to match how edges are stored const edgeKey = `${edge.from_prefix.toLowerCase()}-${edge.to_prefix.toLowerCase()}`; pathEdgeKeys.add(edgeKey); - console.log(`Found edge for path segment ${fromRepeater.node_id}->${toRepeater.node_id}: ${edgeKey} (edge stored as ${edge.from_prefix}->${edge.to_prefix})`); } else { console.warn(`No edge found for path segment ${fromRepeater.node_id}->${toRepeater.node_id}`); - // Log available edges for debugging - const availableEdges = filteredEdges.filter(e => { - const eFrom = e.from_prefix.toUpperCase(); - const eTo = e.to_prefix.toUpperCase(); - return (eFrom === fromPrefix || eTo === fromPrefix || eFrom === toPrefix || eTo === toPrefix); - }); - if (availableEdges.length > 0) { - console.log(`Available edges with these prefixes:`, availableEdges.map(e => `${e.from_prefix}->${e.to_prefix}`)); - } else { - console.log(`No edges found with prefixes ${fromPrefix} or ${toPrefix} in filteredEdges (total: ${filteredEdges.length})`); - } } } - - console.log(`Path edge keys to highlight:`, Array.from(pathEdgeKeys)); - + // First, store original styles for ALL edges if not already stored edgeLines.forEach((line, edgeKey) => { if (!allEdgeStyles.has(edgeKey)) { @@ -1287,8 +1271,6 @@ } }); - console.log(`Total edges on map: ${edgeLines.size}, Path edges to highlight: ${pathEdgeKeys.size}`); - // Normalize path edge keys to lowercase for matching const normalizedPathEdgeKeys = new Set(); pathEdgeKeys.forEach(key => normalizedPathEdgeKeys.add(key.toLowerCase())); diff --git a/modules/web_viewer/templates/realtime.html b/modules/web_viewer/templates/realtime.html index d173b7d..2c29657 100644 --- a/modules/web_viewer/templates/realtime.html +++ b/modules/web_viewer/templates/realtime.html @@ -1002,8 +1002,6 @@ .then(response => response.json()) .then(data => { if (data.commands && data.commands.length > 0) { - console.log(`Loading ${data.commands.length} recent commands`); - // Clear the waiting message const container = document.getElementById('command-stream'); const waiting = container.querySelector('.text-muted.text-center'); @@ -1026,7 +1024,6 @@ // Socket event handlers socket.on('connect', function() { - console.log('Connected to server'); updateStatus('command-status', 'Connected', 'success'); updateStatus('packet-status', 'Connected', 'success'); updateStatus('message-status', 'Connected', 'success'); @@ -1045,7 +1042,6 @@ }); socket.on('disconnect', function() { - console.log('Disconnected from server'); updateStatus('command-status', 'Disconnected', 'danger'); updateStatus('packet-status', 'Disconnected', 'danger'); updateStatus('message-status', 'Disconnected', 'danger'); @@ -1054,8 +1050,7 @@ stopPingInterval(); }); - socket.on('force_disconnect', function(data) { - console.log('Server requested disconnect:', data.reason); + socket.on('force_disconnect', function() { updateStatus('command-status', 'Disconnected by server', 'warning'); updateStatus('packet-status', 'Disconnected by server', 'warning'); // Disconnect the socket @@ -1068,10 +1063,6 @@ updateStatus('packet-status', 'Error', 'danger'); }); - socket.on('status', function(data) { - console.log('Status:', data.message); - }); - socket.on('command_data', function(data) { addCommandEntry(data); }); @@ -1318,8 +1309,7 @@ } } - socket.on('pong', function(data) { - console.log('Pong received from server'); + socket.on('pong', function() { // Connection is alive, update status updateStatus('command-status', 'Connected', 'success'); updateStatus('packet-status', 'Connected', 'success');