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 C240C1FF179 for ; Wed, 26 Nov 2025 16:19:26 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 247EF10734; Wed, 26 Nov 2025 16:19:38 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Wed, 26 Nov 2025 16:18:05 +0100 Message-ID: <20251126151833.3637080-13-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251126151833.3637080-1-d.csapak@proxmox.com> References: <20251126151833.3637080-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.030 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 v5 12/26] 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" when we get a 'LayoutUpdate' message, update the view config with the new layout. Signed-off-by: Dominik Csapak --- ui/src/dashboard/view.rs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs index 3a82cbc7..f1fafcd5 100644 --- a/ui/src/dashboard/view.rs +++ b/ui/src/dashboard/view.rs @@ -7,8 +7,8 @@ use pwt::widget::Dialog; use serde_json::{json, Value}; use yew::virtual_dom::{VComp, VNode}; -use proxmox_yew_comp::http_get; use proxmox_yew_comp::percent_encoding::percent_encode_component; +use proxmox_yew_comp::{http_get, http_put}; use pwt::css; use pwt::prelude::*; use pwt::props::StorageLocation; @@ -87,6 +87,7 @@ pub enum Msg { UpdateConfig(RefreshConfig), ShowSubscriptionsDialog(Option), LayoutUpdate(ViewLayout), + UpdateResult(Result<(), Error>), } struct ViewComp { @@ -108,6 +109,7 @@ struct ViewComp { subscriptions_dialog: Option, editing_state: SharedState>, + update_result: LoadResult<(), Error>, } fn render_widget( @@ -319,6 +321,7 @@ impl Component for ViewComp { subscriptions_dialog: None, editing_state: SharedState::new(Vec::new()), + update_result: LoadResult::new(), } } @@ -378,11 +381,29 @@ impl Component for ViewComp { self.subscriptions_dialog = dialog; } 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; + link.send_message(Msg::UpdateResult(res)); + }), + Err(err) => self.template.update(Err(err.into())), + }; + } } } + Msg::UpdateResult(res) => { + self.update_result.update(res); + } } true } @@ -484,6 +505,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}"), -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel