web: human format attachment size
This commit is contained in:
parent
1f5f10f78d
commit
dc7b3dd3e8
@ -32,6 +32,7 @@ graphql_client = "0.13.0"
|
|||||||
thiserror = "1.0.50"
|
thiserror = "1.0.50"
|
||||||
seed_hooks = { git = "https://github.com/wathiede/styles_hooks", package = "seed_hooks", branch = "main" }
|
seed_hooks = { git = "https://github.com/wathiede/styles_hooks", package = "seed_hooks", branch = "main" }
|
||||||
gloo-net = { version = "0.4.0", features = ["json", "serde_json"] }
|
gloo-net = { version = "0.4.0", features = ["json", "serde_json"] }
|
||||||
|
human_format = { git ="https://github.com/wathiede/human-format-rs" }
|
||||||
|
|
||||||
[package.metadata.wasm-pack.profile.release]
|
[package.metadata.wasm-pack.profile.release]
|
||||||
wasm-opt = ['-Os']
|
wasm-opt = ['-Os']
|
||||||
|
|||||||
@ -4,6 +4,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use chrono::{DateTime, Datelike, Duration, Local, Utc};
|
use chrono::{DateTime, Datelike, Duration, Local, Utc};
|
||||||
|
use human_format::{Formatter, Scales};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use log::error;
|
use log::error;
|
||||||
use seed::{prelude::*, *};
|
use seed::{prelude::*, *};
|
||||||
@ -669,6 +670,9 @@ fn message_render(msg: &ShowThreadQueryThreadMessages, open: bool) -> Node<Msg>
|
|||||||
let filename = a.filename.as_ref().unwrap_or(&default);
|
let filename = a.filename.as_ref().unwrap_or(&default);
|
||||||
let host = seed::window().location().host().expect("couldn't get host");
|
let host = seed::window().location().host().expect("couldn't get host");
|
||||||
let url = format!("//{host}/download/attachment/{}/{}/{}", a.id,a.idx, filename);
|
let url = format!("//{host}/download/attachment/{}/{}/{}", a.id,a.idx, filename);
|
||||||
|
let mut fmtr = Formatter::new();
|
||||||
|
fmtr.with_separator(" ");
|
||||||
|
fmtr.with_scales(Scales::Binary());
|
||||||
|
|
||||||
div![
|
div![
|
||||||
C!["attachment", "card"],
|
C!["attachment", "card"],
|
||||||
@ -688,7 +692,7 @@ fn message_render(msg: &ShowThreadQueryThreadMessages, open: bool) -> Node<Msg>
|
|||||||
div![C!["card-content"],
|
div![C!["card-content"],
|
||||||
div![C!["content"],
|
div![C!["content"],
|
||||||
&a.filename, br![],
|
&a.filename, br![],
|
||||||
small![&a.size, " bytes"]
|
small![ fmtr.format(a.size as f64),"B"]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
footer![
|
footer![
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user