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 v2 6/6] ui: make the default dashboard page configurable
Date: Fri, 27 Nov 2026 18:09:27 +0100	[thread overview]
Message-ID: <20261127170941.4183880-7-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261127170941.4183880-1-d.csapak@proxmox.com>

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 <d.csapak@proxmox.com>
---
 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<AttrValue>,
+    not_found: bool,
 }
 
 impl From<View> for VNode {
@@ -70,8 +71,11 @@ impl From<View> for VNode {
 }
 
 impl View {
-    pub fn new(view: impl Into<Option<AttrValue>>) -> Self {
-        Self { view: view.into() }
+    pub fn new(view: impl Into<Option<AttrValue>>, not_found: bool) -> Self {
+        Self {
+            view: view.into(),
+            not_found,
+        }
     }
 }
 
@@ -521,6 +525,16 @@ impl Component for ViewComp {
     fn view(&self, ctx: &yew::Context<Self>) -> 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<AclContext>,
+    default_dashboard: PersistentState<Option<String>>,
 }
 
 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::<Option<String>>::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<AttrValue> = 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<String>,
+
+    /// The views that can be selected as dashboard in the settings.
+    #[builder]
+    #[prop_or_default]
+    pub view_list: Vec<String>,
 }
 
 impl TopNavBar {
@@ -239,6 +244,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 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<Callback<()>>,
+
+    /// The views that can be selected as dashboard.
+    #[builder]
+    #[prop_or_default]
+    pub view_list: Vec<String>,
 }
 
 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<Option<String>>,
     xterm_form: FormContext,
     xterm_saved: XtermSettings,
     novnc_scaling: PersistentState<Option<String>>,
@@ -114,6 +121,7 @@ impl Component for PdmMySettingsDialog {
 
     fn create(ctx: &Context<Self>) -> 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<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() {
@@ -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





      parent reply	other threads:[~2026-11-27 17:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 17:09 [PATCH datacenter-manager/yew-widget-toolkit v2 0/6] ui: make the default dashboard configurable and add "My Settings" dialog Dominik Csapak
2026-11-27 17:09 ` [PATCH yew-widget-toolkit v2 1/6] state: event: add helpers for custom DOM events Dominik Csapak
2026-11-27 17:09 ` [PATCH yew-widget-toolkit v2 2/6] state: persistent state: allow listening for updates Dominik Csapak
2026-11-27 17:09 ` [PATCH datacenter-manager v2 3/6] ui: add 'My Settings' dialog with xterm.js and noVNC settings Dominik Csapak
2026-11-27 17:09 ` [PATCH datacenter-manager v2 4/6] ui: view configuration: fix dismissing of remove confirmation dialog Dominik Csapak
2026-11-27 17:09 ` [PATCH datacenter-manager v2 5/6] ui: view selector: use a placeholder that can't conflict with a view Dominik Csapak
2026-11-27 17:09 ` Dominik Csapak [this message]

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=20261127170941.4183880-7-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