all lists on 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 v3 7/8] ui: make the default dashboard page configurable
Date: Mon, 30 Nov 2026 13:52:41 +0100	[thread overview]
Message-ID: <20261130125325.2392967-8-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261130125325.2392967-1-d.csapak@proxmox.com>

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 <d.csapak@proxmox.com>
---
 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<Option<String>> {
+    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::<proxmox_client::Error>(),
+        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<AclContext>,
+    default_dashboard: PersistentState<Option<String>>,
 }
 
 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<AttrValue> = 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<String>,
+
+    /// The views that can be selected as dashboard in the settings.
+    #[builder]
+    #[prop_or_default]
+    pub view_list: Vec<String>,
 }
 
 impl TopNavBar {
@@ -255,6 +260,7 @@ impl Component for PdmTopNavBar {
 
         let dialog: Option<Html> = 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<Callback<()>>,
+
+    /// The views that can be selected as dashboard.
+    #[builder]
+    #[prop_or_default]
+    pub view_list: Vec<String>,
 }
 
 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<Option<String>>,
     xterm_form: FormContext,
     xterm_saved: XtermSettings,
     novnc_scaling: PersistentState<Option<String>>,
@@ -119,6 +127,7 @@ impl Component for PdmMySettingsDialog {
 
     fn create(ctx: &Context<Self>) -> 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<Self>, 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





  parent reply	other threads:[~2026-11-30 12:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 12:52 [PATCH datacenter-manager/proxmox-yew-comp/yew-widget-toolkit v3 0/8] ui: make the default dashboard configurable and add "My Settings" dialog Dominik Csapak
2026-11-30 12:52 ` [PATCH yew-widget-toolkit v3 1/8] state: event: add helper to dispatch custom DOM events Dominik Csapak
2026-11-30 12:52 ` [PATCH yew-widget-toolkit v3 2/8] state: persistent state: allow listening for updates Dominik Csapak
2026-11-30 12:52 ` [PATCH proxmox-yew-comp v3 3/8] xtermjs: allow setting the noVNC scaling mode Dominik Csapak
2026-11-30 12:52 ` [PATCH datacenter-manager v3 4/8] ui: view selector: use a placeholder that can't conflict with a view Dominik Csapak
2026-11-30 12:52 ` [PATCH datacenter-manager v3 5/8] ui: add 'My Settings' dialog with xterm.js and noVNC settings Dominik Csapak
2026-11-30 12:52 ` [PATCH datacenter-manager v3 6/8] ui: views: use the view name as key of the component Dominik Csapak
2026-11-30 12:52 ` Dominik Csapak [this message]
2026-11-30 12:52 ` [PATCH datacenter-manager v3 8/8] docs: web ui: describe the 'My Settings' dialog Dominik Csapak

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=20261130125325.2392967-8-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal