fix bad color in configform, move some docs into api docs

This commit is contained in:
Markus Unterwaditzer
2026-05-15 22:00:02 +02:00
committed by Will Greenberg
parent 0783db6e01
commit 9823fd3205
4 changed files with 36 additions and 6 deletions
+27
View File
@@ -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<GpsRecord> {
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<Arc<ServerState>>,
Json(gps_data): Json<GpsData>,
@@ -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<Arc<ServerState>>) -> Result<Json<GpsData>, StatusCode> {
let gps = state.gps_state.read().await;
match gps.as_ref() {
+3 -1
View File
@@ -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(
(
@@ -781,7 +781,7 @@
</div>
</div>
<div class="border-t pt-4 mt-6 space-y-3">
<div class="border-t border-gray-200 pt-4 mt-6 space-y-3">
<h3 class="text-lg font-semibold text-gray-800 mb-4">GPS Settings</h3>
<div>
<label for="gps_mode" class="block text-sm font-medium text-gray-700 mb-1"