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 8991B1FF185 for ; Mon, 17 Nov 2025 16:00:38 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E19C61D3C4; Mon, 17 Nov 2025 16:00:41 +0100 (CET) Mime-Version: 1.0 Date: Mon, 17 Nov 2025 16:00:02 +0100 Message-Id: To: "Dominik Csapak" X-Mailer: aerc 0.20.0 References: <20251117125041.1931382-1-d.csapak@proxmox.com> <20251117125041.1931382-13-d.csapak@proxmox.com> In-Reply-To: <20251117125041.1931382-13-d.csapak@proxmox.com> From: "Shannon Sterz" X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1763391573535 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.064 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: Re: [pdm-devel] [PATCH datacenter-manager v3 12/18] ui: views: save updated layout to backend 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 Cc: 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" one comment in-line. On Mon Nov 17, 2025 at 1:44 PM CET, Dominik Csapak wrote: > when we get a 'LayoutUpdate' message, update the view config with the > new layout. > > Signed-off-by: Dominik Csapak > --- > ui/src/dashboard/view.rs | 32 ++++++++++++++++++++++++++++++-- > 1 file changed, 30 insertions(+), 2 deletions(-) > > diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs > index 404c984f..9bf5dfc7 100644 > --- a/ui/src/dashboard/view.rs > +++ b/ui/src/dashboard/view.rs > @@ -6,7 +6,7 @@ use js_sys::Date; > use serde_json::{json, Value}; > use yew::virtual_dom::{VComp, VNode}; > > -use proxmox_yew_comp::http_get; > +use proxmox_yew_comp::{http_get, http_put}; > use pwt::css; > use pwt::prelude::*; > use pwt::props::StorageLocation; > @@ -83,6 +83,7 @@ pub enum Msg { > ConfigWindow(bool), // show > UpdateConfig(RefreshConfig), > LayoutUpdate(ViewLayout), > + UpdateResult(Result<(), Error>), > } > > struct ViewComp { > @@ -103,6 +104,7 @@ struct ViewComp { > show_create_wizard: Option, > > editing_state: SharedState>, > + update_result: LoadResult<(), Error>, > } > > fn render_widget( > @@ -304,6 +306,7 @@ impl Component for ViewComp { > show_create_wizard: None, > > editing_state: SharedState::new(Vec::new()), > + update_result: LoadResult::new(), > } > } > > @@ -360,11 +363,30 @@ impl Component for ViewComp { > self.show_config_window = false; > } > Msg::LayoutUpdate(view_layout) => { > - // FIXME: update backend layout > + let link = ctx.link().clone(); > if let Some(template) = &mut self.template.data { > template.layout = view_layout; > + if let Some(view) = &ctx.props().view { > + let view = view.to_string(); > + match serde_json::to_string(&template) { > + Ok(layout_str) => self.async_pool.spawn(async move { > + let params = json!({ > + "layout": layout_str, > + }); > + > + let res = > + http_put::<()>(format!("/config/views/{view}"), Some(params)) > + .await; nit: `()` can be inferred here, so you can drop the `::<()>`. > + link.send_message(Msg::UpdateResult(res)); > + }), > + Err(err) => self.template.update(Err(err.into())), > + }; > + } > } > } > + Msg::UpdateResult(res) => { > + self.update_result.update(res); > + } > } > true > } > @@ -452,6 +474,12 @@ impl Component for ViewComp { > .as_ref() > .map(|err| error_message(&err.to_string())), > ); > + view.add_optional_child( > + self.update_result > + .error > + .as_ref() > + .map(|err| error_message(&err.to_string())), > + ); > view.add_optional_child(self.show_config_window.then_some({ > let refresh_config_id = match &props.view { > Some(view) => format!("view-{view}"), _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel