[pdm-devel] [PATCH datacenter-manager v3 11/18] ui: views: add 'view' parameter to api calls
Dominik Csapak
d.csapak at proxmox.com
Mon Nov 17 13:44:33 CET 2025
if a 'view' name was given. This way the panels show the actual data
of the view.
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes from v2:
* 'true' for verbose can already be used directly, we can't call 'true.into()'
ui/src/dashboard/view.rs | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs
index ad38db26..404c984f 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,31 @@ impl ViewComp {
if top_entities {
let client: pdm_client::PdmClient<Rc<proxmox_yew_comp::HttpClientWasm>> =
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?verbose=true", None).await;
+ let mut params = json!({
+ "verbose": true,
+ });
+ 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
More information about the pdm-devel
mailing list