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 5C8731FF15C for ; Fri, 5 Sep 2025 10:33:11 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3A43FF22C; Fri, 5 Sep 2025 10:33:28 +0200 (CEST) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Fri, 5 Sep 2025 10:32:47 +0200 Message-ID: <20250905083253.1242076-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250905083253.1242076-1-d.csapak@proxmox.com> References: <20250905083253.1242076-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.022 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 2/2] ui: dashboard: make refresh button force the update 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" by setting 'max-age' to 0 in that case. Introduce a 'force' parameter to the reload messges/functions so we can easily control that. Signed-off-by: Dominik Csapak --- ui/src/dashboard/mod.rs | 20 ++++++++++++-------- ui/src/dashboard/status_row.rs | 14 +++++++------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/ui/src/dashboard/mod.rs b/ui/src/dashboard/mod.rs index 9d65122..cc7dc58 100644 --- a/ui/src/dashboard/mod.rs +++ b/ui/src/dashboard/mod.rs @@ -100,7 +100,7 @@ pub enum Msg { LoadingFinished(LoadingResult), RemoteListChanged(RemoteList), CreateWizard(bool), - Reload, + Reload(bool), // force UpdateConfig(DashboardConfig), ConfigWindow(bool), Search(Search), @@ -289,9 +289,13 @@ impl PdmDashboard { ) } - fn reload(&mut self, ctx: &yew::Context) { + fn reload(&mut self, ctx: &yew::Context, force: bool) { let link = ctx.link().clone(); - let max_age = self.config.max_age.unwrap_or(DEFAULT_MAX_AGE_S); + let max_age = if force { + 0 + } else { + self.config.max_age.unwrap_or(DEFAULT_MAX_AGE_S) + }; let (_, since) = Self::get_task_options(&self.config); self.load_finished_time = None; @@ -360,7 +364,7 @@ impl Component for PdmDashboard { config, }; - this.reload(ctx); + this.reload(ctx, false); this } @@ -402,8 +406,8 @@ impl Component for PdmDashboard { self.show_wizard = show; true } - Msg::Reload => { - self.reload(ctx); + Msg::Reload(force) => { + self.reload(ctx, force); true } Msg::ConfigWindow(show) => { @@ -416,7 +420,7 @@ impl Component for PdmDashboard { let (new_hours, _) = Self::get_task_options(&self.config); if old_hours != new_hours { - self.reload(ctx); + self.reload(ctx, false); } self.show_config_window = false; @@ -445,7 +449,7 @@ impl Component for PdmDashboard { self.config .refresh_interval .unwrap_or(DEFAULT_REFRESH_INTERVAL_S), - ctx.link().callback(|_| Msg::Reload), + ctx.link().callback(|force| Msg::Reload(force)), ctx.link().callback(|_| Msg::ConfigWindow(true)), )), ) diff --git a/ui/src/dashboard/status_row.rs b/ui/src/dashboard/status_row.rs index 26e3319..99cc3b5 100644 --- a/ui/src/dashboard/status_row.rs +++ b/ui/src/dashboard/status_row.rs @@ -17,7 +17,7 @@ pub struct DashboardStatusRow { last_refresh: Option, reload_interval_s: u64, - on_reload: Callback<()>, + on_reload: Callback, on_settings_click: Callback<()>, } @@ -26,7 +26,7 @@ impl DashboardStatusRow { pub fn new( last_refresh: Option, reload_interval_s: u64, - on_reload: impl Into>, + on_reload: impl Into>, on_settings_click: impl Into>, ) -> Self { yew::props!(Self { @@ -39,7 +39,7 @@ impl DashboardStatusRow { } pub enum Msg { - Reload, + Reload(bool), // force CheckReload, } @@ -74,15 +74,15 @@ impl Component for PdmDashboardStatusRow { fn update(&mut self, ctx: &Context, msg: Self::Message) -> bool { let props = ctx.props(); match msg { - Msg::Reload => { - props.on_reload.emit(()); + Msg::Reload(force) => { + props.on_reload.emit(force); true } Msg::CheckReload => match ctx.props().last_refresh { Some(last_refresh) => { let duration = Date::now() / 1000.0 - last_refresh; if duration >= props.reload_interval_s as f64 { - ctx.link().send_message(Msg::Reload); + ctx.link().send_message(Msg::Reload(false)); } true } @@ -112,7 +112,7 @@ impl Component for PdmDashboardStatusRow { }) .tabindex(0) .disabled(is_loading) - .on_activate(ctx.link().callback(|_| Msg::Reload)), + .on_activate(ctx.link().callback(|_| Msg::Reload(true))), ) .tip(tr!("Refresh now")), ) -- 2.47.2 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel