public inbox for pdm-devel@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 v3 03/21] ui: dashboard: node panel: make remote type optional
Date: Fri, 31 Oct 2025 13:43:46 +0100	[thread overview]
Message-ID: <20251031124822.2739685-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20251031124822.2739685-1-d.csapak@proxmox.com>

and if it's `None` show a summary of all nodes, regardless of remote type.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/dashboard/mod.rs               |  4 +--
 ui/src/dashboard/node_status_panel.rs | 49 +++++++++++++++++++--------
 2 files changed, 36 insertions(+), 17 deletions(-)

diff --git a/ui/src/dashboard/mod.rs b/ui/src/dashboard/mod.rs
index 3b5b3b50..c9b1c014 100644
--- a/ui/src/dashboard/mod.rs
+++ b/ui/src/dashboard/mod.rs
@@ -470,7 +470,7 @@ impl Component for PdmDashboard {
                             .with_child(RemotePanel::new(self.status.clone())),
                     )
                     .with_child(
-                        create_node_panel(RemoteType::Pve, self.status.clone())
+                        create_node_panel(Some(RemoteType::Pve), self.status.clone())
                             .flex(1.0)
                             .width(300),
                     )
@@ -485,7 +485,7 @@ impl Component for PdmDashboard {
                             .width(300),
                     )
                     .with_child(
-                        create_node_panel(RemoteType::Pbs, self.status.clone())
+                        create_node_panel(Some(RemoteType::Pbs), self.status.clone())
                             .flex(1.0)
                             .width(300),
                     )
diff --git a/ui/src/dashboard/node_status_panel.rs b/ui/src/dashboard/node_status_panel.rs
index c66d82e6..0873635d 100644
--- a/ui/src/dashboard/node_status_panel.rs
+++ b/ui/src/dashboard/node_status_panel.rs
@@ -18,14 +18,17 @@ use super::loading_column;
 
 #[derive(PartialEq, Clone, Properties)]
 pub struct NodeStatusPanel {
-    remote_type: RemoteType,
+    remote_type: Option<RemoteType>,
     status: Option<NodeStatusCount>,
     failed_remotes: usize,
 }
 
 impl NodeStatusPanel {
+    /// Create a node status panel.
+    ///
+    /// Passing `None` to `remote_type` means creating a panel for all nodes, regardless of remote type.
     pub fn new(
-        remote_type: RemoteType,
+        remote_type: Option<RemoteType>,
         status: Option<NodeStatusCount>,
         failed_remotes: usize,
     ) -> Self {
@@ -95,13 +98,14 @@ impl yew::Component for NodeStatusPanelComponent {
 
 fn map_status(
     status: &NodeStatusCount,
-    remote_type: RemoteType,
+    remote_type: Option<RemoteType>,
     failed_remotes: usize,
 ) -> (Fa, String, Vec<SearchTerm>) {
-    let mut search_terms = vec![
-        SearchTerm::new("node").category(Some("type")),
-        SearchTerm::new(remote_type.to_string()).category(Some("remote-type")),
-    ];
+    let mut search_terms = vec![SearchTerm::new("node").category(Some("type"))];
+
+    if let Some(remote_type) = remote_type {
+        search_terms.push(SearchTerm::new(remote_type.to_string()).category(Some("remote-type")));
+    }
     let (icon, status_msg) = match status {
         NodeStatusCount {
             online,
@@ -126,11 +130,11 @@ fn map_status(
             )
         }
         NodeStatusCount { online, .. } if failed_remotes > 0 => match remote_type {
-            RemoteType::Pve => (
+            Some(RemoteType::Pve) | None => (
                 Status::Unknown.into(),
                 tr!("{0} of an unknown number of nodes online", online),
             ),
-            RemoteType::Pbs => (
+            Some(RemoteType::Pbs) => (
                 Status::Error.into(),
                 tr!("{0} remotes failed", failed_remotes),
             ),
@@ -141,22 +145,37 @@ fn map_status(
     (icon, status_msg, search_terms)
 }
 
-pub fn create_node_panel(remote_type: RemoteType, status: Option<ResourcesStatus>) -> Panel {
+/// Create a node status panel.
+///
+/// Passing `None` to `remote_type` means creating a panel for all nodes, regardless of remote type.
+pub fn create_node_panel(
+    remote_type: Option<RemoteType>,
+    status: Option<ResourcesStatus>,
+) -> Panel {
     let (icon, title) = match remote_type {
-        RemoteType::Pve => ("building", tr!("Virtual Environment Nodes")),
-        RemoteType::Pbs => ("building-o", tr!("Backup Server Nodes")),
+        Some(RemoteType::Pve) => ("building", tr!("Virtual Environment Nodes")),
+        Some(RemoteType::Pbs) => ("building-o", tr!("Backup Server Nodes")),
+        None => ("building", tr!("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()),
+                Some(RemoteType::Pve) => Some(status.pve_nodes.clone()),
+                Some(RemoteType::Pbs) => Some(status.pbs_nodes.clone()),
+                None => Some(NodeStatusCount {
+                    online: status.pve_nodes.online + status.pbs_nodes.online,
+                    offline: status.pve_nodes.offline + status.pbs_nodes.offline,
+                    unknown: status.pve_nodes.unknown + status.pbs_nodes.unknown,
+                }),
             };
             let failed_remotes = status
                 .failed_remotes_list
                 .iter()
-                .filter(|item| item.remote_type == remote_type)
+                .filter(|item| match remote_type {
+                    Some(remote_type) => item.remote_type == remote_type,
+                    None => true,
+                })
                 .count();
             (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


  parent reply	other threads:[~2025-10-31 12:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-31 12:43 [pdm-devel] [PATCH datacenter-manager v3 00/21] prepare ui for customizable views Dominik Csapak
2025-10-31 12:43 ` [pdm-devel] [PATCH datacenter-manager v3 01/21] ui: dashboard: refactor guest panel creation to its own module Dominik Csapak
2025-10-31 12:43 ` [pdm-devel] [PATCH datacenter-manager v3 02/21] ui: dashboard: refactor creating the node panel into " Dominik Csapak
2025-10-31 12:43 ` Dominik Csapak [this message]
2025-10-31 12:43 ` [pdm-devel] [PATCH datacenter-manager v3 04/21] ui: dashboard: refactor remote panel creation " Dominik Csapak
2025-10-31 12:43 ` [pdm-devel] [PATCH datacenter-manager v3 05/21] ui: dashboard: remote panel: make wizard menu optional Dominik Csapak
2025-10-31 12:43 ` [pdm-devel] [PATCH datacenter-manager v3 06/21] ui: dashboard: refactor sdn panel creation into its own module Dominik Csapak
2025-10-31 12:43 ` [pdm-devel] [PATCH datacenter-manager v3 07/21] ui: dashboard: refactor task summary panel creation to " Dominik Csapak
2025-10-31 12:43 ` [pdm-devel] [PATCH datacenter-manager v3 08/21] ui: dashboard: task summary: disable virtual scrolling Dominik Csapak
2025-10-31 12:43 ` [pdm-devel] [PATCH datacenter-manager v3 09/21] ui: dashboard: refactor subscription panel creation to its own module Dominik Csapak
2025-10-31 12:43 ` [pdm-devel] [PATCH datacenter-manager v3 10/21] ui: dashboard: refactor top entities " Dominik Csapak
2025-10-31 12:43 ` [pdm-devel] [PATCH datacenter-manager v3 11/21] ui: dashboard: refactor DashboardConfig editing/constants to their module Dominik Csapak
2025-10-31 12:43 ` [pdm-devel] [PATCH datacenter-manager v3 12/21] ui: dashboard: factor out task parameter calculation Dominik Csapak
2025-10-31 12:43 ` [pdm-devel] [PATCH datacenter-manager v3 13/21] ui: dashboard: pbs datastores panel: refactor creation into own module Dominik Csapak
2025-10-31 12:43 ` [pdm-devel] [PATCH datacenter-manager v3 14/21] ui: dashboard: remove unused remote list Dominik Csapak
2025-10-31 12:43 ` [pdm-devel] [PATCH datacenter-manager v3 15/21] ui: dashboard: status row: make loading less jarring Dominik Csapak
2025-10-31 12:43 ` [pdm-devel] [PATCH datacenter-manager v3 16/21] ui: introduce `LoadResult` helper type Dominik Csapak
2025-10-31 12:44 ` [pdm-devel] [PATCH datacenter-manager v3 17/21] ui: dashboard: implement 'View' Dominik Csapak
2025-10-31 12:44 ` [pdm-devel] [PATCH datacenter-manager v3 18/21] ui: dashboard: use 'View' instead of the Dashboard Dominik Csapak
2025-10-31 12:44 ` [pdm-devel] [PATCH datacenter-manager v3 19/21] ui: dashboard: subscription info: move subscription loading to view Dominik Csapak
2025-10-31 12:44 ` [pdm-devel] [PATCH datacenter-manager v3 20/21] ui: dashboard: use SharedState for create_*_panel Dominik Csapak
2025-10-31 12:44 ` [pdm-devel] [PATCH datacenter-manager v3 21/21] ui: dashboard: enable editing view Dominik Csapak

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=20251031124822.2739685-4-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal