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 2D2941FF15C for ; Fri, 31 Oct 2025 13:48:22 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9C94611909; Fri, 31 Oct 2025 13:48:57 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Fri, 31 Oct 2025 13:43:45 +0100 Message-ID: <20251031124822.2739685-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251031124822.2739685-1-d.csapak@proxmox.com> References: <20251031124822.2739685-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.027 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [mod.rs] Subject: [pdm-devel] [PATCH datacenter-manager v3 02/21] ui: dashboard: refactor creating the node panel into its own module 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" so we can easily reuse it outside the Dashboard struct. Signed-off-by: Dominik Csapak --- ui/src/dashboard/mod.rs | 51 ++++++-------------------- ui/src/dashboard/node_status_panel.rs | 52 +++++++++++++++++++++------ 2 files changed, 52 insertions(+), 51 deletions(-) diff --git a/ui/src/dashboard/mod.rs b/ui/src/dashboard/mod.rs index 1fe149c3..3b5b3b50 100644 --- a/ui/src/dashboard/mod.rs +++ b/ui/src/dashboard/mod.rs @@ -44,7 +44,7 @@ mod guest_panel; pub use guest_panel::create_guest_panel; mod node_status_panel; -use node_status_panel::NodeStatusPanel; +use node_status_panel::create_node_panel; mod sdn_zone_panel; use sdn_zone_panel::SdnZonePanel; @@ -149,35 +149,6 @@ pub struct PdmDashboard { } impl PdmDashboard { - fn create_node_panel(&self, icon: &str, title: String, remote_type: RemoteType) -> Panel { - let (nodes_status, failed_remotes) = match &self.status { - Some(status) => { - let nodes_status = match remote_type { - RemoteType::Pve => Some(status.pve_nodes.clone()), - RemoteType::Pbs => Some(status.pbs_nodes.clone()), - }; - let failed_remotes = status - .failed_remotes_list - .iter() - .filter(|item| item.remote_type == remote_type) - .count(); - (nodes_status, failed_remotes) - } - None => (None, 0), - }; - - Panel::new() - .flex(1.0) - .width(300) - .title(create_title_with_icon(icon, title)) - .border(true) - .with_child(NodeStatusPanel::new( - remote_type, - nodes_status, - failed_remotes, - )) - } - fn create_sdn_panel(&self) -> Panel { let sdn_zones_status = self.status.as_ref().map(|status| status.sdn_zones.clone()); @@ -498,11 +469,11 @@ impl Component for PdmDashboard { ) .with_child(RemotePanel::new(self.status.clone())), ) - .with_child(self.create_node_panel( - "building", - tr!("Virtual Environment Nodes"), - RemoteType::Pve, - )) + .with_child( + create_node_panel(RemoteType::Pve, self.status.clone()) + .flex(1.0) + .width(300), + ) .with_child( create_guest_panel(Some(GuestType::Qemu), self.status.clone()) .flex(1.0) @@ -513,11 +484,11 @@ impl Component for PdmDashboard { .flex(1.0) .width(300), ) - .with_child(self.create_node_panel( - "building-o", - tr!("Backup Server Nodes"), - RemoteType::Pbs, - )) + .with_child( + create_node_panel(RemoteType::Pbs, self.status.clone()) + .flex(1.0) + .width(300), + ) .with_child(self.create_pbs_datastores_panel()) .with_child(SubscriptionInfo::new()), ) diff --git a/ui/src/dashboard/node_status_panel.rs b/ui/src/dashboard/node_status_panel.rs index e9e8c6b2..c66d82e6 100644 --- a/ui/src/dashboard/node_status_panel.rs +++ b/ui/src/dashboard/node_status_panel.rs @@ -1,19 +1,17 @@ use std::rc::Rc; -use pdm_api_types::remotes::RemoteType; -use pdm_api_types::resource::NodeStatusCount; +use yew::virtual_dom::{VComp, VNode}; + use pdm_search::{Search, SearchTerm}; use proxmox_yew_comp::Status; -use pwt::{ - css::{AlignItems, FlexFit, JustifyContent}, - prelude::*, - widget::{Column, Fa}, -}; -use yew::{ - virtual_dom::{VComp, VNode}, - Properties, -}; +use pwt::css::{AlignItems, FlexFit, JustifyContent}; +use pwt::prelude::*; +use pwt::widget::{Column, Fa, Panel}; + +use pdm_api_types::resource::NodeStatusCount; +use pdm_api_types::{remotes::RemoteType, resource::ResourcesStatus}; +use crate::dashboard::create_title_with_icon; use crate::search_provider::get_search_provider; use super::loading_column; @@ -142,3 +140,35 @@ fn map_status( (icon, status_msg, search_terms) } + +pub fn create_node_panel(remote_type: RemoteType, status: Option) -> Panel { + let (icon, title) = match remote_type { + RemoteType::Pve => ("building", tr!("Virtual Environment Nodes")), + RemoteType::Pbs => ("building-o", tr!("Backup Server Nodes")), + }; + + let (nodes_status, failed_remotes) = match status { + Some(status) => { + let nodes_status = match remote_type { + RemoteType::Pve => Some(status.pve_nodes.clone()), + RemoteType::Pbs => Some(status.pbs_nodes.clone()), + }; + let failed_remotes = status + .failed_remotes_list + .iter() + .filter(|item| item.remote_type == remote_type) + .count(); + (nodes_status, failed_remotes) + } + None => (None, 0), + }; + + Panel::new() + .title(create_title_with_icon(icon, title)) + .border(true) + .with_child(NodeStatusPanel::new( + remote_type, + nodes_status, + failed_remotes, + )) +} -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel