From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id AB4B11FF187 for ; Mon, 25 Aug 2025 11:54:39 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F182BE37C; Mon, 25 Aug 2025 11:54:43 +0200 (CEST) Message-ID: <9fac7d98-3b73-4120-ab73-480533533ba3@proxmox.com> Date: Mon, 25 Aug 2025 11:54:40 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Proxmox Datacenter Manager development discussion , Dominik Csapak References: <20250825081042.797559-1-d.csapak@proxmox.com> <20250825081042.797559-9-d.csapak@proxmox.com> Content-Language: en-US From: Stefan Hanreich In-Reply-To: <20250825081042.797559-9-d.csapak@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.711 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: Re: [pdm-devel] [PATCH datacenter-manager v3 8/8] ui: dashboard: make task summary time range configurable 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" On 8/25/25 10:11 AM, Dominik Csapak wrote: > in the browsers local storage. > > We already have now an interface to configure this, so use it to store > the timeframe to check for tasks > > Signed-off-by: Dominik Csapak > --- > ui/src/dashboard/mod.rs | 34 ++++++++++++++++++++++++++++++---- > 1 file changed, 30 insertions(+), 4 deletions(-) > > diff --git a/ui/src/dashboard/mod.rs b/ui/src/dashboard/mod.rs > index 502332a..d9b58b6 100644 > --- a/ui/src/dashboard/mod.rs > +++ b/ui/src/dashboard/mod.rs > @@ -59,6 +59,9 @@ pub const DEFAULT_MAX_AGE_S: u64 = 60; > /// The default refresh interval > pub const DEFAULT_REFRESH_INTERVAL_S: u64 = DEFAULT_MAX_AGE_S / 2; > > +/// The default hours to show for task summaries > +pub const DEFAULT_TASK_SUMMARY_HOURS: u32 = 24; > + > #[derive(Properties, PartialEq)] > pub struct Dashboard {} > > @@ -81,6 +84,8 @@ pub struct DashboardConfig { > refresh_interval: Option, > #[serde(skip_serializing_if = "Option::is_none")] > max_age: Option, > + #[serde(skip_serializing_if = "Option::is_none")] > + task_last_hours: Option, > } > > pub type LoadingResult = ( > @@ -257,6 +262,7 @@ impl PdmDashboard { > fn reload(&mut self, ctx: &yew::Context) { > let link = ctx.link().clone(); > let max_age = self.config.max_age.unwrap_or(DEFAULT_MAX_AGE_S); > + let last_hours = self.statistics.hours; > > self.load_finished_time = None; > self.async_pool.spawn(async move { > @@ -265,7 +271,7 @@ impl PdmDashboard { > let top_entities_future = client.get_top_entities(); > let status_future = http_get("/resources/status", Some(json!({"max-age": max_age}))); > > - let since = (Date::now() / 1000.0) as i64 - (24 * 60 * 60); > + let since = (Date::now() / 1000.0) as i64 - (last_hours * 60 * 60) as i64; > let params = Some(json!({ > "since": since, > "limit": 0, > @@ -291,7 +297,8 @@ impl Component for PdmDashboard { > type Properties = Dashboard; > > fn create(ctx: &yew::Context) -> Self { > - let config = PersistentState::new(StorageLocation::local("dashboard-config")); > + let config: PersistentState = > + PersistentState::new(StorageLocation::local("dashboard-config")); > let async_pool = AsyncPool::new(); > > let (remote_list, _context_listener) = ctx > @@ -299,9 +306,10 @@ impl Component for PdmDashboard { > .context(ctx.link().callback(Msg::RemoteListChanged)) > .expect("No Remote list context provided"); > > - let since = (Date::now() / 1000.0) as i64 - (24 * 60 * 60); > + let hours = config.task_last_hours.unwrap_or(DEFAULT_TASK_SUMMARY_HOURS); nit: maybe make this a getter? (max_age could be as well?) > + let since = (Date::now() / 1000.0) as i64 - (hours * 60 * 60) as i64; possibly this as well? or at least extract into a function? > let statistics = StatisticsOptions { > - hours: 24, > + hours, > since, > data: None, > error: None, > @@ -375,6 +383,17 @@ impl Component for PdmDashboard { > } > Msg::UpdateConfig(dashboard_config) => { > self.config.update(dashboard_config); > + let old_hours = self.statistics.hours; > + let new_hours = self > + .config > + .task_last_hours > + .unwrap_or(DEFAULT_TASK_SUMMARY_HOURS); duplicated here > + > + if old_hours != new_hours { > + self.statistics.hours = new_hours; > + self.reload(ctx); > + } > + > self.show_config_window = false; > true > } > @@ -592,6 +611,13 @@ impl Component for PdmDashboard { > DisplayField::new() > .key("max-age-explanation") > .value(tr!("If a response from a remote is older than 'Max Age', it will be updated on the next refresh."))) > + .with_field( > + tr!("Task Summary Time Range (last hours)"), > + Number::new() > + .name("task-last-hours") > + .min(0u64) > + .placeholder(DEFAULT_TASK_SUMMARY_HOURS.to_string()), > + ) > .into() > }) > .on_close(ctx.link().callback(|_| Msg::ConfigWindow(false))) _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel