From: Dominik Csapak <d.csapak@proxmox.com>
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 [thread overview]
Message-ID: <20260522083412.1223719-11-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260522083412.1223719-1-d.csapak@proxmox.com>
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 <d.csapak@proxmox.com>
---
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<Rc<proxmox_yew_comp::HttpClientWasm>> =
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
next prev parent reply other threads:[~2026-05-22 8:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 8:33 [PATCH datacenter-manager/proxmox-geojson-data/yew-widget-toolkit/yew-widget-toolkit-assets v3 00/11] add a new map widget for custom views Dominik Csapak
2026-05-22 8:33 ` [PATCH yew-widget-toolkit v3 1/3] js-helper: add client-to-svg-coordinate conversion helper Dominik Csapak
2026-05-22 8:33 ` [PATCH yew-widget-toolkit v3 2/3] widget: charts: add interactive Map with zoom/pan and clustering Dominik Csapak
2026-05-22 13:30 ` Shannon Sterz
2026-05-22 8:33 ` [PATCH yew-widget-toolkit v3 3/3] widget: charts: add WorldMap with GeoJSON rendering Dominik Csapak
2026-05-22 8:34 ` [PATCH yew-widget-toolkit-assets v3 1/1] charts: add necessary classes for Map Dominik Csapak
2026-05-22 8:34 ` [PATCH proxmox-geojson-data v3 1/1] initial commit Dominik Csapak
2026-05-22 13:30 ` Shannon Sterz
2026-05-22 8:34 ` [PATCH datacenter-manager v3 1/6] server: pbs client: add node_config method Dominik Csapak
2026-05-22 8:34 ` [PATCH datacenter-manager v3 2/6] lib/api: add 'location-info' api call with cached information Dominik Csapak
2026-05-22 13:30 ` Shannon Sterz
2026-05-22 8:34 ` [PATCH datacenter-manager v3 3/6] lib/api: add new 'remote-list' info to the resource status Dominik Csapak
2026-05-22 8:34 ` [PATCH datacenter-manager v3 4/6] server: serve geojson worldmap Dominik Csapak
2026-05-22 8:34 ` Dominik Csapak [this message]
2026-05-22 8:34 ` [PATCH datacenter-manager v3 6/6] ui: views: add map component Dominik Csapak
2026-05-22 13:30 ` Shannon Sterz
2026-05-22 9:38 ` [PATCH datacenter-manager/proxmox-geojson-data/yew-widget-toolkit/yew-widget-toolkit-assets v3 00/11] add a new map widget for custom views Thomas Lamprecht
2026-05-22 13:33 ` Shannon Sterz
2026-05-24 2:31 ` applied: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260522083412.1223719-11-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox