From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id EAFC61FF142 for ; Fri, 22 May 2026 10:35:00 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CC49B27C4; Fri, 22 May 2026 10:35:00 +0200 (CEST) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager v3 5/6] ui: views: refactor required api call info into struct Date: Fri, 22 May 2026 10:34:06 +0200 Message-ID: <20260522083412.1223719-11-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260522083412.1223719-1-d.csapak@proxmox.com> References: <20260522083412.1223719-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.049 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 Message-ID-Hash: UWWKQPNHJMHBERLI6C4TELIYL6XSL7IE X-Message-ID-Hash: UWWKQPNHJMHBERLI6C4TELIYL6XSL7IE X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Returning multiple bools is very confusing and error prone, so wrap them in a local struct that has properly named fields. Signed-off-by: Dominik Csapak --- ui/src/dashboard/view.rs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs index bdf92bf6..3ddc4910 100644 --- a/ui/src/dashboard/view.rs +++ b/ui/src/dashboard/view.rs @@ -198,7 +198,7 @@ impl ViewComp { if let Some(data) = self.template.data.as_ref() { let link = ctx.link().clone(); let (_, since) = get_task_options(self.refresh_config.task_last_hours); - let (status, top_entities, tasks) = required_api_calls(&data.layout); + let required = required_api_calls(&data.layout); self.loading = true; let view = ctx.props().view.clone(); @@ -209,7 +209,7 @@ impl ViewComp { } }; let status_future = async { - if status { + if required.status { let mut params = json!({ "max-age": max_age, }); @@ -220,7 +220,7 @@ impl ViewComp { }; let entities_future = async { - if top_entities { + if required.top_entities { let client: pdm_client::PdmClient> = pdm_client(); let res = client @@ -231,7 +231,7 @@ impl ViewComp { }; let tasks_future = async { - if tasks { + if required.task_statistics { let mut params = json!({ "since": since, "limit": 0, @@ -261,11 +261,15 @@ impl ViewComp { } } -// returns which api calls are required: status, top_entities, task statistics -fn required_api_calls(layout: &ViewLayout) -> (bool, bool, bool) { - let mut status = false; - let mut top_entities = false; - let mut task_statistics = false; +#[derive(Default)] +struct RequiredApiCalls { + status: bool, + top_entities: bool, + task_statistics: bool, +} + +fn required_api_calls(layout: &ViewLayout) -> RequiredApiCalls { + let mut api_calls = RequiredApiCalls::default(); match layout { ViewLayout::Rows { rows } => { for row in rows { @@ -277,13 +281,13 @@ fn required_api_calls(layout: &ViewLayout) -> (bool, bool, bool) { | WidgetType::Sdn | WidgetType::PbsDatastores | WidgetType::NodeResourceGauge { .. } => { - status = true; + api_calls.status = true; } WidgetType::Subscription => { // panel does it itself, it's always required anyway } - WidgetType::Leaderboard { .. } => top_entities = true, - WidgetType::TaskSummary { .. } => task_statistics = true, + WidgetType::Leaderboard { .. } => api_calls.top_entities = true, + WidgetType::TaskSummary { .. } => api_calls.task_statistics = true, WidgetType::ResourceTree => { // each list must do it itself } @@ -294,7 +298,7 @@ fn required_api_calls(layout: &ViewLayout) -> (bool, bool, bool) { } } - (status, top_entities, task_statistics) + api_calls } impl Component for ViewComp { -- 2.47.3