From 6e0e9ae4a506b41dc1478b57402082d8e5125185 Mon Sep 17 00:00:00 2001 From: catvayor Date: Wed, 5 Jun 2024 16:50:13 +0200 Subject: [PATCH] state reception --- src/main.rs | 29 +++++++++++++++--- static/utils.js | 4 +++ templates/conscrit.html.hbs | 38 +++++++++-------------- templates/vieux.html.hbs | 61 ++++++++++++++++--------------------- 4 files changed, 70 insertions(+), 62 deletions(-) diff --git a/src/main.rs b/src/main.rs index f6a4798..06ea57d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,8 @@ use std::{ sync::{Arc, RwLock}, }; +#[derive(Serialize, Clone)] +#[serde(crate = "rocket::serde")] enum TrackedState { Conscrit { invisible: bool, @@ -172,8 +174,10 @@ struct TrackedInfo { #[serde(crate = "rocket::serde")] struct AdminTrackedInfo { name: String, + id: String, pos: (f32, f32), color: u8, + state: TrackedState, } impl From for TrackedInfo { @@ -197,8 +201,10 @@ fn base_view(team: &Tracked) -> TrackedInfo { fn admin_view(team: &Tracked) -> AdminTrackedInfo { AdminTrackedInfo { name: team.name.clone(), + id: team.id.clone(), pos: team.pos, color: team.state.admin_color(), + state: team.state.clone(), } } @@ -237,8 +243,13 @@ fn apparent_info(watcher: &Tracked, team: &Tracked) -> Option { } } -#[get("/track/?")] -fn tracked_view(id: &str, gpslog: Option, tracking: &State) -> Option