From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 9AB0B1FF0B4 for ; Fri, 27 Nov 2026 17:14:02 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 8472B218DD; Fri, 27 Nov 2026 17:13:15 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH yew-widget-toolkit 31/38] widget: charts: map: allow showing a status in a corner of the map Date: Fri, 27 Nov 2026 17:12:28 +0100 Message-ID: <20261127161241.3713494-32-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.249 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: I6XN75DYNQRHVFEKHS23EZCTHEQKVDFE X-Message-ID-Hash: I6XN75DYNQRHVFEKHS23EZCTHEQKVDFE 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: so users of the map have a place for a summary of what is on it, without having to position it on top of the map themselves. The WorldMap forwards it. The look and the position are defined in the style sheet with the new 'pwt-map-status' class. Signed-off-by: Dominik Csapak --- src/widget/charts/map/mod.rs | 21 +++++++++++++++++++++ src/widget/charts/world_map.rs | 23 +++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/widget/charts/map/mod.rs b/src/widget/charts/map/mod.rs index 431cc45..400d7c2 100644 --- a/src/widget/charts/map/mod.rs +++ b/src/widget/charts/map/mod.rs @@ -431,6 +431,10 @@ pub struct Map { #[builder] /// Show the labels of the points next to them, where there is room for it. show_labels: bool, + + #[prop_or_default] + /// Shown in a corner of the map, for example a summary of what is on it. + status: Option, } impl Map { @@ -438,6 +442,17 @@ impl Map { pub fn new(map: impl Into) -> Self { yew::props!(Self { map: map.into() }) } + + /// Builder style method to set what is shown in a corner of the map. + pub fn status(mut self, status: impl Into) -> Self { + self.set_status(status); + self + } + + /// Method to set what is shown in a corner of the map. + pub fn set_status(&mut self, status: impl Into) { + self.status = Some(status.into()); + } } pub enum Msg { @@ -1178,6 +1193,11 @@ impl yew::Component for MapComp { ); } + let status = props + .status + .clone() + .map(|status| Container::new().class("pwt-map-status").with_child(status)); + Container::new() .with_std_props(&props.std_props) .listeners(&props.listeners) @@ -1210,6 +1230,7 @@ impl yew::Component for MapComp { )) .with_optional_child(tooltip) .with_optional_child(info) + .with_optional_child(status) .with_child( Row::new() .class("pwt-map-interaction-panel") diff --git a/src/widget/charts/world_map.rs b/src/widget/charts/world_map.rs index 0c4dfcb..da15d74 100644 --- a/src/widget/charts/world_map.rs +++ b/src/widget/charts/world_map.rs @@ -133,6 +133,10 @@ pub struct WorldMap { /// Show the labels of the points next to them. Forwarded to the inner [Map]. show_labels: bool, + #[prop_or_default] + /// Shown in a corner of the map. Forwarded to the inner [Map]. + status: Option, + // the map is big, and it would be compared for every render of the parent otherwise #[derivative(PartialEq(compare_with = "Rc::ptr_eq"))] map_data: Rc, @@ -156,6 +160,17 @@ impl WorldMap { self.state_id = state_id.into_storage_location(); } + /// Builder style method to set what is shown in a corner of the map. + pub fn status(mut self, status: impl Into) -> Self { + self.set_status(status); + self + } + + /// Method to set what is shown in a corner of the map. + pub fn set_status(&mut self, status: impl Into) { + self.status = Some(status.into()); + } + /// Set the points of the map. Converts the List into a list of [MapPoint]. pub fn set_points(&mut self, points: impl Into>>) { self.points = points @@ -535,8 +550,12 @@ impl yew::Component for WorldMapComp { ) .tip(tr!("Show where it is night")); - Map::new(WorldMapShapes { shapes, night }) - .with_std_props(&props.std_props) + let mut map = Map::new(WorldMapShapes { shapes, night }); + if let Some(status) = &props.status { + map.set_status(status.clone()); + } + + map.with_std_props(&props.std_props) .listeners(&props.listeners) .class("pwt-world-map") .tools(vec![night_button.into()]) -- 2.47.3