From eadac6465d83ec6e26a45fd90d96ec5e081ce7b2 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 20 Sep 2024 22:45:23 +0200 Subject: Get stats working --- src/ui.rs | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src/ui.rs') diff --git a/src/ui.rs b/src/ui.rs index 4a73ba4..99a96a5 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -7,6 +7,7 @@ use axum::{ http::StatusCode, routing::{get, post}, }; +use log::info; use serde::Deserialize; use tower_http::services::ServeDir; @@ -52,26 +53,31 @@ struct DashboardTemplate<'a> { title: &'a str, page: ActivePage, conf: config::Config, - errors: Option, params: Vec, + params_errors: Option, + stats: Option, + stats_errors: Option, } async fn dashboard(State(state): State) -> DashboardTemplate<'static> { - let (conf, params_result) = { + let (conf, params_result, stats_result) = { let mut st = state.lock().unwrap(); let params_result = st.dabmux.get_rc_parameters(); + let stats_result = st.dabmux.get_stats(); + info!("STATS: {:?}", stats_result); - (st.conf.clone(), params_result) + (st.conf.clone(), params_result, stats_result) }; - let (params, errors) = match params_result { - Ok(v) => { - (v, None) - }, - Err(e) => { - (Vec::new(), Some(format!("{}", e))) - }, + let (params, params_errors) = match params_result { + Ok(v) => (v, None), + Err(e) => (Vec::new(), Some(format!("{}", e))), + }; + + let (stats, stats_errors) = match stats_result { + Ok(v) => (Some(v), None), + Err(e) => (None, Some(format!("{}", e))), }; DashboardTemplate { @@ -79,7 +85,9 @@ async fn dashboard(State(state): State) -> DashboardTemplate<'stati conf, page: ActivePage::Dashboard, params, - errors, + params_errors, + stats, + stats_errors, } } @@ -100,7 +108,7 @@ async fn post_rc( }; match set_rc_result { - Ok(v) => (StatusCode::OK, v.as_str().or(Some("")).unwrap().to_owned()), + Ok(()) => (StatusCode::OK, "".to_owned()), Err(e) => (StatusCode::BAD_REQUEST, e.to_string()), } } -- cgit v1.2.3