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
This commit is contained in:
openhands 2025-11-11 17:52:32 +00:00
parent ece4952330
commit add4952e74
3 changed files with 25 additions and 6 deletions

View File

@ -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');
}
}
}

View File

@ -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...');

View File

@ -316,10 +316,18 @@ 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');
if (signalNameField && discoveryData.signal_name) {