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 ED7491FF17E for ; Thu, 27 Nov 2025 15:04:46 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0DE914D57; Thu, 27 Nov 2025 15:05:07 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Thu, 27 Nov 2025 15:03:48 +0100 Message-ID: <20251127140451.3131469-5-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251127140451.3131469-1-d.csapak@proxmox.com> References: <20251127140451.3131469-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 4/4] ui: dashboard: subscriptions details: add a 'force refresh' button 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" This simply calls the subscription api with 'max-age: 0', so we force the backend to fetch all subscriptions. This is useful when one adds a subscription to the remotes and does not want to wait for the automatic refresh. Signed-off-by: Dominik Csapak --- ui/src/dashboard/subscription_info.rs | 27 +++++++++++----------- ui/src/dashboard/view.rs | 33 ++++++++++++++++++++------- ui/src/load_result.rs | 6 +++++ 3 files changed, 45 insertions(+), 21 deletions(-) diff --git a/ui/src/dashboard/subscription_info.rs b/ui/src/dashboard/subscription_info.rs index fed2b2c7..d6d13d8c 100644 --- a/ui/src/dashboard/subscription_info.rs +++ b/ui/src/dashboard/subscription_info.rs @@ -136,19 +136,20 @@ impl From for VNode { pub fn create_subscriptions_dialog( subs: SharedState, Error>>, on_dialog_close: Callback<()>, -) -> Option { - if let Some(subs) = subs.read().data.clone() { - let dialog = Dialog::new(tr!("Your Subscriptions")) - .resizable(true) - .width(500) - .height(400) - .min_width(200) - .min_height(50) - .with_child(SubscriptionsList::new(subs.clone())) - .on_close(on_dialog_close); - return Some(dialog); - } - None + on_refresh: Callback, +) -> Dialog { + let loading = !subs.read().has_data(); + let subs = subs.read().data.clone(); + let subs = subs.unwrap_or_default(); + Dialog::new(tr!("Your Subscriptions")) + .with_tool(Button::refresh(loading).on_activate(on_refresh)) + .resizable(true) + .width(500) + .height(400) + .min_width(200) + .min_height(50) + .with_child(SubscriptionsList::new(subs)) + .on_close(on_dialog_close) } pub fn create_subscription_panel( diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs index 2adcee53..2791277b 100644 --- a/ui/src/dashboard/view.rs +++ b/ui/src/dashboard/view.rs @@ -95,6 +95,7 @@ pub enum Msg { ShowSubscriptionsDialog(bool), LayoutUpdate(ViewLayout), UpdateResult(Result<(), Error>), + ForceSubscriptionUpdate, } struct ViewComp { @@ -425,6 +426,22 @@ impl Component for ViewComp { Msg::UpdateResult(res) => { self.update_result.update(res); } + Msg::ForceSubscriptionUpdate => { + let link = ctx.link().clone(); + let view = ctx.props().view.clone(); + self.render_args.subscriptions.write().clear(); + self.async_pool.spawn(async move { + let mut params = json!({ + "verbose": true, + "max-age": 0, + }); + if let Some(view) = view { + params["view"] = view.to_string().into(); + } + let res = http_get("/resources/subscription", Some(params)).await; + link.send_message(Msg::LoadingResult(LoadingResult::SubscriptionInfo(res))); + }); + } } true } @@ -547,14 +564,14 @@ impl Component for ViewComp { .on_submit(move |ctx| crate::remotes::create_remote(ctx, remote_type)) })); - view.add_optional_child(if self.subscriptions_dialog { - create_subscriptions_dialog( - self.render_args.subscriptions.clone(), - ctx.link().callback(|_| Msg::ShowSubscriptionsDialog(false)), - ) - } else { - None - }); + view.add_optional_child( + self.subscriptions_dialog + .then_some(create_subscriptions_dialog( + self.render_args.subscriptions.clone(), + ctx.link().callback(|_| Msg::ShowSubscriptionsDialog(false)), + ctx.link().callback(|_| Msg::ForceSubscriptionUpdate), + )), + ); let view_context = ViewContext { name: props.view.clone(), diff --git a/ui/src/load_result.rs b/ui/src/load_result.rs index 4f3e6d5a..55436fd1 100644 --- a/ui/src/load_result.rs +++ b/ui/src/load_result.rs @@ -33,6 +33,12 @@ impl LoadResult { pub fn has_data(&self) -> bool { self.data.is_some() || self.error.is_some() } + + /// Clears both data and the error from the result. + pub fn clear(&mut self) { + self.data = None; + self.error = None; + } } impl Default for LoadResult { -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel