From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 86EB81FF0B4 for ; Fri, 27 Nov 2026 17:14:07 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id EB7C021900; Fri, 27 Nov 2026 17:13:15 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager 38/38] ui: views: map: show a summary of the remotes and migrations Date: Fri, 27 Nov 2026 17:12:35 +0100 Message-ID: <20261127161241.3713494-39-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261127161241.3713494-1-d.csapak@proxmox.com> References: <20261127161241.3713494-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.248 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: HDMZXEG5TFUTT42UQ6ONIC7UTNV64XOC X-Message-ID-Hash: HDMZXEG5TFUTT42UQ6ONIC7UTNV64XOC X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: in the corner of the map: how many remotes it shows, how many of them have errors or warnings, and how many migrations are running between them. That way one sees at a glance if something needs attention, also when the map is zoomed in somewhere else. Each part is a button with a menu that lists what it counts. Selecting a remote there opens it, and a migration leads to the remote the guest is migrated away from. Signed-off-by: Dominik Csapak --- ui/src/dashboard/map.rs | 94 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 3 deletions(-) diff --git a/ui/src/dashboard/map.rs b/ui/src/dashboard/map.rs index d486f22d..5ce9736a 100644 --- a/ui/src/dashboard/map.rs +++ b/ui/src/dashboard/map.rs @@ -1,4 +1,5 @@ use std::cell::{OnceCell, RefCell}; +use std::collections::BTreeMap; use std::collections::HashMap; use std::collections::HashSet; use std::hash::Hash; @@ -9,6 +10,7 @@ use futures::future::join_all; use geojson::GeoJson; use serde::Deserialize; use serde_json::json; +use yew::html::Scope; use yew::virtual_dom::{VComp, VNode}; use proxmox_yew_comp::percent_encoding::percent_encode_component; @@ -22,6 +24,7 @@ use pwt::widget::charts::{ render_point_default, render_point_ping, render_point_shares, render_tooltip_default, }; use pwt::widget::container::span; +use pwt::widget::menu::{Menu, MenuButton, MenuEntry, MenuItem}; use pwt::widget::{ActionIcon, Column, Container, Fa, Panel, Row, Tooltip, error_message}; use pwt_macros::{builder, widget}; @@ -322,6 +325,88 @@ impl DashboardMapComp { .collect() } + /// A summary of what the map shows, where each part opens a list that leads to its remotes. + /// + /// Returns `None` if there is nothing on the map. + fn render_status(&self, ctx: &Context) -> Option { + // a remote can be at several points + let remotes: BTreeMap<&str, &RemoteStatus> = self + .points + .iter() + .map(|point| (point.data.remote.name.as_str(), &point.data.remote.status)) + .collect(); + if remotes.is_empty() { + return None; + } + + let remote_item = |link: &Scope, remote: &str, status: &RemoteStatus| { + let link = link.clone(); + let name = remote.to_string(); + let status = match status { + RemoteStatus::Good => Status::Success, + RemoteStatus::Warning => Status::Warning, + RemoteStatus::Error => Status::Error, + RemoteStatus::Unknown => Status::Unknown, + }; + MenuItem::new(remote.to_string()) + .icon_class(classes!("fa", Classes::from(status))) + .on_select(move |_| navigate_to(&link, &name, None)) + }; + // all remotes, or only the ones with the given status + let remote_part = + |icon: Option, only: Option, text: fn(usize) -> String| { + let items: Vec = remotes + .iter() + .filter(|(_, status)| only.as_ref().is_none_or(|only| **status == only)) + .map(|(remote, status)| remote_item(ctx.link(), remote, status).into()) + .collect(); + let mut button = MenuButton::new(text(items.len())); + if let Some(icon) = icon { + button.set_icon_class(classes!("fa", Classes::from(icon))); + } + (!items.is_empty()).then(|| button.menu(Menu::new().items(items))) + }; + + // leads to the remote a guest is migrated away from + let migrations: Vec = self + .connections + .iter() + .filter_map(|connection| { + let link = ctx.link().clone(); + let remote = self.points.get(connection.from)?.data.remote.name.clone(); + let item = MenuItem::new(connection.tooltip.clone()?) + .on_select(move |_| navigate_to(&link, &remote, None)); + Some(item.into()) + }) + .collect(); + let migration_count = migrations.len(); + let migration_part = (migration_count > 0).then(|| { + MenuButton::new(tr!( + "1 Migration" | "{0} Migrations" % migration_count, + migration_count + )) + .icon_class("fa fa-exchange") + .menu(Menu::new().items(migrations)) + }); + + let status = Row::new() + .with_optional_child(remote_part(None, None, |count| { + tr!("1 Remote" | "{0} Remotes" % count, count) + })) + .with_optional_child(remote_part( + Some(Status::Error), + Some(RemoteStatus::Error), + |count| tr!("1 Error" | "{0} Errors" % count, count), + )) + .with_optional_child(remote_part( + Some(Status::Warning), + Some(RemoteStatus::Warning), + |count| tr!("1 Warning" | "{0} Warnings" % count, count), + )) + .with_optional_child(migration_part); + Some(status.into()) + } + fn update_data(&mut self, ctx: &Context) { self.points = Self::calculate_points(ctx); self.connections = self.calculate_connections(ctx); @@ -421,7 +506,7 @@ impl yew::Component for DashboardMapComp { _ => return loading_column().into(), }; - WorldMap::new(geojson) + let mut map = WorldMap::new(geojson) .with_std_props(&props.std_props) .listeners(&props.listeners) .max_zoom_level(100.0) @@ -429,8 +514,11 @@ impl yew::Component for DashboardMapComp { .state_id("PdmWorldMap") .show_labels(true) .points(self.points.clone()) - .connections(self.connections.clone()) - .into() + .connections(self.connections.clone()); + if let Some(status) = self.render_status(ctx) { + map.set_status(status); + } + map.into() } } -- 2.47.3