Make default colour schemes for the web UI configurable on the server side #102

This commit is contained in:
Ian Renton
2026-01-30 21:31:13 +00:00
parent 221fade44b
commit 2be1c5b3d3
14 changed files with 53 additions and 28 deletions

View File

@@ -291,6 +291,10 @@ function loadOptions() {
text: sc
})));
$("#alerts-to-fetch").val(options["web-ui-options"]["alert-count-default"]);
if ($("#color-scheme option:selected").val() == "") {
$("#color-scheme").val(options["web-ui-options"]["default-color-scheme"]);
setColorScheme(options["web-ui-options"]["default-color-scheme"]);
}
// Load URL params. These may select things from the various filter & display options, so the function needs
// to be called after these are set up, but if the URL params ask for "embedded mode", this will suppress

View File

@@ -238,6 +238,11 @@ function loadOptions() {
value: sc,
text: sc
})));
$("#band-color-scheme").val(options["web-ui-options"]["default-band-color-scheme"]);
if ($("#color-scheme option:selected").val() == "") {
$("#color-scheme").val(options["web-ui-options"]["default-color-scheme"]);
setColorScheme(options["web-ui-options"]["default-color-scheme"]);
}
// First pass loading settings, so we can load the band colour scheme before the filters that need to use it
loadSettings();

View File

@@ -144,8 +144,11 @@ function columnsUpdated() {
// Function to set the colour scheme based on the state of the UI select box
function setColorSchemeFromUI() {
setColorScheme($("#color-scheme option:selected").val());
saveSettings();
let theme = $("#color-scheme option:selected").val();
if (theme != "") {
setColorScheme(theme);
saveSettings();
}
}
// Function to set the color scheme. Supported values: "dark", "light", "auto"
@@ -164,7 +167,8 @@ function setColorScheme(mode) {
// Startup function to determine whether to use light or dark mode, or leave as auto
function usePreferredTheme() {
// Work out if we have ever explicitly saved the value of our select box. If so, we set our colour scheme now based
// on that. If not, we let the select retain its default value of "auto".
// on that. If not, we let the select stay with nothing selected, so that the server sets it to whatever the
// server's default is when the options call is retrieved.
let val = localStorage.getItem("#color-scheme:value");
if (val != null) {
setColorScheme(JSON.parse(val));

View File

@@ -170,6 +170,11 @@ function loadOptions() {
value: sc,
text: sc
})));
$("#band-color-scheme").val(options["web-ui-options"]["default-band-color-scheme"]);
if ($("#color-scheme option:selected").val() == "") {
$("#color-scheme").val(options["web-ui-options"]["default-color-scheme"]);
setColorScheme(options["web-ui-options"]["default-color-scheme"]);
}
// First pass loading settings, so we can load the band colour scheme before the filters that need to use it
loadSettings();

View File

@@ -396,6 +396,11 @@ function loadOptions() {
value: sc,
text: sc
})));
$("#band-color-scheme").val(options["web-ui-options"]["default-band-color-scheme"]);
if ($("#color-scheme option:selected").val() == "") {
$("#color-scheme").val(options["web-ui-options"]["default-color-scheme"]);
setColorScheme(options["web-ui-options"]["default-color-scheme"]);
}
// First pass loading settings, so we can load the band colour scheme before the filters that need to use it
loadSettings();