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: [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	[thread overview]
Message-ID: <20261127161241.3713494-39-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261127161241.3713494-1-d.csapak@proxmox.com>

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 <d.csapak@proxmox.com>
---
 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<Self>) -> Option<Html> {
+        // 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<Self>, 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<Status>, only: Option<RemoteStatus>, text: fn(usize) -> String| {
+                let items: Vec<MenuEntry> = 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<MenuEntry> = 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>) {
         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





  parent reply	other threads:[~2026-11-27 16:14 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 16:11 [PATCH datacenter-manager/proxmox-geojson-data/yew-widget-toolkit/yew-widget-toolkit-assets 00/38] map: show running remote migrations and rework the world map Dominik Csapak
2026-11-27 16:11 ` [PATCH proxmox-geojson-data 01/38] generate the borders between countries as lines without duplicates Dominik Csapak
2026-11-28 19:46   ` Thomas Lamprecht
2026-11-27 16:11 ` [PATCH yew-widget-toolkit-assets 02/38] charts: world map: add classes for the map and its features Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 03/38] charts: map: stack the map and its points in two layers Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 04/38] charts: map: show locations as a dot with a halo Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 05/38] charts: map: show the buttons as one panel Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 06/38] charts: map: add classes for connections Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 07/38] charts: world map: add class for the shade of the night Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 08/38] charts: map: add classes for the shares and the ping of a location Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 09/38] charts: map: add class for the shadow of a connection Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 10/38] charts: map: add class for the labels of locations Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 11/38] charts: map: add class for the status of a map Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 12/38] widget: charts: map: factor out the radius factor of a cluster Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 13/38] widget: charts: map: close the info card with the first click after a drag Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 14/38] widget: menu: open the menu of a button above it if there is no room below Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 15/38] widget: charts: world map: compare the map data by reference Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 16/38] widget: charts: world map: draw polygons as areas and line strings as lines Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 17/38] widget: charts: world map: split the map into one path per region Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 18/38] widget: charts: map: draw the points in an svg element of their own Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 19/38] widget: charts: map: don't render if the pointer moves over the same point Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 20/38] widget: charts: map: keep the tooltip on its points when clustering anew Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 21/38] widget: charts: world map: add a graticule Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 22/38] widget: charts: map: animate changes of the view Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 23/38] widget: charts: map: draw points as a dot with a halo and their count Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 24/38] widget: charts: map: let the style sheet color the zoom buttons Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 25/38] widget: charts: map: allow drawing connections between points Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 26/38] widget: charts: map: allow additional buttons in the panel Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 27/38] widget: charts: world map: allow shading the night Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 28/38] widget: charts: map: add helpers to show shares and to ping a point Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 29/38] widget: charts: map: draw a shadow below connections Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 30/38] widget: charts: map: allow showing labels next to the points Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 31/38] widget: charts: map: allow showing a status in a corner of the map Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 32/38] ui: views: map: only load and parse the world map once Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 33/38] ui: views: map: only format the titles once when sorting Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 34/38] ui: views: map: show running remote migrations Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 35/38] ui: views: map: shade the night on the map Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 36/38] ui: views: map: show the states of a cluster and ping problems Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 37/38] ui: views: map: show the names of the locations Dominik Csapak
2026-11-27 16:12 ` Dominik Csapak [this message]
2026-11-28 23:48 ` [PATCH datacenter-manager/proxmox-geojson-data/yew-widget-toolkit/yew-widget-toolkit-assets 00/38] map: show running remote migrations and rework the world map Thomas Lamprecht

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=20261127161241.3713494-39-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