diff --git a/config-example.yml b/config-example.yml index bb6e73e..5d65d6f 100644 --- a/config-example.yml +++ b/config-example.yml @@ -90,15 +90,22 @@ spot-providers: name: "RBN CW/RTTY" enabled: false port: 7000 + # This setting doesn't affect the spot provider itself, or anything in the back-end of Spothole, just the web UI. + # By default spots from all enabled providers will be shown in the web UI. However, you might want RBN data to be + # received by Spothole but not shown on the web UI unless the user explicitly turns it on. For that behaviour, + # set enabled to true, but enabled-by-default-in-web-ui to false. + enabled-by-default-in-web-ui: false - class: "RBN" name: "RBN FT8" enabled: false port: 7001 + enabled-by-default-in-web-ui: false - class: "UKPacketNet" name: "UK Packet Radio Net" enabled: false + enabled-by-default-in-web-ui: false - class: "XOTA" name: "39C3 TOTA" diff --git a/core/config.py b/core/config.py index 3af6c22..77f4871 100644 --- a/core/config.py +++ b/core/config.py @@ -5,7 +5,8 @@ import yaml # Check you have a config file if not os.path.isfile("config.yml"): - logging.error("Your config file is missing. Ensure you have copied config-example.yml to config.yml and updated it according to your needs.") + logging.error( + "Your config file is missing. Ensure you have copied config-example.yml to config.yml and updated it according to your needs.") exit() # Load config @@ -17,4 +18,9 @@ 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"] -WEB_UI_OPTIONS = config["web-ui-options"] \ No newline at end of file +WEB_UI_OPTIONS = config["web-ui-options"] + +# For ease of config, each spot provider owns its own config about whether it should be enabled by default in the web UI +# 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)] diff --git a/server/handlers/api/options.py b/server/handlers/api/options.py index a7a5084..d106a1f 100644 --- a/server/handlers/api/options.py +++ b/server/handlers/api/options.py @@ -40,6 +40,7 @@ class APIOptionsHandler(tornado.web.RequestHandler): # 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/webassets/.idea/.gitignore b/webassets/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/webassets/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/webassets/.idea/vcs.xml b/webassets/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/webassets/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/webassets/apidocs/openapi.yml b/webassets/apidocs/openapi.yml index 3e0771b..ad9979c 100644 --- a/webassets/apidocs/openapi.yml +++ b/webassets/apidocs/openapi.yml @@ -1,4 +1,4 @@ -openapi: 3.0.4 +openapi: 3.1.0 info: title: Spothole API description: |- @@ -557,6 +557,12 @@ paths: 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 diff --git a/webassets/js/bands.js b/webassets/js/bands.js index 8cf97c5..c3730f4 100644 --- a/webassets/js/bands.js +++ b/webassets/js/bands.js @@ -252,7 +252,7 @@ function loadOptions() { generateMultiToggleFilterCard("#dx-continent-options", "dx_continent", options["continents"]); generateMultiToggleFilterCard("#de-continent-options", "de_continent", options["continents"]); generateMultiToggleFilterCard("#mode-options", "mode_type", options["mode_types"]); - generateMultiToggleFilterCard("#source-options", "source", options["spot_sources"]); + generateSourcesMultiToggleFilterCard(options["spot_sources"], options["web-ui-options"]["spot-providers-enabled-by-default"]); // 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 diff --git a/webassets/js/map.js b/webassets/js/map.js index 67911c0..aa10f9d 100644 --- a/webassets/js/map.js +++ b/webassets/js/map.js @@ -184,7 +184,7 @@ function loadOptions() { generateMultiToggleFilterCard("#dx-continent-options", "dx_continent", options["continents"]); generateMultiToggleFilterCard("#de-continent-options", "de_continent", options["continents"]); generateMultiToggleFilterCard("#mode-options", "mode_type", options["mode_types"]); - generateMultiToggleFilterCard("#source-options", "source", options["spot_sources"]); + generateSourcesMultiToggleFilterCard(options["spot_sources"], options["web-ui-options"]["spot-providers-enabled-by-default"]); // 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 diff --git a/webassets/js/spots.js b/webassets/js/spots.js index c5c4b34..8ac14c3 100644 --- a/webassets/js/spots.js +++ b/webassets/js/spots.js @@ -422,7 +422,7 @@ function loadOptions() { generateMultiToggleFilterCard("#dx-continent-options", "dx_continent", options["continents"]); generateMultiToggleFilterCard("#de-continent-options", "de_continent", options["continents"]); generateMultiToggleFilterCard("#mode-options", "mode_type", options["mode_types"]); - generateMultiToggleFilterCard("#source-options", "source", options["spot_sources"]); + generateSourcesMultiToggleFilterCard(options["spot_sources"], options["web-ui-options"]["spot-providers-enabled-by-default"]); // 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 diff --git a/webassets/js/spotsbandsandmap.js b/webassets/js/spotsbandsandmap.js index cbbb195..3a79546 100644 --- a/webassets/js/spotsbandsandmap.js +++ b/webassets/js/spotsbandsandmap.js @@ -6,10 +6,9 @@ var spots = [] function addBandToggleColourCSS(band_options) { var $style = $('