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 138FB1FF17C for ; Tue, 2 Dec 2025 18:27:47 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2D33A18753; Tue, 2 Dec 2025 18:28:12 +0100 (CET) From: Shan Shaji To: pdm-devel@lists.proxmox.com Date: Tue, 2 Dec 2025 18:27:29 +0100 Message-ID: <20251202172729.612782-1-s.shaji@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1764696414395 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.114 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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] fix: show empty-state message inside the top entities panels 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" When the entities list was empty, the dashboard did not display any message inside the Top Entities panels. This change adds a empty-state message so the panels provide proper feedback when no entries are available. Signed-off-by: Shan Shaji --- ui/src/dashboard/top_entities.rs | 79 +++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 27 deletions(-) diff --git a/ui/src/dashboard/top_entities.rs b/ui/src/dashboard/top_entities.rs index ab8c703..a78df57 100644 --- a/ui/src/dashboard/top_entities.rs +++ b/ui/src/dashboard/top_entities.rs @@ -1,6 +1,7 @@ use std::rc::Rc; use pwt::state::SharedState; +use pwt::widget::Fa; use web_sys::HtmlElement; use yew::virtual_dom::{VComp, VNode}; @@ -31,16 +32,23 @@ use crate::{ pub struct TopEntities { entities: Vec, metrics_title: String, + metrics_empty_message: String, /// The threshold for the oklab color gradient relaying how much load there is. /// Will be clamped between 0.001 and 0.999 to ensure invariants to avoid division by zero. threshold: f64, } impl TopEntities { - pub fn new(entities: Vec, metrics_title: String, threshold: f64) -> Self { + pub fn new( + entities: Vec, + metrics_title: String, + metrics_empty_message: String, + threshold: f64, + ) -> Self { Self { entities, metrics_title, + metrics_empty_message, threshold: threshold.clamp(0.001, 0.999), } } @@ -132,6 +140,7 @@ impl Component for TopEntitiesComp { .style("gap", "var(--pwt-spacer-3)"); let mut tooltip = None; let data = &props.entities; + for entity in data.iter().rev() { let resource = &entity.resource; let rrd = &entity.rrd_data; @@ -199,6 +208,18 @@ impl Component for TopEntitiesComp { .with_optional_child(tooltip_anchor), ); } + + if data.is_empty() { + list.add_child( + Row::new() + .gap(2) + .class(AlignItems::Center) + .style("grid-column", "span 2") + .with_child(Fa::new("info-circle").fixed_width()) + .with_child(&props.metrics_empty_message), + ); + } + Container::new() .class(FlexFit) .with_child(list) @@ -336,34 +357,38 @@ pub fn create_top_entities_panel( leaderboard_type: LeaderboardType, ) -> Panel { let top_entities = top_entities.read(); - let (entities, icon, title, metrics_title, threshold) = match leaderboard_type { - LeaderboardType::GuestCpu => ( - top_entities.data.as_ref().map(|e| e.guest_cpu.clone()), - "desktop", - tr!("Guests With the Highest CPU Usage"), - tr!("CPU usage"), - 0.85, - ), - LeaderboardType::NodeCpu => ( - top_entities.data.as_ref().map(|e| e.node_cpu.clone()), - "building", - tr!("Nodes With the Highest CPU Usage"), - tr!("CPU usage"), - 0.85, - ), - LeaderboardType::NodeMemory => ( - top_entities.data.as_ref().map(|e| e.node_memory.clone()), - "building", - tr!("Nodes With the Highest Memory Usage"), - tr!("Memory usage"), - 0.95, - ), - }; + let (entities, icon, title, metrics_title, metrics_empty_message, threshold) = + match leaderboard_type { + LeaderboardType::GuestCpu => ( + top_entities.data.as_ref().map(|e| e.guest_cpu.clone()), + "desktop", + tr!("Guests With the Highest CPU Usage"), + tr!("CPU usage"), + tr!("No guests available"), + 0.85, + ), + LeaderboardType::NodeCpu => ( + top_entities.data.as_ref().map(|e| e.node_cpu.clone()), + "building", + tr!("Nodes With the Highest CPU Usage"), + tr!("CPU usage"), + tr!("No nodes available"), + 0.85, + ), + LeaderboardType::NodeMemory => ( + top_entities.data.as_ref().map(|e| e.node_memory.clone()), + "building", + tr!("Nodes With the Highest Memory Usage"), + tr!("Memory usage"), + tr!("No nodes available"), + 0.95, + ), + }; Panel::new() .title(create_title_with_icon(icon, title)) - .with_optional_child( - entities.map(|entities| TopEntities::new(entities, metrics_title, threshold)), - ) + .with_optional_child(entities.map(|entities| { + TopEntities::new(entities, metrics_title, metrics_empty_message, threshold) + })) .with_optional_child((!top_entities.has_data()).then_some(loading_column())) .with_optional_child( top_entities -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel