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 B9E761FF0B7 for ; Mon, 30 Nov 2026 13:53:49 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 7EAC82171F; Mon, 30 Nov 2026 13:53:47 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager v3 7/8] ui: make the default dashboard page configurable Date: Mon, 30 Nov 2026 13:52:41 +0100 Message-ID: <20261130125325.2392967-8-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261130125325.2392967-1-d.csapak@proxmox.com> References: <20261130125325.2392967-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: 5UNRNFKHBMYAOSHLHZTY7MQH4CSYHQM4 X-Message-ID-Hash: 5UNRNFKHBMYAOSHLHZTY7MQH4CSYHQM4 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: by allowing users to select any of their views as the dashboard, saved in the local storage of their browser. The selection is in the 'My Settings' dialog. For that, pass the list of views from the main app through the top nav bar to the dialog. If the selected view does not exist (anymore), show a notice instead of the dashboard. Signed-off-by: Dominik Csapak --- ui/src/dashboard/mod.rs | 7 +++++++ ui/src/dashboard/view.rs | 18 ++++++++++++++++++ ui/src/main.rs | 1 + ui/src/main_menu.rs | 21 +++++++++++++++++++-- ui/src/top_nav_bar.rs | 6 ++++++ ui/src/widget/my_settings_dialog.rs | 27 ++++++++++++++++++++++++++- 6 files changed, 77 insertions(+), 3 deletions(-) diff --git a/ui/src/dashboard/mod.rs b/ui/src/dashboard/mod.rs index 93a2d7f3..ed8e1a52 100644 --- a/ui/src/dashboard/mod.rs +++ b/ui/src/dashboard/mod.rs @@ -1,5 +1,7 @@ use pwt::css; use pwt::prelude::*; +use pwt::props::StorageLocation; +use pwt::state::PersistentState; use pwt::widget::{Column, Fa, Row}; mod top_entities; @@ -54,6 +56,11 @@ pub use refresh_config_edit::create_refresh_config_edit_window; mod resource_tree; pub use resource_tree::create_resource_tree; +/// The view that is selected as dashboard in this browser, `None` for the default dashboard. +pub fn default_dashboard_state() -> PersistentState> { + PersistentState::new(StorageLocation::local("default-dashboard")) +} + fn loading_column() -> Column { Column::new() .padding(4) diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs index 63c35a83..7d88d295 100644 --- a/ui/src/dashboard/view.rs +++ b/ui/src/dashboard/view.rs @@ -740,6 +740,14 @@ fn default_dashboard( } } +/// Whether a request failed because the requested object does not exist. +fn is_not_found(err: &Error) -> bool { + matches!( + err.downcast_ref::(), + Some(proxmox_client::Error::Api(StatusCode::NOT_FOUND, _)) + ) +} + /// Whether a request was refused for lack of privileges. pub(super) fn is_forbidden(err: &Error) -> bool { matches!( @@ -1081,6 +1089,16 @@ impl Component for ViewComp { if !self.template.has_data() { return Progress::new().into(); } + match (&props.view, &self.template.data, &self.template.error) { + (Some(view), None, Some(err)) if is_not_found(err) => { + return empty_state( + "search", + tr!("View not found"), + tr!("The configured view '{0}' was not found.", view), + ); + } + _ => {} + } let may_add_remotes = self .acl_context diff --git a/ui/src/main.rs b/ui/src/main.rs index 0dd00971..1d680a79 100644 --- a/ui/src/main.rs +++ b/ui/src/main.rs @@ -325,6 +325,7 @@ impl Component for DatacenterManagerApp { .with_child( TopNavBar::new(self.running_tasks.clone()) .username(username.clone()) + .view_list(self.view_list.clone()) .on_logout(ctx.link().callback(|_| Msg::Logout)), ) .with_child({ diff --git a/ui/src/main_menu.rs b/ui/src/main_menu.rs index 8d05328d..0524f177 100644 --- a/ui/src/main_menu.rs +++ b/ui/src/main_menu.rs @@ -5,7 +5,7 @@ use yew::virtual_dom::{Key, VComp, VNode}; use pwt::css::{self, Display, FlexFit}; use pwt::prelude::*; -use pwt::state::{NavigationContextExt, Selection}; +use pwt::state::{NavigationContextExt, PersistentState, Selection}; use pwt::widget::nav::{Menu, MenuItem, NavigationDrawer}; use pwt::widget::{Container, Panel, Row, SelectionView, SelectionViewRenderInfo}; @@ -18,6 +18,7 @@ use crate::ceph::CephView; use crate::configuration::subscription_panel::SubscriptionPanel; use crate::configuration::subscription_registry::SubscriptionRegistryProps; use crate::configuration::views::ViewGrid; +use crate::dashboard::default_dashboard_state; use crate::dashboard::view::View; use crate::guests::GuestPanel; use crate::remotes::{DisabledRemote, RemotesPanel}; @@ -63,6 +64,7 @@ impl MainMenu { pub enum Msg { Select(Key), UpdateAcl(AclContext), + UpdateDefaultDashboard, } pub struct PdmMainMenu { @@ -70,6 +72,7 @@ pub struct PdmMainMenu { menu_selection: Selection, acl_context: AclContext, _acl_context_listener: ContextHandle, + default_dashboard: PersistentState>, } fn register_view( @@ -120,11 +123,15 @@ impl Component for PdmMainMenu { .context(ctx.link().callback(Msg::UpdateAcl)) .expect("acl context not present"); + let default_dashboard = default_dashboard_state() + .on_update(ctx.link().callback(|_| Msg::UpdateDefaultDashboard)); + Self { active: Key::from("dashboard"), menu_selection: Selection::new(), acl_context, _acl_context_listener: acl_context_listener, + default_dashboard, } } @@ -138,6 +145,10 @@ impl Component for PdmMainMenu { self.acl_context = acl_context; true } + Msg::UpdateDefaultDashboard => { + self.default_dashboard.load(); + true + } } } @@ -159,6 +170,8 @@ impl Component for PdmMainMenu { let mut menu = Menu::new(); + let default_dashboard: Option = self.default_dashboard.clone().map(|s| s.into()); + register_view( &mut menu, &mut content, @@ -167,7 +180,11 @@ impl Component for PdmMainMenu { Some("fa fa-tachometer"), { let has_views = !props.view_list.is_empty(); - move |_| View::new(None).has_views(has_views).into() + move |_| { + View::new(default_dashboard.clone()) + .has_views(has_views) + .into() + } }, ); diff --git a/ui/src/top_nav_bar.rs b/ui/src/top_nav_bar.rs index 09da5a2d..2090b440 100644 --- a/ui/src/top_nav_bar.rs +++ b/ui/src/top_nav_bar.rs @@ -49,6 +49,11 @@ pub struct TopNavBar { #[builder(IntoPropValue, into_prop_value)] #[prop_or_default] pub username: Option, + + /// The views that can be selected as dashboard in the settings. + #[builder] + #[prop_or_default] + pub view_list: Vec, } impl TopNavBar { @@ -255,6 +260,7 @@ impl Component for PdmTopNavBar { let dialog: Option = self.view_state.as_ref().map(|view_state| match view_state { ViewState::MySettingsDialog => MySettingsDialog::new() + .view_list(props.view_list.clone()) .on_close(ctx.link().callback(|_| Msg::ChangeView(None))) .into(), ViewState::LanguageDialog => LanguageDialog::new() diff --git a/ui/src/widget/my_settings_dialog.rs b/ui/src/widget/my_settings_dialog.rs index c18c5519..f2323bdb 100644 --- a/ui/src/widget/my_settings_dialog.rs +++ b/ui/src/widget/my_settings_dialog.rs @@ -14,6 +14,7 @@ use pwt::widget::{Button, Container, Dialog, InputPanel, Row}; use pwt_macros::builder; +use crate::dashboard::default_dashboard_state; use crate::pve::utils::novnc_scaling_state; // The xterm.js console uses the text of its local storage entries as is, so they cannot be saved @@ -74,6 +75,11 @@ pub struct MySettingsDialog { #[builder_cb(IntoEventCallback, into_event_callback, ())] #[prop_or_default] pub on_close: Option>, + + /// The views that can be selected as dashboard. + #[builder] + #[prop_or_default] + pub view_list: Vec, } impl Default for MySettingsDialog { @@ -89,6 +95,7 @@ impl MySettingsDialog { } pub enum Msg { + DefaultDashboard(String), XtermFormChange, XtermSave, XtermReset, @@ -97,6 +104,7 @@ pub enum Msg { #[doc(hidden)] pub struct PdmMySettingsDialog { + default_dashboard: PersistentState>, xterm_form: FormContext, xterm_saved: XtermSettings, novnc_scaling: PersistentState>, @@ -119,6 +127,7 @@ impl Component for PdmMySettingsDialog { fn create(ctx: &Context) -> Self { Self { + default_dashboard: default_dashboard_state(), xterm_form: FormContext::new().on_change(ctx.link().callback(|_| Msg::XtermFormChange)), xterm_saved: XtermSettings::load(), novnc_scaling: novnc_scaling_state(), @@ -127,6 +136,11 @@ impl Component for PdmMySettingsDialog { fn update(&mut self, _ctx: &Context, msg: Self::Message) -> bool { match msg { + Msg::DefaultDashboard(view) => { + self.default_dashboard + .update((!view.is_empty()).then_some(view)); + false + } Msg::XtermFormChange => true, Msg::XtermSave => { if let Some(settings) = self.current_valid_xterm_settings() { @@ -165,9 +179,20 @@ impl Component for PdmMySettingsDialog { .with_child(title) }; + let views = props.view_list.iter().map(|view| view.clone().into()); + let panel = InputPanel::new() .padding(4) - .with_custom_child(section_title(tr!("xterm.js Settings"))) + .with_custom_child(section_title(tr!("Web Interface Settings"))) + .with_field( + tr!("Dashboard"), + Combobox::new() + .items(Rc::new(views.collect())) + .placeholder(tr!("Default")) + .default(self.default_dashboard.clone()) + .on_change(link.callback(Msg::DefaultDashboard)), + ) + .with_custom_child(section_title(tr!("xterm.js Settings")).padding_top(2)) .with_field( tr!("Font-Family"), Field::new() -- 2.47.3