mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-08-15 15:09:48 +00:00
chore(web_viewer): drop debug console logging from templates
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.
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -243,10 +243,10 @@
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="filter-evidence" class="form-label">Evidence</label>
|
||||
<select class="form-select" id="filter-evidence" title="Multi-byte only: build the graph solely from unique multi-byte path observations, ignoring ambiguous single-byte evidence. Neighbours only: only links this node confirmed directly by zero-hop discovery, with measured SNR.">
|
||||
<select class="form-select" id="filter-evidence" title="Multi-byte only: build the graph solely from unique multi-byte path observations, ignoring ambiguous single-byte evidence. Neighbors only: only links this node confirmed directly by zero-hop discovery, with measured SNR.">
|
||||
<option value="all">All Evidence</option>
|
||||
<option value="multibyte" selected>Multi-byte Only</option>
|
||||
<option value="neighbors">Neighbours Only</option>
|
||||
<option value="neighbors">Neighbors Only</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
@@ -297,7 +297,7 @@
|
||||
<hr style="margin: 4px 0;">
|
||||
<div class="connection-legend-item">
|
||||
<span style="display: inline-block; width: 18px; border-top: 4px solid currentColor; vertical-align: middle;"></span>
|
||||
<span>Confirmed neighbour (zero-hop)</span>
|
||||
<span>Confirmed neighbor (zero-hop)</span>
|
||||
</div>
|
||||
<div class="connection-legend-item">
|
||||
<span style="display: inline-block; width: 18px; border-top: 2px solid currentColor; vertical-align: middle;"></span>
|
||||
@@ -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()));
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user