From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager 1/2] ui: pve: node: use `node_info` helper from yew-comp
Date: Tue, 23 Sep 2025 11:51:12 +0200 [thread overview]
Message-ID: <20250923095124.1679038-10-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250923095124.1679038-1-d.csapak@proxmox.com>
Contains more information that is presented like on PVE, and does not
use much more space.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
ui/src/pve/node/overview.rs | 76 ++++---------------------------------
1 file changed, 8 insertions(+), 68 deletions(-)
diff --git a/ui/src/pve/node/overview.rs b/ui/src/pve/node/overview.rs
index 2b659e54..1a98c004 100644
--- a/ui/src/pve/node/overview.rs
+++ b/ui/src/pve/node/overview.rs
@@ -5,13 +5,12 @@ use yew::{
Context,
};
-use proxmox_human_byte::HumanByte;
-use proxmox_yew_comp::{RRDGraph, RRDTimeframe, RRDTimeframeSelector, Series};
+use proxmox_yew_comp::{node_info, RRDGraph, RRDTimeframe, RRDTimeframeSelector, Series};
use pwt::{
css::{ColorScheme, FlexFit, JustifyContent},
prelude::*,
props::{ContainerBuilder, WidgetBuilder},
- widget::{error_message, Column, Container, Fa, Progress, Row},
+ widget::{error_message, Column, Container, Progress, Row},
AsyncPool,
};
@@ -210,67 +209,7 @@ impl yew::Component for NodeOverviewPanelComp {
}
fn view(&self, ctx: &yew::Context<Self>) -> yew::Html {
- let mut status_comp = Column::new().gap(2).padding(4);
- let status = self.status.as_ref();
- let cpu = status.map(|s| s.cpu).unwrap_or_default();
- let maxcpu = status.map(|s| s.cpuinfo.cpus).unwrap_or_default();
- let load = status.map(|s| s.loadavg.join(", ")).unwrap_or_default();
-
- let memory = status.map(|s| s.memory.used as u64).unwrap_or_default();
- let maxmem = status.map(|s| s.memory.total as u64).unwrap_or(1);
-
- let root = status.map(|s| s.rootfs.used as u64).unwrap_or_default();
- let maxroot = status.map(|s| s.rootfs.total as u64).unwrap_or(1);
-
- let root_used = root as f64 / maxroot as f64;
-
- status_comp = status_comp
- .with_child(make_row(
- tr!("CPU usage"),
- Fa::new("cpu"),
- tr!("{0}% of {1} CPU(s)", format!("{:.2}", cpu * 100.0), maxcpu),
- Some(cpu as f32),
- ))
- .with_child(make_row(
- tr!("Load average"),
- Fa::new("line-chart"),
- load,
- None,
- ))
- .with_child(crate::renderer::memory_status_row(memory, maxmem))
- .with_child(make_row(
- tr!("Root filesystem usage"),
- Fa::new("database"),
- tr!(
- "{0}% ({1} of {2})",
- format!("{:.2}", root_used * 100.0),
- HumanByte::from(root),
- HumanByte::from(maxroot),
- ),
- Some(root_used as f32),
- ))
- .with_child(Container::new().padding(1)) // spacer
- .with_child(
- Row::new()
- .with_child(tr!("Version"))
- .with_flex_spacer()
- .with_optional_child(status.map(|s| s.pveversion.as_str())),
- )
- .with_child(
- Row::new()
- .with_child(tr!("CPU Model"))
- .with_flex_spacer()
- .with_child(tr!(
- "{0} ({1} sockets)",
- status.map(|s| s.cpuinfo.model.as_str()).unwrap_or_default(),
- status.map(|s| s.cpuinfo.sockets).unwrap_or_default()
- )),
- );
-
- if let Some(err) = &self.last_status_error {
- status_comp.add_child(error_message(&err.to_string()));
- }
-
+ let status_comp = node_info(self.status.as_ref().map(|s| s.into()));
let loading = self.status.is_none() && self.last_status_error.is_none();
Container::new()
.class(FlexFit)
@@ -282,6 +221,11 @@ impl yew::Component for NodeOverviewPanelComp {
.style("opacity", (!loading).then_some("0")),
)
.with_child(status_comp)
+ .with_optional_child(
+ self.last_status_error
+ .as_ref()
+ .map(|err| error_message(&err.to_string())),
+ )
.with_child(separator().padding_x(4))
.with_child(
Row::new()
@@ -341,7 +285,3 @@ impl yew::Component for NodeOverviewPanelComp {
.into()
}
}
-
-fn make_row(title: String, icon: Fa, text: String, meter_value: Option<f32>) -> Column {
- crate::renderer::status_row(title, icon, text, meter_value, false)
-}
--
2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2025-09-23 9:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 9:51 [pdm-devel] [PATCH datacenter-manager/yew-comp 00/10] status row/node status cleanup + refactor Dominik Csapak
2025-09-23 9:51 ` [pdm-devel] [PATCH yew-comp 1/8] status: impl conversion to classes Dominik Csapak
2025-09-23 9:51 ` [pdm-devel] [PATCH yew-comp 2/8] status row: add option to add the icon on the right side Dominik Csapak
2025-09-23 9:51 ` [pdm-devel] [PATCH yew-comp 3/8] meter label: make value optional Dominik Csapak
2025-09-23 9:51 ` [pdm-devel] [PATCH yew-comp 4/8] meter label: use `StatusRow` for text row Dominik Csapak
2025-09-23 9:51 ` [pdm-devel] [PATCH yew-comp 5/8] meter label: align the status row with baseline Dominik Csapak
2025-09-23 9:51 ` [pdm-devel] [PATCH yew-comp 6/8] meter label: add `animated` property Dominik Csapak
2025-09-23 9:51 ` [pdm-devel] [PATCH yew-comp 7/8] meter label: add option to align the icon on the right Dominik Csapak
2025-09-23 9:51 ` [pdm-devel] [PATCH yew-comp 8/8] add `node_info` helper to render a consistent view of the NodeStatus Dominik Csapak
2025-09-23 9:51 ` Dominik Csapak [this message]
2025-09-23 9:51 ` [pdm-devel] [PATCH datacenter-manager 2/2] ui: rework status row/meter helpers Dominik Csapak
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=20250923095124.1679038-10-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.