diff options
Diffstat (limited to 'server/src/routes/ui/stats.rs')
-rw-r--r-- | server/src/routes/ui/stats.rs | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/server/src/routes/ui/stats.rs b/server/src/routes/ui/stats.rs index 927d85c..07da1d4 100644 --- a/server/src/routes/ui/stats.rs +++ b/server/src/routes/ui/stats.rs @@ -12,12 +12,14 @@ use crate::{ database::Database, routes::{ api::AcceptJson, - ui::node::{ + locale::AcceptLanguage, + ui::{layout::trs, node::{ format_duration, format_duration_long, format_size, rocket_uri_macro_r_library_node, - }, + }}, }, uri, }; +use jellybase::locale::tr; use jellycommon::{Node, NodeID, NodeKind, Visibility}; use rocket::{get, serde::json::Json, Either, State}; use serde::Serialize; @@ -29,7 +31,9 @@ pub fn r_stats( sess: Session, db: &State<Database>, aj: AcceptJson, + lang: AcceptLanguage, ) -> Result<Either<DynLayoutPage<'_>, Json<Value>>, MyError> { + let AcceptLanguage(lang) = lang; let mut items = db.list_nodes_with_udata(sess.user.name.as_str())?; items.retain(|(n, _)| matches!(n.visibility, Visibility::Visible)); @@ -77,25 +81,25 @@ pub fn r_stats( }))) } else { Either::Left(LayoutPage { - title: "Library Statistics".to_owned(), + title: tr(lang, "stats.title", &[]).to_string(), content: markup::new! { .page.stats { - h1 { "Library Statistics" } + h1 { @trs(&lang, "stats.title") } p { "There is a total of " b{@all.count} " nodes in the library." } p { "The total runtime of the library is " b{@format_duration_long(all.runtime)} ", taking up " b{@format_size(all.size)} " of disk space." } p { "An average node has a runtime of " b{@format_duration(all.average_runtime())} " and file size of " b{@format_size(all.average_size() as u64)} "." } - h2 { "Grouped by Kind" } + h2 { @trs(&lang, "stats.by_kind.title") } table.striped { tr { - th { "Kind" } - th { "Count" } - th { "Storage Size" } - th { "Media Runtime" } - th { "Average Size" } - th { "Average Runtime" } - th { "Largest File" } - th { "Longest Runtime" } + th { @trs(&lang, "stats.by_kind.kind") } + th { @trs(&lang, "stats.by_kind.count") } + th { @trs(&lang, "stats.by_kind.total_size") } + th { @trs(&lang, "stats.by_kind.total_runtime") } + th { @trs(&lang, "stats.by_kind.average_size") } + th { @trs(&lang, "stats.by_kind.average_runtime") } + th { @trs(&lang, "stats.by_kind.max_size") } + th { @trs(&lang, "stats.by_kind.max_runtime") } } @for (k,b) in &kinds { tr { td { @format!("{k:?}") } |