diff --git a/server/index.js b/server/index.js index 29050bfec..158c6bdc2 100644 --- a/server/index.js +++ b/server/index.js @@ -734,17 +734,37 @@ app.get('/api/version', async (req, res) => { const packageJson = require('../package.json'); const currentVersion = packageJson.version || 'N/A'; - // Use UpdateManager to check for updates respecting user's channel preference - const updateInfo = await updateManager.checkForUpdates(); + let latestVersion = currentVersion; + let updateAvailable = false; + + try { + // Try to check for updates, but don't fail if it doesn't work + const updateInfo = await updateManager.checkForUpdates(); + latestVersion = updateInfo.latestVersion || currentVersion; + updateAvailable = updateInfo.hasUpdate || false; + } catch (updateError) { + // Log the error but continue with current version info + console.error("[Version API] Error checking for updates:", updateError.message); + } res.json({ version: currentVersion, - latestVersion: updateInfo.latestVersion, - updateAvailable: updateInfo.hasUpdate + latestVersion: latestVersion, + updateAvailable: updateAvailable }); } catch (error) { - console.error("Error in version endpoint:", error); - res.status(500).json({ error: "Could not retrieve version" }); + console.error("[Version API] Error in version endpoint:", error); + // Still try to return current version if possible + try { + const packageJson = require('../package.json'); + res.json({ + version: packageJson.version || 'N/A', + latestVersion: packageJson.version || 'N/A', + updateAvailable: false + }); + } catch (fallbackError) { + res.status(500).json({ error: "Could not retrieve version" }); + } } }); diff --git a/src/public/js/debug-toggles.js b/src/public/js/debug-toggles.js new file mode 100644 index 000000000..0f25b3467 --- /dev/null +++ b/src/public/js/debug-toggles.js @@ -0,0 +1,93 @@ +// Debug function for notification toggles +// Copy and paste this into the browser console when the alert modal is open + +function debugToggles() { + console.log('=== Toggle Debug Info ==='); + + // Check if modal is open + const modal = document.getElementById('alert-management-modal'); + console.log('Modal found:', !!modal); + console.log('Modal visible:', modal && !modal.classList.contains('hidden')); + + // Check active tab + const activeTab = document.querySelector('.alert-tab.active'); + console.log('Active tab:', activeTab ? activeTab.getAttribute('data-tab') : 'none'); + + // Check toggle elements + const emailToggle = document.getElementById('global-email-toggle'); + const webhookToggle = document.getElementById('global-webhook-toggle'); + + console.log('\n--- Toggle Elements ---'); + console.log('Email toggle found:', !!emailToggle); + if (emailToggle) { + console.log('Email toggle checked:', emailToggle.checked); + console.log('Email toggle disabled:', emailToggle.disabled); + console.log('Email toggle parent:', emailToggle.parentElement); + } + + console.log('\nWebhook toggle found:', !!webhookToggle); + if (webhookToggle) { + console.log('Webhook toggle checked:', webhookToggle.checked); + console.log('Webhook toggle disabled:', webhookToggle.disabled); + console.log('Webhook toggle parent:', webhookToggle.parentElement); + } + + // Check config sections + const emailSection = document.getElementById('email-config-section'); + const webhookSection = document.getElementById('webhook-config-section'); + + console.log('\n--- Config Sections ---'); + console.log('Email section found:', !!emailSection); + if (emailSection) { + console.log('Email section opacity:', emailSection.style.opacity); + console.log('Email section inputs:', emailSection.querySelectorAll('input').length); + } + + console.log('\nWebhook section found:', !!webhookSection); + if (webhookSection) { + console.log('Webhook section opacity:', webhookSection.style.opacity); + console.log('Webhook section inputs:', webhookSection.querySelectorAll('input').length); + } + + // Check current config + console.log('\n--- Current Config ---'); + if (window.PulseApp && window.PulseApp.ui && window.PulseApp.ui.alertManagementModal) { + console.log('PulseApp.ui.alertManagementModal available'); + } + + // Test toggle click + console.log('\n--- Testing Toggle Click ---'); + if (emailToggle) { + console.log('Simulating email toggle click...'); + const event = new Event('change', { bubbles: true }); + emailToggle.checked = !emailToggle.checked; + emailToggle.dispatchEvent(event); + } +} + +// Run the debug function +debugToggles(); + +// Additional helper to manually trigger toggle setup +function manualSetupToggles() { + if (window.PulseApp && window.PulseApp.ui && window.PulseApp.ui.alertManagementModal) { + // Try to access the setupNotificationToggles function if it's exposed + console.log('Attempting manual toggle setup...'); + + // Manually recreate the setup logic + const emailToggle = document.getElementById('global-email-toggle'); + const webhookToggle = document.getElementById('global-webhook-toggle'); + + if (emailToggle) { + emailToggle.addEventListener('change', (e) => { + console.log('[Manual] Email toggle changed to:', e.target.checked); + }); + } + + if (webhookToggle) { + webhookToggle.addEventListener('change', (e) => { + console.log('[Manual] Webhook toggle changed to:', e.target.checked); + }); + } + } +} \ No newline at end of file diff --git a/src/public/js/ui/alertManagementModal.js b/src/public/js/ui/alertManagementModal.js index 8b843cb67..f566f652c 100644 --- a/src/public/js/ui/alertManagementModal.js +++ b/src/public/js/ui/alertManagementModal.js @@ -165,7 +165,13 @@ PulseApp.ui.alertManagementModal = (() => { openAlertRuleModal, editAlertRule, toggleAlertRule, - deleteAlertRule + deleteAlertRule, + // Debug functions + debugToggles: () => { + console.log('Email toggle:', document.getElementById('global-email-toggle')); + console.log('Webhook toggle:', document.getElementById('global-webhook-toggle')); + setupNotificationToggles(); + } }; Object.entries(functions).forEach(([name, func]) => { @@ -574,20 +580,20 @@ PulseApp.ui.alertManagementModal = (() => {
Master switches for all alert notifications
Open the browser console and run: debugToggles()
Or add this to the alertManagementModal.js temporarily to debug
+ + \ No newline at end of file