From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 78AD71FF179 for ; Wed, 12 Nov 2025 17:18:46 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5E0FD9455; Wed, 12 Nov 2025 17:19:33 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Wed, 12 Nov 2025 17:11:51 +0100 Message-ID: <20251112161900.75032-17-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251112161900.75032-1-d.csapak@proxmox.com> References: <20251112161900.75032-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pdm-devel] [PATCH datacenter-manager 16/18] ui: load view list on page init X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" and provide a ViewListContext for the components below, so we can refresh the list when it's requested. Signed-off-by: Dominik Csapak --- ui/src/main.rs | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/ui/src/main.rs b/ui/src/main.rs index f8a44f57..ce87a93e 100644 --- a/ui/src/main.rs +++ b/ui/src/main.rs @@ -10,7 +10,7 @@ use yew::prelude::*; use pwt::prelude::*; use pwt::props::TextRenderFn; -use pwt::state::{Loader, PersistentState}; +use pwt::state::{Loader, PersistentState, SharedStateObserver}; use pwt::widget::{Column, DesktopApp, Dialog, Mask}; use pbs_api_types::TaskListItem; @@ -23,11 +23,14 @@ use proxmox_yew_comp::{ //use pbs::MainMenu; use pdm_api_types::subscription::{RemoteSubscriptionState, RemoteSubscriptions}; +use pdm_api_types::views::ViewConfig; use pdm_ui::{ register_pve_tasks, MainMenu, RemoteList, RemoteListCacheEntry, SearchProvider, TopNavBar, + ViewListContext, }; type MsgRemoteList = Result; +type MsgViewList = Result, Error>; enum Msg { ConfirmSubscription, @@ -37,6 +40,8 @@ enum Msg { Logout, TaskChanged, RemoteList(MsgRemoteList), + ViewList(MsgViewList), + UpdateViewList, } struct DatacenterManagerApp { @@ -51,6 +56,10 @@ struct DatacenterManagerApp { remote_list_error: Option, remote_list_timeout: Option, search_provider: SearchProvider, + + view_list: Vec, + view_list_context: ViewListContext, + _view_list_observer: SharedStateObserver, } async fn check_subscription() -> Msg { @@ -95,9 +104,24 @@ impl DatacenterManagerApp { //ctx.link().send_future_batch(get_fingerprint()); // self.remote_list_timeout = Self::poll_remote_list(ctx, true); + self.update_views(ctx); } } + fn update_views(&mut self, ctx: &Context) { + ctx.link().send_future(async move { + let res = http_get("/config/views", None) + .await + .map(|list: Vec| { + let mut list: Vec<_> = list.into_iter().map(|config| config.id).collect(); + list.sort(); + list + }); + + Msg::ViewList(res) + }); + } + fn update_remotes(&mut self, ctx: &Context, result: MsgRemoteList) -> bool { self.remote_list_timeout = Self::poll_remote_list(ctx, false); let mut changed = false; @@ -183,6 +207,10 @@ impl Component for DatacenterManagerApp { let login_info = authentication_from_cookie(&proxmox_yew_comp::ExistingProduct::PDM); + let view_list_context = ViewListContext::new(); + let _view_list_observer = + view_list_context.add_listener(ctx.link().callback(|_| Msg::UpdateViewList)); + let mut this = Self { _auth_observer, login_info, @@ -195,6 +223,9 @@ impl Component for DatacenterManagerApp { remote_list_error: None, remote_list_timeout: None, search_provider: SearchProvider::new(), + view_list: Vec::new(), + view_list_context, + _view_list_observer, }; this.on_login(ctx, false); @@ -248,6 +279,14 @@ impl Component for DatacenterManagerApp { } */ Msg::RemoteList(remotes) => self.update_remotes(ctx, remotes), + Msg::ViewList(views) => { + self.view_list = views.ok().unwrap_or_default(); + true + } + Msg::UpdateViewList => { + self.update_views(ctx); + false + } } } @@ -272,6 +311,7 @@ impl Component for DatacenterManagerApp { .with_child({ let main_view: Html = if self.login_info.is_some() && !loading { MainMenu::new() + .view_list(self.view_list.clone()) .username(username.clone()) .remote_list(self.remote_list_cache.clone()) .remote_list_loading(self.remote_list_error.is_some()) @@ -289,11 +329,14 @@ impl Component for DatacenterManagerApp { let context = self.remote_list.clone(); let search_context = self.search_provider.clone(); + let view_list_context = self.view_list_context.clone(); DesktopApp::new(html! { context={search_context}> {context}> - {body} + context={view_list_context}> + {body} + > > > }) -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel