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 46CC81FF165 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 A3E47398D; 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:17 +0200 Message-ID: <20251023083253.1038119-14-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 13/16] ui: dashboard: status row: make loading less jarring 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 tracking the loading state not only via the last_refresh property, but also from a reload message to a changing last_refresh value. This means it now always shows the last refresh time if there was one and only rotates the icon in that case. This is much less jarring that a split second change of the text from a date to 'now refreshing' back to a finished date. While at it, remove the unused 'loading' property of the PdmDashboard struct. Signed-off-by: Dominik Csapak --- ui/src/dashboard/mod.rs | 11 ++--------- ui/src/dashboard/status_row.rs | 11 +++++++++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ui/src/dashboard/mod.rs b/ui/src/dashboard/mod.rs index e4115c6d..a394ea81 100644 --- a/ui/src/dashboard/mod.rs +++ b/ui/src/dashboard/mod.rs @@ -102,8 +102,6 @@ pub struct PdmDashboard { top_entities: Option, last_top_entities_error: Option, statistics: StatisticsOptions, - loaded_once: bool, - loading: bool, load_finished_time: Option, show_wizard: Option, show_config_window: bool, @@ -113,7 +111,7 @@ pub struct PdmDashboard { impl PdmDashboard { fn reload(&mut self, ctx: &yew::Context) { - let max_age = if self.loaded_once { + let max_age = if self.load_finished_time.is_some() { self.config.max_age.unwrap_or(DEFAULT_MAX_AGE_S) } else { INITIAL_MAX_AGE_S @@ -125,7 +123,6 @@ impl PdmDashboard { let link = ctx.link().clone(); let (_, since) = get_task_options(self.config.task_last_hours); - self.load_finished_time = None; self.async_pool.spawn(async move { let client = crate::pdm_client(); @@ -183,8 +180,6 @@ impl Component for PdmDashboard { data: None, error: None, }, - loaded_once: false, - loading: true, load_finished_time: None, show_wizard: None, show_config_window: false, @@ -224,9 +219,7 @@ impl Component for PdmDashboard { Err(err) => self.statistics.error = Some(err), }, LoadingResult::All => { - self.loading = false; - if !self.loaded_once { - self.loaded_once = true; + if self.load_finished_time.is_none() { // immediately trigger a "normal" reload after the first load with the // configured or default max-age to ensure users sees more current data. ctx.link().send_message(Msg::Reload); diff --git a/ui/src/dashboard/status_row.rs b/ui/src/dashboard/status_row.rs index 5e377411..0855b123 100644 --- a/ui/src/dashboard/status_row.rs +++ b/ui/src/dashboard/status_row.rs @@ -45,6 +45,7 @@ pub enum Msg { #[doc(hidden)] pub struct PdmDashboardStatusRow { _interval: Interval, + loading: bool, } impl PdmDashboardStatusRow { @@ -68,6 +69,7 @@ impl Component for PdmDashboardStatusRow { fn create(ctx: &yew::Context) -> Self { Self { _interval: Self::create_interval(ctx), + loading: false, } } @@ -76,19 +78,24 @@ impl Component for PdmDashboardStatusRow { match msg { Msg::Reload(clicked) => { props.on_reload.emit(clicked); + self.loading = true; true } } } - fn changed(&mut self, ctx: &Context, _old_props: &Self::Properties) -> bool { + fn changed(&mut self, ctx: &Context, old_props: &Self::Properties) -> bool { self._interval = Self::create_interval(ctx); + let new_refresh = ctx.props().last_refresh; + if new_refresh.is_some() && old_props.last_refresh != new_refresh { + self.loading = false; + } true } fn view(&self, ctx: &yew::Context) -> yew::Html { let props = ctx.props(); - let is_loading = props.last_refresh.is_none(); + let is_loading = props.last_refresh.is_none() || self.loading; let on_settings_click = props.on_settings_click.clone(); Row::new() .gap(1) -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel