fix: Resolve light/dark theme issues across dashboards and settings

- Add missing setThemePreference() and setAnimationsEnabled() functions
  to settings-manager.js; sync theme/animations dropdowns in _updateUI
- Fix base.html toggleTheme() saving to wrong localStorage key ('theme'
  instead of 'intercept-theme'), causing theme not to persist in ADS-B
  and AIS dashboards; also sync button icon and persist to server
- Add [data-theme="light"] CSS variable overrides to adsb_dashboard.css
  and ais_dashboard.css so the dashboards respond to light theme
- Fix GPS sky view canvas (gps.js) to read grid/label colours from CSS
  variables instead of hardcoded dark hex values; add MutationObserver
  to redraw immediately on theme change
- Fix satellite_dashboard.html polar plot functions to read background,
  accent and text colours from CSS variables

Closes #139

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-02-18 13:58:49 +00:00
parent 4df112e712
commit 6c6cd8a280
6 changed files with 163 additions and 34 deletions

View File

@@ -323,6 +323,18 @@ const Settings = {
if (customRow) {
customRow.style.display = this.get('offline.tile_provider') === 'custom' ? 'block' : 'none';
}
// Theme select
const themeSelect = document.getElementById('themeSelect');
if (themeSelect) {
themeSelect.value = localStorage.getItem('intercept-theme') || 'dark';
}
// Animations toggle
const animationsEnabled = document.getElementById('animationsEnabled');
if (animationsEnabled) {
animationsEnabled.checked = localStorage.getItem('intercept-animations') !== 'off';
}
},
/**
@@ -983,3 +995,34 @@ function toggleApiKeyVisibility() {
if (!input) return;
input.type = input.type === 'password' ? 'text' : 'password';
}
/**
* Set theme preference from the Display settings tab
*/
function setThemePreference(value) {
document.documentElement.setAttribute('data-theme', value);
localStorage.setItem('intercept-theme', value);
const btn = document.getElementById('themeToggle');
if (btn) {
btn.textContent = value === 'light' ? '🌙' : '☀️';
}
fetch('/settings', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ theme: value })
}).catch(() => {});
}
/**
* Set animations preference from the Display settings tab
*/
function setAnimationsEnabled(enabled) {
if (enabled) {
document.documentElement.removeAttribute('data-animations');
} else {
document.documentElement.setAttribute('data-animations', 'off');
}
localStorage.setItem('intercept-animations', enabled ? 'on' : 'off');
}