diff --git a/config-example.yml b/config-example.yml index 5dc3aaf..94ded82 100644 --- a/config-example.yml +++ b/config-example.yml @@ -189,5 +189,5 @@ web-ui-options: max-spot-age-default: 30 alert-count: [25, 50, 100, 200, 500] alert-count-default: 100 - default-color-scheme: "auto" - default-band-color-scheme: "PSK Reporter (Adjusted)" \ No newline at end of file + color-scheme-default: "auto" + band-color-scheme-default: "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..c2419c4 100644 --- a/server/handlers/pagetemplate.py +++ b/server/handlers/pagetemplate.py @@ -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) diff --git a/templates/alerts.html b/templates/alerts.html index 57a2d69..5295f56 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -102,6 +102,9 @@
Number of Alerts

Show up to alerts

@@ -115,9 +118,9 @@

diff --git a/templates/bands.html b/templates/bands.html index 36533e8..c805e1e 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -102,6 +102,9 @@
Spot Age

Last minutes

@@ -115,14 +118,24 @@


@@ -136,6 +149,9 @@ + diff --git a/templates/map.html b/templates/map.html index 9b5b7a2..db87dbb 100644 --- a/templates/map.html +++ b/templates/map.html @@ -101,6 +101,9 @@
Spot Age

Last minutes

@@ -127,14 +130,24 @@


@@ -154,6 +167,9 @@ + diff --git a/templates/spots.html b/templates/spots.html index 8379eac..f3b582b 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -134,6 +134,9 @@
Number of Spots

Show up to spots

@@ -158,14 +161,24 @@


@@ -226,6 +239,9 @@ + diff --git a/webassets/apidocs/openapi.yml b/webassets/apidocs/openapi.yml index 08994c6..e326421 100644 --- a/webassets/apidocs/openapi.yml +++ b/webassets/apidocs/openapi.yml @@ -483,7 +483,7 @@ paths: tags: - General summary: Get enumeration options - description: Retrieves the list of options for various enumerated types, which can be found in the spots and also provided back to the API as query parameters. While these enumerated options are defined in this spec anyway, providing them in an API call allows us to define extra parameters, like the colours associated with bands, and also allows clients to set up their filters and features without having to have internal knowledge about, for example, what bands the server knows about. The call also returns a variety of other parameters that may be of use to a web UI, including the contents of the "web-ui-options" config section, which provides guidance for web UI implementations such as the built-in one on sensible configuration options such as the number of spots/alerts to retrieve, or the maximum age of spots to retrieve. + description: Retrieves the list of options for various enumerated types, which can be found in the spots and also provided back to the API as query parameters. While these enumerated options are defined in this spec anyway, providing them in an API call allows us to define extra parameters, like the colours associated with bands, and also allows clients to set up their filters and features without having to have internal knowledge about, for example, what bands the server knows about. The call also returns a variety of other parameters that may be of use to a web UI or other client. operationId: options responses: '200': @@ -535,46 +535,6 @@ paths: type: boolean description: Whether the POST /spot call, to add spots to the server directly via its API, is permitted on this server. example: true - web-ui-options: - type: object - properties: - spot-count: - type: array - description: An array of suggested "spot counts" that the web UI can retrieve from the API - items: - type: integer - example: 50 - spot-count-default: - type: integer - example: 50 - description: The suggested default "spot count" that the web UI should retrieve from the API - max-spot-age: - type: array - description: An array of suggested "maximum spot ages" that the web UI can retrieve from the API - items: - type: integer - example: 30 - max-spot-age-default: - type: integer - example: 30 - description: The suggested default "maximum spot age" that the web UI should retrieve from the API - spot-providers-enabled-by-default: - type: array - description: A list of the spot providers that should be enabled in the web UI on first load, if the user hasn't already got a localStorage setting that sets their preference. This is to allow some high-volume providers like RBN to be enabled in Spothole's back-end and displayable in the web UI if the user wants, but by default the experience will not include them. - items: - type: string - example: "POTA" - alert-count: - type: array - description: An array of suggested "alert counts" that the web UI can retrieve from the API - items: - type: integer - example: 100 - alert-count-default: - type: integer - example: 100 - description: The suggested default "alert count" that the web UI should retrieve from the API - /lookup/call: get: diff --git a/webassets/js/alerts.js b/webassets/js/alerts.js index 7716f9e..646e4c0 100644 --- a/webassets/js/alerts.js +++ b/webassets/js/alerts.js @@ -285,17 +285,6 @@ function loadOptions() { generateMultiToggleFilterCard("#dx-continent-options", "dx_continent", options["continents"]); generateMultiToggleFilterCard("#source-options", "source", options["alert_sources"]); - // Populate the Display panel - options["web-ui-options"]["alert-count"].forEach(sc => $("#alerts-to-fetch").append($('