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 8CB5F1FF0B4 for ; Fri, 27 Nov 2026 18:10:06 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 9122C21791; Fri, 27 Nov 2026 18:10:04 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager v2 6/6] ui: make the default dashboard page configurable Date: Fri, 27 Nov 2026 18:09:27 +0100 Message-ID: <20261127170941.4183880-7-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261127170941.4183880-1-d.csapak@proxmox.com> References: <20261127170941.4183880-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.247 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: HJQWHSQNQVPOQFPHQ4VS7ZH2HVQ56KVB X-Message-ID-Hash: HJQWHSQNQVPOQFPHQ4VS7ZH2HVQ56KVB 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 to set the user any view as their dashboard, saved in their local browser storage. 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 view is not found in the global view list, show a notice for that. Signed-off-by: Dominik Csapak --- ui/src/dashboard/view.rs | 18 ++++++++++++++-- ui/src/main.rs | 1 + ui/src/main_menu.rs | 32 +++++++++++++++++++++++++---- ui/src/top_nav_bar.rs | 6 ++++++ ui/src/widget/my_settings_dialog.rs | 26 ++++++++++++++++++++++- 5 files changed, 76 insertions(+), 7 deletions(-) diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs index 64480310..24678fed 100644 --- a/ui/src/dashboard/view.rs +++ b/ui/src/dashboard/view.rs @@ -60,6 +60,7 @@ pub enum EditingMessage { #[derive(Properties, PartialEq)] pub struct View { view: Option, + not_found: bool, } impl From for VNode { @@ -70,8 +71,11 @@ impl From for VNode { } impl View { - pub fn new(view: impl Into>) -> Self { - Self { view: view.into() } + pub fn new(view: impl Into>, not_found: bool) -> Self { + Self { + view: view.into(), + not_found, + } } } @@ -521,6 +525,16 @@ impl Component for ViewComp { fn view(&self, ctx: &yew::Context) -> yew::Html { let props = ctx.props(); let link = ctx.link(); + match props.view.clone() { + Some(view) if props.not_found => { + return empty_state( + "search", + tr!("View not found"), + tr!("The configured view '{0}' was not found.", view), + ); + } + _ => {} + } if !self.template.has_data() { return Progress::new().into(); } diff --git a/ui/src/main.rs b/ui/src/main.rs index 009e6a38..7642fb55 100644 --- a/ui/src/main.rs +++ b/ui/src/main.rs @@ -307,6 +307,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 8e36717e..4e85f562 100644 --- a/ui/src/main_menu.rs +++ b/ui/src/main_menu.rs @@ -1,11 +1,12 @@ use std::rc::Rc; use html::IntoPropValue; +use pwt::props::StorageLocation; 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}; @@ -74,6 +75,7 @@ impl MainMenu { pub enum Msg { Select(Key), UpdateAcl(AclContext), + UpdateDefaultDashboard, } pub struct PdmMainMenu { @@ -81,6 +83,7 @@ pub struct PdmMainMenu { menu_selection: Selection, acl_context: AclContext, _acl_context_listener: ContextHandle, + default_dashboard: PersistentState>, } fn register_view( @@ -129,11 +132,17 @@ impl Component for PdmMainMenu { .context(ctx.link().callback(Msg::UpdateAcl)) .expect("acl context not present"); + let default_dashboard = PersistentState::>::new(StorageLocation::Local( + "default-dashboard".into(), + )) + .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, } } @@ -147,6 +156,10 @@ impl Component for PdmMainMenu { self.acl_context = acl_context; true } + Msg::UpdateDefaultDashboard => { + self.default_dashboard.load(); + true + } } } @@ -168,13 +181,24 @@ impl Component for PdmMainMenu { let mut menu = Menu::new(); + let default_dashboard: Option = self.default_dashboard.clone().map(|s| s.into()); + let not_found = default_dashboard + .as_ref() + .map(|dashboard| { + !props + .view_list + .iter() + .any(|view| view == dashboard.as_str()) + }) + .unwrap_or(false); + register_view( &mut menu, &mut content, tr!("Dashboard"), "dashboard", Some("fa fa-tachometer"), - move |_| View::new(None).into(), + move |_| View::new(default_dashboard.clone(), not_found).into(), ); let mut views = Menu::new(); @@ -192,7 +216,7 @@ impl Component for PdmMainMenu { view.clone(), &format!("view-{view}"), Some("fa fa-plus-square-o"), - move |_| View::new(Some(view.clone().into())).into(), + move |_| View::new(Some(view.clone().into()), false).into(), ); } @@ -203,7 +227,7 @@ impl Component for PdmMainMenu { view.clone(), &format!("view-{view}"), Some("fa fa-plus-square-o"), - move |_| View::new(Some(view.clone().into())).into(), + move |_| View::new(Some(view.clone().into()), false).into(), ); } diff --git a/ui/src/top_nav_bar.rs b/ui/src/top_nav_bar.rs index 015b6b13..35dc08c6 100644 --- a/ui/src/top_nav_bar.rs +++ b/ui/src/top_nav_bar.rs @@ -48,6 +48,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 { @@ -239,6 +244,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 0ec84f71..ae916a47 100644 --- a/ui/src/widget/my_settings_dialog.rs +++ b/ui/src/widget/my_settings_dialog.rs @@ -69,6 +69,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 { @@ -84,6 +89,7 @@ impl MySettingsDialog { } pub enum Msg { + DefaultDashboard(String), XtermFormChange, XtermSave, XtermReset, @@ -92,6 +98,7 @@ pub enum Msg { #[doc(hidden)] pub struct PdmMySettingsDialog { + default_dashboard: PersistentState>, xterm_form: FormContext, xterm_saved: XtermSettings, novnc_scaling: PersistentState>, @@ -114,6 +121,7 @@ impl Component for PdmMySettingsDialog { fn create(ctx: &Context) -> Self { Self { + default_dashboard: PersistentState::new(StorageLocation::local("default-dashboard")), xterm_form: FormContext::new().on_change(ctx.link().callback(|_| Msg::XtermFormChange)), xterm_saved: XtermSettings::load(), novnc_scaling: PersistentState::new(StorageLocation::local("novnc-scaling")), @@ -122,6 +130,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() { @@ -160,9 +173,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