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 044F11FF0B3 for ; Thu, 26 Nov 2026 15:54:39 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 62EA621754; Thu, 26 Nov 2026 15:54:34 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager 02/10] ui: views: keep the icon for custom widget titles Date: Thu, 26 Nov 2026 15:49:15 +0100 Message-ID: <20261126145410.3011676-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261126145410.3011676-1-d.csapak@proxmox.com> References: <20261126145410.3011676-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.258 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: LCGCEJ7JC3NU6KQOCELTQEZUVMG65SFS X-Message-ID-Hash: LCGCEJ7JC3NU6KQOCELTQEZUVMG65SFS 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: a custom title replaced the whole title of the panel, including its icon, since the icon was part of the title the panel creators set. Move the default icons and titles of all widgets into one function and set the title when rendering the widget, so a custom title only replaces the text. Signed-off-by: Dominik Csapak --- ui/src/dashboard/gauge_panel.rs | 22 +---- ui/src/dashboard/guest_panel.rs | 7 -- ui/src/dashboard/node_status_panel.rs | 8 -- ui/src/dashboard/pbs_datastores_panel.rs | 5 - ui/src/dashboard/remote_panel.rs | 6 +- ui/src/dashboard/resource_tree.rs | 1 - ui/src/dashboard/sdn_zone_panel.rs | 5 +- ui/src/dashboard/subscription_info.rs | 8 -- ui/src/dashboard/tasks.rs | 24 ++--- ui/src/dashboard/top_entities.rs | 50 +++++----- ui/src/dashboard/view.rs | 112 ++++++++++++++++++----- 11 files changed, 122 insertions(+), 126 deletions(-) diff --git a/ui/src/dashboard/gauge_panel.rs b/ui/src/dashboard/gauge_panel.rs index 24d0f323..b697ec0e 100644 --- a/ui/src/dashboard/gauge_panel.rs +++ b/ui/src/dashboard/gauge_panel.rs @@ -12,15 +12,13 @@ use pdm_api_types::remotes::RemoteType; use pdm_api_types::{resource::ResourcesStatus, views::NodeResourceType}; use crate::LoadResult; -use crate::dashboard::{create_title_with_icon, loading_column}; +use crate::dashboard::loading_column; struct PanelConfig { show_cpu: bool, show_mem: bool, show_storage: bool, - title: String, subtitle: bool, - icon: &'static str, } impl PanelConfig { @@ -30,33 +28,25 @@ impl PanelConfig { show_cpu: true, show_mem: false, show_storage: false, - title: tr!("CPU Usage"), subtitle: false, - icon: "cpu", }, Some(NodeResourceType::Memory) => PanelConfig { show_cpu: false, show_mem: true, show_storage: false, - title: tr!("Memory Usage"), subtitle: false, - icon: "memory", }, Some(NodeResourceType::Storage) => PanelConfig { show_cpu: false, show_mem: false, show_storage: true, - title: tr!("Storage Usage"), subtitle: false, - icon: "database", }, None => PanelConfig { show_cpu: true, show_mem: true, show_storage: true, - title: tr!("Resource Usage"), subtitle: true, - icon: "tachometer", }, } } @@ -74,19 +64,9 @@ pub fn create_gauge_panel( let status = status.read(); let conf = PanelConfig::new(resource_type); - let suffix = match remote_type { - Some(RemoteType::Pve) => " - Virtual Environment", - Some(RemoteType::Pbs) => " - Backup Server", - None => "", - }; - let is_loading = !status.has_data(); Panel::new() - .title(create_title_with_icon( - conf.icon, - format!("{}{suffix}", conf.title), - )) .border(true) .with_optional_child(status.data.as_ref().map(|data| { let (cpu, mem, storage) = match remote_type { diff --git a/ui/src/dashboard/guest_panel.rs b/ui/src/dashboard/guest_panel.rs index 2a5b4fca..b962d09d 100644 --- a/ui/src/dashboard/guest_panel.rs +++ b/ui/src/dashboard/guest_panel.rs @@ -16,7 +16,6 @@ use pdm_api_types::resource::{GuestStatusCount, ResourceType, ResourcesStatus}; use pdm_search::{Search, SearchTerm}; use crate::LoadResult; -use crate::dashboard::create_title_with_icon; use crate::dashboard::view::add_current_view_to_search; use crate::pve::GuestType; use crate::search_provider::get_search_provider; @@ -220,14 +219,8 @@ pub fn create_guest_panel( guest_type: Option, status: SharedState>, ) -> Panel { - let (icon, title) = match guest_type { - Some(GuestType::Qemu) => ("desktop", tr!("Virtual Machines")), - Some(GuestType::Lxc) => ("cubes", tr!("Linux Containers")), - None => ("desktop", tr!("Guests")), - }; let status = status.read(); Panel::new() - .title(create_title_with_icon(icon, title)) .with_child(GuestPanel::new(guest_type, status.data.clone())) .with_optional_child( status diff --git a/ui/src/dashboard/node_status_panel.rs b/ui/src/dashboard/node_status_panel.rs index 6bfcf85f..18fd648e 100644 --- a/ui/src/dashboard/node_status_panel.rs +++ b/ui/src/dashboard/node_status_panel.rs @@ -14,7 +14,6 @@ use pdm_api_types::resource::NodeStatusCount; use pdm_api_types::{remotes::RemoteType, resource::ResourcesStatus}; use crate::LoadResult; -use crate::dashboard::create_title_with_icon; use crate::dashboard::view::add_current_view_to_search; use crate::search_provider::get_search_provider; @@ -161,12 +160,6 @@ pub fn create_node_panel( remote_type: Option, status: SharedState>, ) -> Panel { - let (icon, title) = match remote_type { - Some(RemoteType::Pve) => ("building", tr!("Virtual Environment Nodes")), - Some(RemoteType::Pbs) => ("building-o", tr!("Backup Server Nodes")), - None => ("building", tr!("Nodes")), - }; - let status = status.read(); let (nodes_status, failed_remotes) = match &status.data { @@ -194,7 +187,6 @@ pub fn create_node_panel( }; Panel::new() - .title(create_title_with_icon(icon, title)) .border(true) .with_child(NodeStatusPanel::new( remote_type, diff --git a/ui/src/dashboard/pbs_datastores_panel.rs b/ui/src/dashboard/pbs_datastores_panel.rs index ba7c9b89..2bb1cfe6 100644 --- a/ui/src/dashboard/pbs_datastores_panel.rs +++ b/ui/src/dashboard/pbs_datastores_panel.rs @@ -12,7 +12,6 @@ use pwt::state::SharedState; use pwt::widget::{Container, Fa, List, ListTile, Panel}; use crate::LoadResult; -use crate::dashboard::create_title_with_icon; use crate::dashboard::view::add_current_view_to_search; use crate::search_provider::get_search_provider; @@ -170,10 +169,6 @@ pub fn create_pbs_datastores_panel( .map(|status| status.pbs_datastores.clone()); Panel::new() - .title(create_title_with_icon( - "database", - tr!("Backup Server Datastores"), - )) .border(true) .with_child(PbsDatastoresPanel::new(pbs_datastores)) } diff --git a/ui/src/dashboard/remote_panel.rs b/ui/src/dashboard/remote_panel.rs index 2e631d7c..bc2cf8b2 100644 --- a/ui/src/dashboard/remote_panel.rs +++ b/ui/src/dashboard/remote_panel.rs @@ -17,7 +17,7 @@ use pdm_api_types::resource::ResourcesStatus; use crate::LoadResult; use crate::dashboard::view::add_current_view_to_search; -use crate::{dashboard::create_title_with_icon, search_provider::get_search_provider}; +use crate::search_provider::get_search_provider; #[derive(Properties, PartialEq)] /// A panel for showing the overall remotes status @@ -148,9 +148,7 @@ pub fn create_remote_panel( on_pbs_wizard: Option>, ) -> Panel { let status = status.read(); - let mut panel = Panel::new() - .title(create_title_with_icon("server", tr!("Remotes"))) - .with_child(RemotePanel::new(status.data.clone())); + let mut panel = Panel::new().with_child(RemotePanel::new(status.data.clone())); if on_pve_wizard.is_some() || on_pbs_wizard.is_some() { let mut menu = Menu::new(); diff --git a/ui/src/dashboard/resource_tree.rs b/ui/src/dashboard/resource_tree.rs index 51f2d1d2..4b233fc2 100644 --- a/ui/src/dashboard/resource_tree.rs +++ b/ui/src/dashboard/resource_tree.rs @@ -48,6 +48,5 @@ fn ResourceTreeWithSearch(props: &ResourceTreeWithSearchProps) -> Html { pub fn create_resource_tree(redraw_controller: RedrawController) -> Panel { Panel::new() .class(css::FlexFit) - .title(tr!("Resources")) .with_child(html! {}) } diff --git a/ui/src/dashboard/sdn_zone_panel.rs b/ui/src/dashboard/sdn_zone_panel.rs index 24b0299f..5d5328db 100644 --- a/ui/src/dashboard/sdn_zone_panel.rs +++ b/ui/src/dashboard/sdn_zone_panel.rs @@ -16,7 +16,6 @@ use yew::{ }; use crate::LoadResult; -use crate::dashboard::create_title_with_icon; use crate::dashboard::view::add_current_view_to_search; use crate::search_provider::get_search_provider; @@ -175,7 +174,5 @@ pub fn create_sdn_panel(status: SharedState>) .as_ref() .map(|status| status.sdn_zones.clone()); - Panel::new() - .title(create_title_with_icon("sdn", tr!("SDN Zones"))) - .with_child(SdnZonePanel::new(sdn_zones_status)) + Panel::new().with_child(SdnZonePanel::new(sdn_zones_status)) } diff --git a/ui/src/dashboard/subscription_info.rs b/ui/src/dashboard/subscription_info.rs index a344010b..d19896a4 100644 --- a/ui/src/dashboard/subscription_info.rs +++ b/ui/src/dashboard/subscription_info.rs @@ -157,15 +157,7 @@ pub fn create_subscription_panel( subs: SharedState, Error>>, on_details_clicked: Callback, ) -> Panel { - let title: Html = Row::new() - .class(AlignItems::Center) - .gap(2) - .with_child(Fa::new("ticket")) - .with_child(tr!("Remote Subscription Status")) - .into(); - let mut panel = Panel::new() - .title(title) .border(true) .with_child(SubscriptionInfo::new(subs.read().data.clone())); diff --git a/ui/src/dashboard/tasks.rs b/ui/src/dashboard/tasks.rs index 9c91fab2..06ba49de 100644 --- a/ui/src/dashboard/tasks.rs +++ b/ui/src/dashboard/tasks.rs @@ -22,7 +22,6 @@ use pwt_macros::{builder, widget}; use pdm_api_types::TaskStatistics; use crate::LoadResult; -use crate::dashboard::create_title_with_icon; use crate::dashboard::loading_column; use crate::dashboard::refresh_config_edit::DEFAULT_TASK_SUMMARY_HOURS; use crate::tasks::TaskWorkerType; @@ -308,27 +307,20 @@ impl Component for ProxmoxTaskSummary { pub fn create_task_summary_panel( statistics: SharedState>, remotes: Option, - hours: u32, since: i64, ) -> Panel { - let title = match remotes { - Some(_count) => tr!("Task Summary Sorted by Failed Tasks (Last {0}h)", hours), - None => tr!("Task Summary by Category (Last {0}h)", hours), - }; let loading = !statistics.read().has_data(); let guard = statistics.read(); let data = guard.data.clone(); let error = guard.error.as_ref(); - Panel::new() - .title(create_title_with_icon("list", title)) - .with_child( - Container::new() - .class(css::FlexFit) - .padding(2) - .with_optional_child(data.map(|data| TaskSummary::new(data, since, remotes))) - .with_optional_child((loading).then_some(loading_column())) - .with_optional_child(error.map(|err| error_message(&err.to_string()))), - ) + Panel::new().with_child( + Container::new() + .class(css::FlexFit) + .padding(2) + .with_optional_child(data.map(|data| TaskSummary::new(data, since, remotes))) + .with_optional_child((loading).then_some(loading_column())) + .with_optional_child(error.map(|err| error_message(&err.to_string()))), + ) } pub fn get_task_options(last_hours: Option) -> (u32, i64) { diff --git a/ui/src/dashboard/top_entities.rs b/ui/src/dashboard/top_entities.rs index cdc3b465..122f8287 100644 --- a/ui/src/dashboard/top_entities.rs +++ b/ui/src/dashboard/top_entities.rs @@ -24,7 +24,7 @@ use pdm_client::types::{Resource, TopEntity}; use crate::LoadResult; use crate::{ - dashboard::{create_title_with_icon, loading_column}, + dashboard::loading_column, get_deep_url, navigate_to, renderer::{render_resource_icon, render_resource_name}, }; @@ -338,35 +338,27 @@ pub fn create_top_entities_panel( leaderboard_type: LeaderboardType, ) -> Panel { let top_entities = top_entities.read(); - let (entities, icon, title, metrics_title, metrics_empty_message, threshold) = - match leaderboard_type { - LeaderboardType::GuestCpu => ( - top_entities.data.as_ref().map(|e| e.guest_cpu.clone()), - "desktop", - tr!("Guests With the Highest CPU Usage"), - tr!("CPU usage"), - tr!("No guests available"), - 0.85, - ), - LeaderboardType::NodeCpu => ( - top_entities.data.as_ref().map(|e| e.node_cpu.clone()), - "building", - tr!("Nodes With the Highest CPU Usage"), - tr!("CPU usage"), - tr!("No nodes available"), - 0.85, - ), - LeaderboardType::NodeMemory => ( - top_entities.data.as_ref().map(|e| e.node_memory.clone()), - "building", - tr!("Nodes With the Highest Memory Usage"), - tr!("Memory usage"), - tr!("No nodes available"), - 0.95, - ), - }; + let (entities, metrics_title, metrics_empty_message, threshold) = match leaderboard_type { + LeaderboardType::GuestCpu => ( + top_entities.data.as_ref().map(|e| e.guest_cpu.clone()), + tr!("CPU usage"), + tr!("No guests available"), + 0.85, + ), + LeaderboardType::NodeCpu => ( + top_entities.data.as_ref().map(|e| e.node_cpu.clone()), + tr!("CPU usage"), + tr!("No nodes available"), + 0.85, + ), + LeaderboardType::NodeMemory => ( + top_entities.data.as_ref().map(|e| e.node_memory.clone()), + tr!("Memory usage"), + tr!("No nodes available"), + 0.95, + ), + }; Panel::new() - .title(create_title_with_icon(icon, title)) .with_optional_child(entities.and_then(|entities| { let html: Html = if entities.is_empty() { Row::new() diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs index 64480310..8d8f83a9 100644 --- a/ui/src/dashboard/view.rs +++ b/ui/src/dashboard/view.rs @@ -28,7 +28,7 @@ use crate::dashboard::{ DashboardStatusRow, create_gauge_panel, create_guest_panel, create_map_panel, create_node_panel, create_pbs_datastores_panel, create_refresh_config_edit_window, create_remote_panel, create_resource_tree, create_sdn_panel, create_subscription_panel, - create_task_summary_panel, create_top_entities_panel, + create_task_summary_panel, create_title_with_icon, create_top_entities_panel, }; use crate::remotes::AddWizard; use crate::renderer::empty_state; @@ -36,10 +36,11 @@ use crate::widget::RedrawController; use crate::{LoadResult, RemoteList, pdm_client}; use pdm_api_types::remotes::RemoteType; -use pdm_api_types::resource::ResourcesStatus; +use pdm_api_types::resource::{GuestType, ResourcesStatus}; use pdm_api_types::subscription::RemoteSubscriptions; use pdm_api_types::views::{ - RowWidget, TaskSummaryGrouping, ViewConfig, ViewLayout, ViewTemplate, WidgetType, + LeaderboardType, NodeResourceType, RowWidget, TaskSummaryGrouping, ViewConfig, ViewLayout, + ViewTemplate, WidgetType, }; use pdm_api_types::{CachedLocationInfo, TaskStatistics}; use pdm_client::types::TopEntities; @@ -149,6 +150,8 @@ fn render_widget( redraw_controller, } = render_args; + let (task_hours, task_since) = get_task_options(refresh_config.task_last_hours); + let mut widget = match &item.r#type { WidgetType::Nodes { remote_type } => create_node_panel(*remote_type, status), WidgetType::Guests { guest_type } => { @@ -174,8 +177,7 @@ fn render_widget( TaskSummaryGrouping::Category => None, TaskSummaryGrouping::Remote => Some(5), }; - let (hours, since) = get_task_options(refresh_config.task_last_hours); - create_task_summary_panel(statistics, remotes, hours, since) + create_task_summary_panel(statistics, remotes, task_since) } WidgetType::ResourceTree => create_resource_tree(redraw_controller), WidgetType::NodeResourceGauge { @@ -186,13 +188,80 @@ fn render_widget( WidgetType::UnknownWidget { widget_type, .. } => create_unknown_widget_panel(widget_type), }; - if let Some(title) = &item.title { - widget.set_title(title.clone()); + let (icon, default_title) = default_widget_title(&item.r#type, task_hours); + if let Some(title) = item.title.clone().or(default_title) { + match icon { + Some(icon) => widget.set_title(create_title_with_icon(icon, title)), + None => widget.set_title(title), + } } widget.border(false).class(css::FlexFit).into() } +/// Returns the default icon and title of a widget, if it has any. +fn default_widget_title( + widget_type: &WidgetType, + task_hours: u32, +) -> (Option<&'static str>, Option) { + let (icon, title) = match widget_type { + WidgetType::Nodes { remote_type } => match remote_type { + Some(RemoteType::Pve) => ("building", tr!("Virtual Environment Nodes")), + Some(RemoteType::Pbs) => ("building-o", tr!("Backup Server Nodes")), + None => ("building", tr!("Nodes")), + }, + WidgetType::Guests { guest_type } => match guest_type { + Some(GuestType::Qemu) => ("desktop", tr!("Virtual Machines")), + Some(GuestType::Lxc) => ("cubes", tr!("Linux Containers")), + None => ("desktop", tr!("Guests")), + }, + WidgetType::PbsDatastores => ("database", tr!("Backup Server Datastores")), + WidgetType::Remotes { .. } => ("server", tr!("Remotes")), + WidgetType::Subscription => ("ticket", tr!("Remote Subscription Status")), + WidgetType::Sdn => ("sdn", tr!("SDN Zones")), + WidgetType::Leaderboard { leaderboard_type } => match leaderboard_type { + LeaderboardType::GuestCpu => ("desktop", tr!("Guests With the Highest CPU Usage")), + LeaderboardType::NodeCpu => ("building", tr!("Nodes With the Highest CPU Usage")), + LeaderboardType::NodeMemory => ("building", tr!("Nodes With the Highest Memory Usage")), + }, + WidgetType::TaskSummary { grouping } => match grouping { + TaskSummaryGrouping::Category => ( + "list", + tr!("Task Summary by Category (Last {0}h)", task_hours), + ), + TaskSummaryGrouping::Remote => ( + "list", + tr!( + "Task Summary Sorted by Failed Tasks (Last {0}h)", + task_hours + ), + ), + }, + WidgetType::NodeResourceGauge { + resource, + remote_type, + } => { + let (icon, title) = match resource { + Some(NodeResourceType::Cpu) => ("cpu", tr!("CPU Usage")), + Some(NodeResourceType::Memory) => ("memory", tr!("Memory Usage")), + Some(NodeResourceType::Storage) => ("database", tr!("Storage Usage")), + None => ("tachometer", tr!("Resource Usage")), + }; + let suffix = match remote_type { + Some(RemoteType::Pve) => " - Virtual Environment", + Some(RemoteType::Pbs) => " - Backup Server", + None => "", + }; + (icon, format!("{title}{suffix}")) + } + WidgetType::ResourceTree => return (None, Some(tr!("Resources"))), + WidgetType::Map => return (None, None), + WidgetType::UnknownWidget { .. } => return (None, Some(tr!("Unknown Widget"))), + }; + + (Some(icon), Some(title)) +} + impl ViewComp { fn reload(&mut self, ctx: &yew::Context) { let max_age = if self.load_finished_time.is_some() { @@ -790,20 +859,17 @@ pub fn add_current_view_to_search(ctx: &yew::Context, sear } fn create_unknown_widget_panel(widget_type: &str) -> Panel { - Panel::new() - .title(tr!("Unknown Widget")) - .border(true) - .with_child( - Column::new() - .class(css::FlexFit) - .class(css::JustifyContent::Center) - .class(css::AlignItems::Center) - .with_child( - Row::new() - .gap(1) - .class(css::AlignItems::Center) - .with_child(Fa::from(Status::Warning).large_2x()) - .with_child(span(tr!("Unknown Widget of type '{0}'", widget_type))), - ), - ) + Panel::new().border(true).with_child( + Column::new() + .class(css::FlexFit) + .class(css::JustifyContent::Center) + .class(css::AlignItems::Center) + .with_child( + Row::new() + .gap(1) + .class(css::AlignItems::Center) + .with_child(Fa::from(Status::Warning).large_2x()) + .with_child(span(tr!("Unknown Widget of type '{0}'", widget_type))), + ), + ) } -- 2.47.3