[pdm-devel] [PATCH yew-comp 1/7] tasks: make date filter functional

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Jan 20 12:30:22 CET 2025


Am 20.01.25 um 10:29 schrieb Dominik Csapak:
> by converting the strings like '2014-05-01' into epochs by using the
> js-sys Date interface.
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  src/tasks.rs | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/src/tasks.rs b/src/tasks.rs
> index 4ea243f..fa17602 100644
> --- a/src/tasks.rs
> +++ b/src/tasks.rs
> @@ -134,7 +134,27 @@ impl LoadableComponent for ProxmoxTasks {
>          let store = self.store.clone();
>  
>          let form_context = self.filter_form_context.read();
> -        let filter = form_context.get_submit_data();
> +        let mut filter = form_context.get_submit_data();
> +
> +        // Transform Date values
> +        if let Some(since) = filter.get("since").and_then(|v| v.as_str()) {
> +            let since = js_sys::Date::new(&wasm_bindgen::JsValue::from_str(since));
> +            since.set_hours(0);
> +            since.set_minutes(0);
> +            since.set_seconds(0);
> +            let since = (since.get_time() / 1000.0).round() as u64;

Is round doing something here? Could only be the case if one could enter
milliseconds in the since/until strings, and if that would be the case
it might be better to just call set_milliseconds(0) too.

> +            filter["since"] = since.into();
> +        }
> +
> +        if let Some(until) = filter.get("until").and_then(|v| v.as_str()) {
> +            let until = js_sys::Date::new(&wasm_bindgen::JsValue::from_str(until));
> +            until.set_hours(23);
> +            until.set_minutes(59);
> +            until.set_seconds(59);
> +            let until = (until.get_time() / 1000.0).round() as u64;

same here.

> +            filter["until"] = until.into();
> +        }
> +
>          Box::pin(async move {
>              let data = crate::http_get(&path, Some(filter)).await?;
>              store.write().set_data(data);





More information about the pdm-devel mailing list