From 6ed0eed10bc9869ddb9800d6e32324772a466403 Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Fri, 30 Jan 2026 20:56:18 +0000 Subject: [PATCH] Web UI options faff --- config-example.yml | 4 +++- core/config.py | 4 ++++ server/handlers/api/options.py | 4 +--- server/handlers/pagetemplate.py | 6 ++++-- templates/about.html | 2 +- templates/add_spot.html | 4 ++-- templates/alerts.html | 6 +++--- templates/bands.html | 8 ++++---- templates/base.html | 12 ++++++++---- templates/map.html | 12 ++++++------ templates/spots.html | 8 ++++---- templates/status.html | 4 ++-- webassets/js/alerts.js | 4 ++-- webassets/js/bands.js | 7 ++++--- webassets/js/common.js | 7 ++++++- webassets/js/map.js | 7 ++++--- webassets/js/spots.js | 10 ++++++---- 17 files changed, 64 insertions(+), 45 deletions(-) diff --git a/config-example.yml b/config-example.yml index cff388d..5dc3aaf 100644 --- a/config-example.yml +++ b/config-example.yml @@ -188,4 +188,6 @@ web-ui-options: max-spot-age: [5, 10, 30, 60] max-spot-age-default: 30 alert-count: [25, 50, 100, 200, 500] - alert-count-default: 100 \ No newline at end of file + alert-count-default: 100 + default-color-scheme: "auto" + default-band-color-scheme: "PSK Reporter (Adjusted)" \ No newline at end of file diff --git a/core/config.py b/core/config.py index 77f4871..17b9dd7 100644 --- a/core/config.py +++ b/core/config.py @@ -24,3 +24,7 @@ WEB_UI_OPTIONS = config["web-ui-options"] # but for consistency we provide this to the front-end in web-ui-options because it has no impact outside of the web UI. WEB_UI_OPTIONS["spot-providers-enabled-by-default"] = [p["name"] for p in config["spot-providers"] if p["enabled"] and ( "enabled-by-default-in-web-ui" not in p or p["enabled-by-default-in-web-ui"] == True)] +# If spotting to this server is enabled, "API" is another valid spot source even though it does not come from +# one of our proviers. We set that to also be enabled by default. +if ALLOW_SPOTTING: + WEB_UI_OPTIONS["spot-providers-enabled-by-default"].append("API") diff --git a/server/handlers/api/options.py b/server/handlers/api/options.py index d106a1f..cbbe97a 100644 --- a/server/handlers/api/options.py +++ b/server/handlers/api/options.py @@ -34,13 +34,11 @@ class APIOptionsHandler(tornado.web.RequestHandler): map(lambda p: p["name"], filter(lambda p: p["enabled"], self.status_data["alert_providers"]))), "continents": CONTINENTS, "max_spot_age": MAX_SPOT_AGE, - "spot_allowed": ALLOW_SPOTTING, - "web-ui-options": WEB_UI_OPTIONS} + "spot_allowed": ALLOW_SPOTTING} # If spotting to this server is enabled, "API" is another valid spot source even though it does not come from # one of our proviers. if ALLOW_SPOTTING: options["spot_sources"].append("API") - options["web-ui-options"]["spot-providers-enabled-by-default"].append("API") self.write(json.dumps(options, default=serialize_everything)) self.set_status(200) diff --git a/server/handlers/pagetemplate.py b/server/handlers/pagetemplate.py index c1c9751..3de9080 100644 --- a/server/handlers/pagetemplate.py +++ b/server/handlers/pagetemplate.py @@ -2,8 +2,9 @@ from datetime import datetime import pytz import tornado +import json -from core.config import ALLOW_SPOTTING +from core.config import ALLOW_SPOTTING, WEB_UI_OPTIONS from core.constants import SOFTWARE_VERSION from core.prometheus_metrics_handler import page_requests_counter @@ -22,5 +23,6 @@ class PageTemplateHandler(tornado.web.RequestHandler): page_requests_counter.inc() # Load named template, and provide variables used in templates - self.render(self.template_name + ".html", software_version=SOFTWARE_VERSION, allow_spotting=ALLOW_SPOTTING) + self.render(self.template_name + ".html", software_version=SOFTWARE_VERSION, allow_spotting=ALLOW_SPOTTING, + web_ui_options=json.dumps(WEB_UI_OPTIONS)) diff --git a/templates/about.html b/templates/about.html index 3efbc39..8531b4f 100644 --- a/templates/about.html +++ b/templates/about.html @@ -63,7 +63,7 @@

This software is dedicated to the memory of Tom G1PJB, SK, a friend and colleague who sadly passed away around the time I started writing it in Autumn 2025. I was looking forward to showing it to you when it was done.

- + {% end %} \ No newline at end of file diff --git a/templates/add_spot.html b/templates/add_spot.html index 5a9c281..c95d720 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -69,8 +69,8 @@ - - + + {% end %} \ No newline at end of file diff --git a/templates/alerts.html b/templates/alerts.html index fb24224..57a2d69 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -115,7 +115,7 @@

@@ -170,8 +170,8 @@ - - + + {% end %} \ No newline at end of file diff --git a/templates/bands.html b/templates/bands.html index 630bd36..36533e8 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -115,7 +115,7 @@

@@ -136,9 +136,9 @@ - - - + + + {% end %} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index b51e85e..e5d1537 100644 --- a/templates/base.html +++ b/templates/base.html @@ -46,10 +46,14 @@ crossorigin="anonymous"> - - - - + + + + + diff --git a/templates/map.html b/templates/map.html index 07de81f..e5d6302 100644 --- a/templates/map.html +++ b/templates/map.html @@ -127,9 +127,9 @@

@@ -154,9 +154,9 @@ - - - + + + {% end %} \ No newline at end of file diff --git a/templates/spots.html b/templates/spots.html index 1ad3673..8379eac 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -158,7 +158,7 @@

@@ -226,9 +226,9 @@ - - - + + + {% end %} \ No newline at end of file diff --git a/templates/status.html b/templates/status.html index 9ecb6d7..821eb64 100644 --- a/templates/status.html +++ b/templates/status.html @@ -3,8 +3,8 @@

- - + + {% end %} \ No newline at end of file diff --git a/webassets/js/alerts.js b/webassets/js/alerts.js index 3d3d0cd..4bb67f2 100644 --- a/webassets/js/alerts.js +++ b/webassets/js/alerts.js @@ -286,11 +286,11 @@ function loadOptions() { generateMultiToggleFilterCard("#source-options", "source", options["alert_sources"]); // Populate the Display panel - options["web-ui-options"]["alert-count"].forEach(sc => $("#alerts-to-fetch").append($('