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 6294A1FF179 for ; Wed, 12 Nov 2025 17:19:23 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3A55C9842; Wed, 12 Nov 2025 17:20:06 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Wed, 12 Nov 2025 17:11:46 +0100 Message-ID: <20251112161900.75032-12-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251112161900.75032-1-d.csapak@proxmox.com> References: <20251112161900.75032-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 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 11/18] ui: views: add 'view' parameter to api calls 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" if a 'view' name was given. This way the panels show the actual data of the view. Signed-off-by: Dominik Csapak --- ui/src/dashboard/view.rs | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs index 4ab66e08..1f5a0388 100644 --- a/ui/src/dashboard/view.rs +++ b/ui/src/dashboard/view.rs @@ -3,7 +3,7 @@ use std::rc::Rc; use anyhow::Error; use futures::join; use js_sys::Date; -use serde_json::json; +use serde_json::{json, Value}; use yew::virtual_dom::{VComp, VNode}; use proxmox_yew_comp::http_get; @@ -162,11 +162,20 @@ impl ViewComp { let (status, top_entities, tasks) = required_api_calls(&data.layout); self.loading = true; + let view = ctx.props().view.clone(); self.async_pool.spawn(async move { + let add_view_filter = |params: &mut Value| { + if let Some(view) = &view { + params["view"] = view.to_string().into(); + } + }; let status_future = async { if status { - let res = - http_get("/resources/status", Some(json!({"max-age": max_age}))).await; + let mut params = json!({ + "max-age": max_age, + }); + add_view_filter(&mut params); + let res = http_get("/resources/status", Some(params)).await; link.send_message(Msg::LoadingResult(LoadingResult::Resources(res))); } }; @@ -175,24 +184,29 @@ impl ViewComp { if top_entities { let client: pdm_client::PdmClient> = pdm_client(); - let res = client.get_top_entities(None).await; + let res = client + .get_top_entities(view.as_ref().map(|view| view.as_str())) + .await; link.send_message(Msg::LoadingResult(LoadingResult::TopEntities(res))); } }; let tasks_future = async { if tasks { - let params = Some(json!({ + let mut params = json!({ "since": since, "limit": 0, - })); - let res = http_get("/remote-tasks/statistics", params).await; + }); + add_view_filter(&mut params); + let res = http_get("/remote-tasks/statistics", Some(params)).await; link.send_message(Msg::LoadingResult(LoadingResult::TaskStatistics(res))); } }; let subs_future = async { - let res = http_get("/resources/subscription", None).await; + let mut params = json!({}); + add_view_filter(&mut params); + let res = http_get("/resources/subscription", Some(params)).await; link.send_message(Msg::LoadingResult(LoadingResult::SubscriptionInfo(res))); }; -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel