From add4952e749093a70eb52b92800e6507f793f09e Mon Sep 17 00:00:00 2001 From: openhands Date: Tue, 11 Nov 2025 17:52:32 +0000 Subject: [PATCH] Fix JavaScript errors and auto-populate issues - Fix loadProtocolMappings reference error in dashboard.js by calling loadAllSignals() - Add debugging to populateModalFields to identify field availability issues - Ensure protocol mapping tab is activated before auto-populating from discovery - Add delay to ensure tab content is loaded before attempting auto-population --- static/dashboard.js | 6 +++++- static/discovery.js | 17 ++++++++++++----- static/protocol_mapping.js | 8 ++++++++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/static/dashboard.js b/static/dashboard.js index 46fea40..c0b447e 100644 --- a/static/dashboard.js +++ b/static/dashboard.js @@ -24,7 +24,11 @@ function showTab(tabName) { } else if (tabName === 'logs') { loadLogs(); } else if (tabName === 'protocol-mapping') { - loadProtocolMappings(); + if (typeof loadAllSignals === 'function') { + loadAllSignals(); + } else { + console.warn('loadAllSignals function not available - protocol mapping tab may not work correctly'); + } } } diff --git a/static/discovery.js b/static/discovery.js index 7c1ded4..00e12b8 100644 --- a/static/discovery.js +++ b/static/discovery.js @@ -119,19 +119,26 @@ class SimplifiedProtocolDiscovery { }; } + autoPopulateSignalForm(signalData) { console.log('Auto-populating signal form with:', signalData); - + + // Ensure protocol mapping tab is active + if (typeof showTab === 'function') { + showTab('protocol-mapping'); + } + // Use the simplified protocol mapping function if (typeof window.autoPopulateSignalForm === 'function') { - window.autoPopulateSignalForm(signalData); + // Add a small delay to ensure the tab is loaded + setTimeout(() => { + window.autoPopulateSignalForm(signalData); + }, 100); } else { console.error('Simplified protocol mapping functions not loaded'); this.showNotification('Protocol mapping system not available', 'error'); } - } - - // Start discovery scan + } // Start discovery scan async startDiscoveryScan() { console.log('Starting discovery scan...'); diff --git a/static/protocol_mapping.js b/static/protocol_mapping.js index d057cd9..676329c 100644 --- a/static/protocol_mapping.js +++ b/static/protocol_mapping.js @@ -316,9 +316,17 @@ function populateModalFields(discoveryData) { if (signalModal && signalModal.style.display === 'none') { signalModal.style.display = 'block'; + console.log('✓ Opened signal modal'); } else if (mappingModal && mappingModal.style.display === 'none') { mappingModal.style.display = 'block'; + console.log('✓ Opened mapping modal'); } + + // Debug: Check if fields exist + console.log('Available fields:'); + console.log('- protocol_type:', document.getElementById('protocol_type')); + console.log('- protocol_address:', document.getElementById('protocol_address')); + console.log('- db_source:', document.getElementById('db_source')); // Populate signal name (try different field names) const signalNameField = document.getElementById('signal_name') || document.getElementById('mapping_id');