From 9823fd32059a362c8aa2b4ea3ce349df92ab1547 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Fri, 15 May 2026 22:00:02 +0200 Subject: [PATCH] fix bad color in configform, move some docs into api docs --- daemon/src/gps.rs | 27 +++++++++++++++++++ daemon/src/lib.rs | 4 ++- .../web/src/lib/components/ConfigForm.svelte | 2 +- doc/configuration.md | 9 ++++--- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/daemon/src/gps.rs b/daemon/src/gps.rs index 303e3e9..2be8c67 100644 --- a/daemon/src/gps.rs +++ b/daemon/src/gps.rs @@ -60,6 +60,7 @@ where } #[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(feature = "apidocs", derive(utoipa::ToSchema))] pub struct GpsData { #[serde(deserialize_with = "deserialize_latitude")] pub latitude: f64, @@ -98,6 +99,20 @@ pub async fn load_gps_records(file: tokio::fs::File) -> Vec { records } +/// Submit GPS coordinates +#[cfg_attr(feature = "apidocs", utoipa::path( + post, + path = "/api/gps", + tag = "Configuration", + request_body = GpsData, + responses( + (status = StatusCode::OK, description = "GPS data accepted"), + (status = StatusCode::FORBIDDEN, description = "GPS API endpoint is disabled"), + (status = StatusCode::INTERNAL_SERVER_ERROR, description = "Failed to write GPS record") + ), + summary = "Submit GPS coordinates", + description = "Submit GPS coordinates from an external source (e.g. a phone app). Requires gps_mode to be set to 'Api' in configuration. latitude is in decimal degrees from -90 to 90, longitude is in decimal degrees from -180 to 180, timestamp is a Unix timestamp in seconds." +))] pub async fn post_gps( State(state): State>, Json(gps_data): Json, @@ -155,6 +170,18 @@ pub async fn post_gps( Ok(StatusCode::OK) } +/// Get the current GPS coordinates +#[cfg_attr(feature = "apidocs", utoipa::path( + get, + path = "/api/gps", + tag = "Configuration", + responses( + (status = StatusCode::OK, description = "Current GPS data", body = GpsData), + (status = StatusCode::NOT_FOUND, description = "No GPS data available") + ), + summary = "Get current GPS coordinates", + description = "Returns the most recently submitted GPS coordinates. Returns 404 if no coordinates have been submitted yet this session." +))] pub async fn get_gps(State(state): State>) -> Result, StatusCode> { let gps = state.gps_state.read().await; match gps.as_ref() { diff --git a/daemon/src/lib.rs b/daemon/src/lib.rs index b347dca..69fdf5b 100644 --- a/daemon/src/lib.rs +++ b/daemon/src/lib.rs @@ -47,7 +47,9 @@ use utoipa::OpenApi; server::test_notification, server::get_time, server::set_time_offset, - server::debug_set_display_state + server::debug_set_display_state, + gps::post_gps, + gps::get_gps ), servers( ( diff --git a/daemon/web/src/lib/components/ConfigForm.svelte b/daemon/web/src/lib/components/ConfigForm.svelte index 8bad35d..88a3669 100644 --- a/daemon/web/src/lib/components/ConfigForm.svelte +++ b/daemon/web/src/lib/components/ConfigForm.svelte @@ -781,7 +781,7 @@ -
+

GPS Settings