From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id BF8B91FF165 for ; Thu, 23 Oct 2025 10:33:03 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EFB8539B0; Thu, 23 Oct 2025 10:33:30 +0200 (CEST) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Thu, 23 Oct 2025 10:28:15 +0200 Message-ID: <20251023083253.1038119-12-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251023083253.1038119-1-d.csapak@proxmox.com> References: <20251023083253.1038119-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.028 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pdm-devel] [PATCH datacenter-manager v2 11/16] ui: dashboard: factor out task parameter calculation X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" into the dashboard::tasks module. Signed-off-by: Dominik Csapak --- 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, 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) -> (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) -> 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 da447ecd..9989d4a9 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; @@ -328,3 +330,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, 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