From: Dominik Csapak <d.csapak@proxmox.com>
To: Thomas Lamprecht <t.lamprecht@proxmox.com>,
Proxmox Datacenter Manager development discussion
<pdm-devel@lists.proxmox.com>
Subject: Re: [pdm-devel] [PATCH yew-comp 1/7] tasks: make date filter functional
Date: Mon, 20 Jan 2025 13:10:45 +0100 [thread overview]
Message-ID: <c22d1e83-b0d4-4f74-88f7-49a0082393e1@proxmox.com> (raw)
In-Reply-To: <6bedbd8e-8b5e-4888-8cbf-bc9b89b18fdf@proxmox.com>
On 1/20/25 12:30, Thomas Lamprecht wrote:
> 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@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.
We currently rely on the browser to display a date time selector, and since
this is browser dependent, we technically cannot really know what we're getting here.
so the round was just to be overly careful to respect the input, but yeah
simply omitting the round to truncate the decimal places seems better.
and 'f64 as u64' already does rounds to zero, so i'll send a follow up to remove the round()
to reference the offical rust docs for 'as':
https://doc.rust-lang.org/1.84.0/reference/expressions/operator-expr.html#type-cast-expressions
>
>> + 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);
>
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2025-01-20 12:11 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-20 9:29 [pdm-devel] [PATCH yew-comp/datacenter-manager] ui: implement remote task list Dominik Csapak
2025-01-20 9:29 ` [pdm-devel] [PATCH yew-comp 1/7] tasks: make date filter functional Dominik Csapak
2025-01-20 11:30 ` Thomas Lamprecht
2025-01-20 12:10 ` Dominik Csapak [this message]
2025-01-21 8:33 ` Thomas Lamprecht
2025-01-21 9:46 ` Dominik Csapak
2025-01-20 9:29 ` [pdm-devel] [PATCH yew-comp 2/7] tasks: load more tasks on end of list Dominik Csapak
2025-01-20 17:29 ` Thomas Lamprecht
2025-01-21 9:43 ` Dominik Csapak
2025-01-20 9:29 ` [pdm-devel] [PATCH yew-comp 3/7] utils: factor out task description into own function Dominik Csapak
2025-01-20 17:29 ` Thomas Lamprecht
2025-01-21 9:44 ` Dominik Csapak
2025-01-20 9:29 ` [pdm-devel] [PATCH yew-comp 4/7] running tasks: make TaskListItem renderer configurable Dominik Csapak
2025-01-20 9:29 ` [pdm-devel] [PATCH yew-comp 5/7] running tasks: make buttons configurable Dominik Csapak
2025-01-20 9:29 ` [pdm-devel] [PATCH yew-comp 6/7] tasks: make columns configurable Dominik Csapak
2025-01-20 17:37 ` Thomas Lamprecht
2025-01-20 9:29 ` [pdm-devel] [PATCH yew-comp 7/7] tasks: make the 'show task' action configurable Dominik Csapak
2025-01-20 9:29 ` [pdm-devel] [PATCH datacenter-manager 1/9] server: factor out task filters into `TaskFilters` type Dominik Csapak
2025-01-20 17:42 ` Thomas Lamprecht
2025-01-20 9:29 ` [pdm-devel] [PATCH datacenter-manager 2/9] server: task cache: skip remotes with errors on fetch Dominik Csapak
2025-01-20 17:45 ` Thomas Lamprecht
2025-01-21 8:29 ` Dietmar Maurer
2025-01-20 9:30 ` [pdm-devel] [PATCH datacenter-manager 3/9] server: task cache: add filter options Dominik Csapak
2025-01-20 9:30 ` [pdm-devel] [PATCH datacenter-manager 4/9] server: task cache: reverse task order Dominik Csapak
2025-01-20 9:30 ` [pdm-devel] [PATCH datacenter-manager 5/9] pdm-client: export PveUpid Dominik Csapak
2025-01-20 9:30 ` [pdm-devel] [PATCH datacenter-manager 6/9] ui: refactor RemoteConfigPanel into own module Dominik Csapak
2025-01-20 9:30 ` [pdm-devel] [PATCH datacenter-manager 7/9] ui: remotes: add tasks to global remote panel Dominik Csapak
2025-01-20 9:30 ` [pdm-devel] [PATCH datacenter-manager 8/9] ui: register pve tasks Dominik Csapak
2025-01-20 9:30 ` [pdm-devel] [PATCH datacenter-manager 9/9] ui: also show running remote tasks in 'running tasks' list Dominik Csapak
2025-01-20 11:27 ` [pdm-devel] applied: [PATCH yew-comp/datacenter-manager] ui: implement remote task list Dietmar Maurer
2025-01-20 11:34 ` Thomas Lamprecht
2025-01-21 8:41 ` [pdm-devel] " Lukas Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c22d1e83-b0d4-4f74-88f7-49a0082393e1@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
--cc=t.lamprecht@proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox