diff --git a/config-example.yml b/config-example.yml index c0ef473..50bb9e9 100644 --- a/config-example.yml +++ b/config-example.yml @@ -135,4 +135,13 @@ hamqth-password: "" clublog-api-key: "" # Allow submitting spots to the Spothole API? -allow-spotting: true \ No newline at end of file +allow-spotting: true + +# Options for the web UI. +web-ui-options: + spot-count: [10, 25, 50, 100] + spot-count-default: 50 + 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 diff --git a/core/config.py b/core/config.py index 6cb0ad6..3af6c22 100644 --- a/core/config.py +++ b/core/config.py @@ -16,4 +16,5 @@ MAX_SPOT_AGE = config["max-spot-age-sec"] MAX_ALERT_AGE = config["max-alert-age-sec"] SERVER_OWNER_CALLSIGN = config["server-owner-callsign"] WEB_SERVER_PORT = config["web-server-port"] -ALLOW_SPOTTING = config["allow-spotting"] \ No newline at end of file +ALLOW_SPOTTING = config["allow-spotting"] +WEB_UI_OPTIONS = config["web-ui-options"] \ No newline at end of file diff --git a/server/webserver.py b/server/webserver.py index a95b424..b52fde4 100644 --- a/server/webserver.py +++ b/server/webserver.py @@ -8,7 +8,7 @@ import bottle import pytz from bottle import run, request, response, template -from core.config import MAX_SPOT_AGE, ALLOW_SPOTTING +from core.config import MAX_SPOT_AGE, ALLOW_SPOTTING, WEB_UI_OPTIONS from core.constants import BANDS, ALL_MODES, MODE_TYPES, SIGS, CONTINENTS, SOFTWARE_VERSION, UNKNOWN_BAND from core.lookup_helper import lookup_helper from core.prometheus_metrics_handler import page_requests_counter, get_metrics, api_requests_counter @@ -469,7 +469,8 @@ class WebServer: 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} + "spot_allowed": ALLOW_SPOTTING, + "web-ui-options": WEB_UI_OPTIONS} # 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: diff --git a/views/webpage_alerts.tpl b/views/webpage_alerts.tpl index 8012377..d1fd498 100644 --- a/views/webpage_alerts.tpl +++ b/views/webpage_alerts.tpl @@ -101,11 +101,6 @@
Show up to alerts
diff --git a/views/webpage_bands.tpl b/views/webpage_bands.tpl index d1a229e..d02410f 100644 --- a/views/webpage_bands.tpl +++ b/views/webpage_bands.tpl @@ -93,10 +93,6 @@Last minutes
diff --git a/views/webpage_map.tpl b/views/webpage_map.tpl index 5eaa094..5712ffe 100644 --- a/views/webpage_map.tpl +++ b/views/webpage_map.tpl @@ -92,10 +92,6 @@Last minutes
diff --git a/views/webpage_spots.tpl b/views/webpage_spots.tpl index 89ff1c5..2e785ae 100644 --- a/views/webpage_spots.tpl +++ b/views/webpage_spots.tpl @@ -117,10 +117,6 @@Show up to spots
diff --git a/webassets/apidocs/openapi.yml b/webassets/apidocs/openapi.yml index 1e53798..bedca5b 100644 --- a/webassets/apidocs/openapi.yml +++ b/webassets/apidocs/openapi.yml @@ -438,7 +438,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. + 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. operationId: options responses: '200': @@ -490,6 +490,39 @@ 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 + 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: diff --git a/webassets/js/alerts.js b/webassets/js/alerts.js index f995326..4f587e4 100644 --- a/webassets/js/alerts.js +++ b/webassets/js/alerts.js @@ -285,6 +285,13 @@ 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($('