mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-02-04 01:04:33 +00:00
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:
@@ -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:
|
||||
|
||||
@@ -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($('<option>', {
|
||||
value: sc,
|
||||
text: sc
|
||||
})));
|
||||
$("#alerts-to-fetch").val(options["web-ui-options"]["alert-count-default"]);
|
||||
if ($("#color-scheme option:selected").val() == "") {
|
||||
$("#color-scheme").val(options["web-ui-options"]["default-color-scheme"]);
|
||||
setColorScheme(options["web-ui-options"]["default-color-scheme"]);
|
||||
}
|
||||
|
||||
// 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
|
||||
// loading settings, so this needs to be called before that.
|
||||
@@ -303,6 +292,7 @@ function loadOptions() {
|
||||
|
||||
// Load filters from settings storage
|
||||
loadSettings();
|
||||
setColorScheme($("#color-scheme option:selected").val());
|
||||
|
||||
// Load alerts and set up the timer
|
||||
loadAlerts();
|
||||
|
||||
@@ -228,24 +228,9 @@ function loadOptions() {
|
||||
// Store options
|
||||
options = jsonData;
|
||||
|
||||
// Populate the Display panel
|
||||
options["web-ui-options"]["max-spot-age"].forEach(sc => $("#max-spot-age").append($('<option>', {
|
||||
value: sc * 60,
|
||||
text: sc
|
||||
})));
|
||||
$("#max-spot-age").val(options["web-ui-options"]["max-spot-age-default"] * 60);
|
||||
getAvailableBandColorSchemes().forEach(sc => $("#band-color-scheme").append($('<option>', {
|
||||
value: sc,
|
||||
text: sc
|
||||
})));
|
||||
$("#band-color-scheme").val(options["web-ui-options"]["default-band-color-scheme"]);
|
||||
if ($("#color-scheme option:selected").val() == "") {
|
||||
$("#color-scheme").val(options["web-ui-options"]["default-color-scheme"]);
|
||||
setColorScheme(options["web-ui-options"]["default-color-scheme"]);
|
||||
}
|
||||
|
||||
// First pass loading settings, so we can load the band colour scheme before the filters that need to use it
|
||||
loadSettings();
|
||||
setColorScheme($("#color-scheme option:selected").val());
|
||||
setBandColorScheme($("#band-color-scheme option:selected").val());
|
||||
|
||||
// Add CSS for band toggle buttons
|
||||
@@ -257,7 +242,7 @@ function loadOptions() {
|
||||
generateMultiToggleFilterCard("#dx-continent-options", "dx_continent", options["continents"]);
|
||||
generateMultiToggleFilterCard("#de-continent-options", "de_continent", options["continents"]);
|
||||
generateModesMultiToggleFilterCard(options["modes"]);
|
||||
generateSourcesMultiToggleFilterCard(options["spot_sources"], options["web-ui-options"]["spot-providers-enabled-by-default"]);
|
||||
generateSourcesMultiToggleFilterCard(options["spot_sources"], spotProvidersEnabledByDefault);
|
||||
|
||||
// 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
|
||||
|
||||
@@ -160,24 +160,9 @@ function loadOptions() {
|
||||
// Store options
|
||||
options = jsonData;
|
||||
|
||||
// Populate the Display panel
|
||||
options["web-ui-options"]["max-spot-age"].forEach(sc => $("#max-spot-age").append($('<option>', {
|
||||
value: sc * 60,
|
||||
text: sc
|
||||
})));
|
||||
$("#max-spot-age").val(options["web-ui-options"]["max-spot-age-default"] * 60);
|
||||
getAvailableBandColorSchemes().forEach(sc => $("#band-color-scheme").append($('<option>', {
|
||||
value: sc,
|
||||
text: sc
|
||||
})));
|
||||
$("#band-color-scheme").val(options["web-ui-options"]["default-band-color-scheme"]);
|
||||
if ($("#color-scheme option:selected").val() == "") {
|
||||
$("#color-scheme").val(options["web-ui-options"]["default-color-scheme"]);
|
||||
setColorScheme(options["web-ui-options"]["default-color-scheme"]);
|
||||
}
|
||||
|
||||
// First pass loading settings, so we can load the band colour scheme before the filters that need to use it
|
||||
loadSettings();
|
||||
setColorScheme($("#color-scheme option:selected").val());
|
||||
setBandColorScheme($("#band-color-scheme option:selected").val());
|
||||
|
||||
// Add CSS for band toggle buttons
|
||||
@@ -189,7 +174,7 @@ function loadOptions() {
|
||||
generateMultiToggleFilterCard("#dx-continent-options", "dx_continent", options["continents"]);
|
||||
generateMultiToggleFilterCard("#de-continent-options", "de_continent", options["continents"]);
|
||||
generateModesMultiToggleFilterCard(options["modes"]);
|
||||
generateSourcesMultiToggleFilterCard(options["spot_sources"], options["web-ui-options"]["spot-providers-enabled-by-default"]);
|
||||
generateSourcesMultiToggleFilterCard(options["spot_sources"], spotProvidersEnabledByDefault);
|
||||
|
||||
// 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
|
||||
|
||||
@@ -386,24 +386,9 @@ function loadOptions() {
|
||||
// Store options
|
||||
options = jsonData;
|
||||
|
||||
// Populate the Display panel
|
||||
options["web-ui-options"]["spot-count"].forEach(sc => $("#spots-to-fetch").append($('<option>', {
|
||||
value: sc,
|
||||
text: sc
|
||||
})));
|
||||
$("#spots-to-fetch").val(options["web-ui-options"]["spot-count-default"]);
|
||||
getAvailableBandColorSchemes().forEach(sc => $("#band-color-scheme").append($('<option>', {
|
||||
value: sc,
|
||||
text: sc
|
||||
})));
|
||||
$("#band-color-scheme").val(options["web-ui-options"]["default-band-color-scheme"]);
|
||||
if ($("#color-scheme option:selected").val() == "") {
|
||||
$("#color-scheme").val(options["web-ui-options"]["default-color-scheme"]);
|
||||
setColorScheme(options["web-ui-options"]["default-color-scheme"]);
|
||||
}
|
||||
|
||||
// First pass loading settings, so we can load the band colour scheme before the filters that need to use it
|
||||
loadSettings();
|
||||
setColorScheme($("#color-scheme option:selected").val());
|
||||
setBandColorScheme($("#band-color-scheme option:selected").val());
|
||||
|
||||
// Add CSS for band toggle buttons
|
||||
@@ -415,7 +400,7 @@ function loadOptions() {
|
||||
generateMultiToggleFilterCard("#dx-continent-options", "dx_continent", options["continents"]);
|
||||
generateMultiToggleFilterCard("#de-continent-options", "de_continent", options["continents"]);
|
||||
generateModesMultiToggleFilterCard(options["modes"]);
|
||||
generateSourcesMultiToggleFilterCard(options["spot_sources"], options["web-ui-options"]["spot-providers-enabled-by-default"]);
|
||||
generateSourcesMultiToggleFilterCard(options["spot_sources"], spotProvidersEnabledByDefault);
|
||||
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user