all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager 10/15] ui: dashboard: factor out task parameter calculation
Date: Tue, 21 Oct 2025 16:03:26 +0200	[thread overview]
Message-ID: <20251021140801.3611022-11-d.csapak@proxmox.com> (raw)
In-Reply-To: <20251021140801.3611022-1-d.csapak@proxmox.com>

into the dashboard::tasks module.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/dashboard/mod.rs   | 19 ++++++-------------
 ui/src/dashboard/tasks.rs |  8 ++++++++
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/ui/src/dashboard/mod.rs b/ui/src/dashboard/mod.rs
index fc2e150a..06283500 100644
--- a/ui/src/dashboard/mod.rs
+++ b/ui/src/dashboard/mod.rs
@@ -47,7 +47,7 @@ use status_row::DashboardStatusRow;
 mod filtered_tasks;
 
 mod tasks;
-use tasks::create_task_summary_panel;
+use tasks::{create_task_summary_panel, get_task_options};
 
 pub mod types;
 
@@ -57,8 +57,7 @@ pub use refresh_config_edit::{
     create_refresh_config_edit_window, refresh_config_id, RefreshConfig,
 };
 use refresh_config_edit::{
-    DEFAULT_MAX_AGE_S, DEFAULT_REFRESH_INTERVAL_S, DEFAULT_TASK_SUMMARY_HOURS,
-    FORCE_RELOAD_MAX_AGE_S, INITIAL_MAX_AGE_S,
+    DEFAULT_MAX_AGE_S, DEFAULT_REFRESH_INTERVAL_S, FORCE_RELOAD_MAX_AGE_S, INITIAL_MAX_AGE_S,
 };
 
 #[derive(Properties, PartialEq)]
@@ -127,7 +126,7 @@ impl PdmDashboard {
 
     fn do_reload(&mut self, ctx: &yew::Context<Self>, max_age: u64) {
         let link = ctx.link().clone();
-        let (_, since) = Self::get_task_options(&self.config);
+        let (_, since) = get_task_options(self.config.task_last_hours);
 
         self.load_finished_time = None;
         self.async_pool.spawn(async move {
@@ -167,12 +166,6 @@ impl PdmDashboard {
             link.send_message(Msg::LoadingFinished(LoadingResult::All));
         });
     }
-
-    fn get_task_options(config: &PersistentState<RefreshConfig>) -> (u32, i64) {
-        let hours = config.task_last_hours.unwrap_or(DEFAULT_TASK_SUMMARY_HOURS);
-        let since = (Date::now() / 1000.0) as i64 - (hours * 60 * 60) as i64;
-        (hours, since)
-    }
 }
 
 impl Component for PdmDashboard {
@@ -275,9 +268,9 @@ impl Component for PdmDashboard {
                 true
             }
             Msg::UpdateConfig(dashboard_config) => {
-                let (old_hours, _) = Self::get_task_options(&self.config);
+                let (old_hours, _) = get_task_options(self.config.task_last_hours);
                 self.config.update(dashboard_config);
-                let (new_hours, _) = Self::get_task_options(&self.config);
+                let (new_hours, _) = get_task_options(self.config.task_last_hours);
 
                 if old_hours != new_hours {
                     self.reload(ctx);
@@ -290,7 +283,7 @@ impl Component for PdmDashboard {
     }
 
     fn view(&self, ctx: &yew::Context<Self>) -> yew::Html {
-        let (hours, since) = Self::get_task_options(&self.config);
+        let (hours, since) = get_task_options(self.config.task_last_hours);
         let content = Column::new()
             .class(FlexFit)
             .with_child(
diff --git a/ui/src/dashboard/tasks.rs b/ui/src/dashboard/tasks.rs
index cdb0d9c6..9a009c4d 100644
--- a/ui/src/dashboard/tasks.rs
+++ b/ui/src/dashboard/tasks.rs
@@ -3,6 +3,7 @@ use std::collections::HashMap;
 use std::rc::Rc;
 
 use anyhow::Error;
+use js_sys::Date;
 use yew::html::Scope;
 use yew::virtual_dom::Key;
 
@@ -21,6 +22,7 @@ use pdm_api_types::TaskStatistics;
 
 use crate::dashboard::create_title_with_icon;
 use crate::dashboard::loading_column;
+use crate::dashboard::refresh_config_edit::DEFAULT_TASK_SUMMARY_HOURS;
 use crate::tasks::TaskWorkerType;
 
 use super::filtered_tasks::FilteredTasks;
@@ -325,3 +327,9 @@ pub fn create_task_summary_panel(
                 .with_optional_child(error.map(|err| error_message(&err.to_string()))),
         )
 }
+
+pub fn get_task_options(last_hours: Option<u32>) -> (u32, i64) {
+    let hours = last_hours.unwrap_or(DEFAULT_TASK_SUMMARY_HOURS);
+    let since = (Date::now() / 1000.0) as i64 - (hours * 60 * 60) as i64;
+    (hours, since)
+}
-- 
2.47.3



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


  parent reply	other threads:[~2025-10-21 14:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-21 14:03 [pdm-devel] [PATCH datacenter-manager 00/15] prepare ui fore customizable views Dominik Csapak
2025-10-21 14:03 ` [pdm-devel] [PATCH datacenter-manager 01/15] ui: dashboard: refactor guest panel creation to its own module Dominik Csapak
2025-10-21 14:03 ` [pdm-devel] [PATCH datacenter-manager 02/15] ui: dashboard: refactor creating the node panel into " Dominik Csapak
2025-10-21 14:03 ` [pdm-devel] [PATCH datacenter-manager 03/15] ui: dashboard: refactor remote panel creation " Dominik Csapak
2025-10-21 14:03 ` [pdm-devel] [PATCH datacenter-manager 04/15] ui: dashboard: remote panel: make wizard menu optional Dominik Csapak
2025-10-21 14:03 ` [pdm-devel] [PATCH datacenter-manager 05/15] ui: dashboard: refactor sdn panel creation into its own module Dominik Csapak
2025-10-21 14:03 ` [pdm-devel] [PATCH datacenter-manager 06/15] ui: dashboard: refactor task summary panel creation to " Dominik Csapak
2025-10-21 14:03 ` [pdm-devel] [PATCH datacenter-manager 07/15] ui: dashboard: refactor subscription " Dominik Csapak
2025-10-21 14:03 ` [pdm-devel] [PATCH datacenter-manager 08/15] ui: dashboard: refactor top entities " Dominik Csapak
2025-10-21 14:03 ` [pdm-devel] [PATCH datacenter-manager 09/15] ui: dashboard: refactor DashboardConfig editing/constants to their module Dominik Csapak
2025-10-21 14:03 ` Dominik Csapak [this message]
2025-10-21 14:03 ` [pdm-devel] [PATCH datacenter-manager 11/15] ui: dashboard: remove unused remote list Dominik Csapak
2025-10-21 14:03 ` [pdm-devel] [PATCH datacenter-manager 12/15] ui: dashboard: status row: make loading less jarring Dominik Csapak
2025-10-21 14:03 ` [pdm-devel] [PATCH datacenter-manager 13/15] ui: introduce `LoadResult` helper type Dominik Csapak
2025-10-21 14:03 ` [pdm-devel] [PATCH datacenter-manager 14/15] ui: dashboard: implement 'View' Dominik Csapak
2025-10-21 14:03 ` [pdm-devel] [PATCH datacenter-manager 15/15] ui: dashboard: use 'View' instead of the Dashboard Dominik Csapak
2025-10-23  8:33 ` [pdm-devel] superseded: [PATCH datacenter-manager 00/15] prepare ui fore customizable views Dominik Csapak

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=20251021140801.3611022-11-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pdm-devel@lists.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal