From b1202cc8897e2ba79f55ef37539df6922deb7f60 Mon Sep 17 00:00:00 2001 From: husky Date: Wed, 12 Mar 2025 12:36:37 -0700 Subject: [PATCH] bring over changes from develop repos --- asklyphe-frontend/src/routes/admin.rs | 35 +++++++++++++++++-- .../templates/admin/invitecode.html | 2 +- unit_converter/src/length_units.rs | 2 +- unit_converter/src/lib.rs | 2 +- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/asklyphe-frontend/src/routes/admin.rs b/asklyphe-frontend/src/routes/admin.rs index 4e93d30..3e97993 100644 --- a/asklyphe-frontend/src/routes/admin.rs +++ b/asklyphe-frontend/src/routes/admin.rs @@ -343,14 +343,45 @@ pub async fn admin_invitecode( } let active_codes = match list_invite_codes(nats.clone(), token.clone(), false).await { - Ok(v) => v, + Ok(mut v) => { + for v in &mut v { + if let Some(used_by) = &v.used_by { + if used_by.len() > 32 { + v.used_by = Some(format!("{}...", &used_by[0..32])); + } + } + + if v.creator.len() > 32 { + v.creator = format!("{}...", &v.creator[0..32]); + } + } + + v + }, Err(e) => { return e.into_response(); } }; let used_codes = match list_invite_codes(nats.clone(), token.clone(), true).await { - Ok(v) => v.into_iter().map(|mut v| if v.used_at.is_none() { v.used_at = Some(String::from("unset")); v } else { v }).collect(), + Ok(v) => v.into_iter().map(|mut v| { + if let Some(used_by) = &v.used_by { + if used_by.len() > 32 { + v.used_by = Some(format!("{}...", &used_by[0..32])); + } + } + + if v.creator.len() > 32 { + v.creator = format!("{}...", &v.creator[0..32]); + } + + if v.used_at.is_none() { + v.used_at = Some(String::from("unset")); + v + } else { + v + } + }).collect(), Err(e) => { return e.into_response(); } diff --git a/asklyphe-frontend/templates/admin/invitecode.html b/asklyphe-frontend/templates/admin/invitecode.html index f7c7039..b6b4dd7 100644 --- a/asklyphe-frontend/templates/admin/invitecode.html +++ b/asklyphe-frontend/templates/admin/invitecode.html @@ -1,6 +1,6 @@ {% extends "admin/shell.html" %} -{% block title %}Home{% endblock %} +{% block title %}Invite Codes{% endblock %} {% block head %} {% endblock %} diff --git a/unit_converter/src/length_units.rs b/unit_converter/src/length_units.rs index 511dcf8..61a3282 100644 --- a/unit_converter/src/length_units.rs +++ b/unit_converter/src/length_units.rs @@ -16,7 +16,7 @@ use astro_float::{BigFloat, RoundingMode}; use once_cell::sync::Lazy; use std::collections::BTreeMap; -pub const PRECISION: usize = 1024; +pub const PRECISION: usize = 2048; // length unit -> value in meters pub static LENGTH_STORE: Lazy> = Lazy::new(|| { diff --git a/unit_converter/src/lib.rs b/unit_converter/src/lib.rs index 11e498c..6eda266 100644 --- a/unit_converter/src/lib.rs +++ b/unit_converter/src/lib.rs @@ -15,7 +15,7 @@ use crate::length_units::{LengthUnit, LENGTH_NAMES, LENGTH_STORE, PRECISION}; use crate::unit_defs::{ConvertTo, MetricPrefix}; use astro_float::{BigFloat, Consts, Radix, RoundingMode}; -pub const MAX_PRECISION: usize = 1024; +pub const MAX_PRECISION: usize = 2048; pub mod length_units; pub mod unit_defs;