Set up web UI using web_ui_options embedded directly into HTML, to avoid more complex JS load order faff #102

This commit is contained in:
Ian Renton
2026-01-30 22:24:12 +00:00
parent 2be1c5b3d3
commit 5230fa535f
13 changed files with 81 additions and 122 deletions

View File

@@ -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)

View File

@@ -3,7 +3,7 @@ from datetime import datetime
import pytz
import tornado
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 +22,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=WEB_UI_OPTIONS)