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 2/2] ui: dashboard: make refresh button force the update
Date: Fri,  5 Sep 2025 10:32:47 +0200	[thread overview]
Message-ID: <20250905083253.1242076-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250905083253.1242076-1-d.csapak@proxmox.com>

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 <d.csapak@proxmox.com>
---
 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<Self>) {
+    fn reload(&mut self, ctx: &yew::Context<Self>, 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<f64>,
     reload_interval_s: u64,
 
-    on_reload: Callback<()>,
+    on_reload: Callback<bool>,
 
     on_settings_click: Callback<()>,
 }
@@ -26,7 +26,7 @@ impl DashboardStatusRow {
     pub fn new(
         last_refresh: Option<f64>,
         reload_interval_s: u64,
-        on_reload: impl Into<Callback<()>>,
+        on_reload: impl Into<Callback<bool>>,
         on_settings_click: impl Into<Callback<()>>,
     ) -> 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<Self>, 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


  reply	other threads:[~2025-09-05  8:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-05  8:32 [pdm-devel] [PATCH datacenter-manager 1/2] ui: dashboard: increase max-age default to 930 seconds Dominik Csapak
2025-09-05  8:32 ` Dominik Csapak [this message]
2025-09-05 12:26 ` Thomas Lamprecht

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=20250905083253.1242076-2-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