[pdm-devel] [PATCH yew-comp v3 2/2] node status panel: remove power management and make fingerprint opt-in
Shannon Sterz
s.sterz at proxmox.com
Mon Nov 10 09:58:29 CET 2025
the panel appeared to dense with all these tools being present. so
remove the reboot and power off button and make the fingerprint button
opt-in.
Signed-off-by: Shannon Sterz <s.sterz at proxmox.com>
---
src/node_status_panel.rs | 70 ++++++++++------------------------------
1 file changed, 17 insertions(+), 53 deletions(-)
diff --git a/src/node_status_panel.rs b/src/node_status_panel.rs
index 3d37d80..c73594b 100644
--- a/src/node_status_panel.rs
+++ b/src/node_status_panel.rs
@@ -12,12 +12,11 @@ use pwt::widget::{error_message, Fa, Panel, Row, Tooltip};
use pwt::widget::{Button, Dialog};
use pwt_macros::builder;
-use proxmox_node_status::{NodePowerCommand, NodeStatus};
+use proxmox_node_status::NodeStatus;
use crate::utils::copy_text_to_clipboard;
use crate::{
- http_get, http_post, node_info, ConfirmButton, LoadableComponent, LoadableComponentContext,
- LoadableComponentMaster,
+ http_get, node_info, LoadableComponent, LoadableComponentContext, LoadableComponentMaster,
};
#[derive(Properties, Clone, PartialEq)]
@@ -27,6 +26,10 @@ pub struct NodeStatusPanel {
#[builder(IntoPropValue, into_prop_value)]
#[prop_or_default]
status_base_url: Option<AttrValue>,
+
+ #[builder(IntoPropValue, into_prop_value)]
+ #[prop_or_default]
+ fingerprint_button: bool,
}
impl NodeStatusPanel {
@@ -44,8 +47,6 @@ impl Default for NodeStatusPanel {
enum Msg {
Error(Error),
Loaded(Rc<NodeStatus>),
- RebootOrShutdown(NodePowerCommand),
- Reload,
}
#[derive(PartialEq)]
@@ -59,24 +60,6 @@ struct ProxmoxNodeStatusPanel {
}
impl ProxmoxNodeStatusPanel {
- fn change_power_state(&self, ctx: &LoadableComponentContext<Self>, command: NodePowerCommand) {
- let Some(url) = ctx.props().status_base_url.clone() else {
- return;
- };
- let link = ctx.link().clone();
-
- ctx.link().spawn(async move {
- let data = Some(serde_json::json!({
- "command": command,
- }));
-
- match http_post(url.as_str(), data).await {
- Ok(()) => link.send_message(Msg::Reload),
- Err(err) => link.send_message(Msg::Error(err)),
- }
- });
- }
-
fn fingerprint_dialog(
&self,
ctx: &LoadableComponentContext<Self>,
@@ -154,7 +137,7 @@ impl LoadableComponent for ProxmoxNodeStatusPanel {
})
}
- fn update(&mut self, ctx: &crate::LoadableComponentContext<Self>, msg: Self::Message) -> bool {
+ fn update(&mut self, _ctx: &crate::LoadableComponentContext<Self>, msg: Self::Message) -> bool {
match msg {
Msg::Error(err) => {
self.error = Some(err);
@@ -165,11 +148,6 @@ impl LoadableComponent for ProxmoxNodeStatusPanel {
self.error = None;
true
}
- Msg::RebootOrShutdown(command) => {
- self.change_power_state(ctx, command);
- false
- }
- Msg::Reload => true,
}
}
@@ -195,7 +173,7 @@ impl LoadableComponent for ProxmoxNodeStatusPanel {
.as_ref()
.map(|r| crate::NodeStatus::Common(r));
- Panel::new()
+ let mut panel = Panel::new()
.border(false)
.class(FlexFit)
.title(
@@ -206,25 +184,11 @@ impl LoadableComponent for ProxmoxNodeStatusPanel {
.with_child(tr!("Node Status"))
.into_html(),
)
- .with_tool(
- ConfirmButton::new(tr!("Reboot"))
- .confirm_message(tr!("Are you sure you want to reboot the node?"))
- .on_activate(
- ctx.link()
- .callback(|_| Msg::RebootOrShutdown(NodePowerCommand::Reboot)),
- )
- .icon_class("fa fa-undo"),
- )
- .with_tool(
- ConfirmButton::new(tr!("Shutdown"))
- .confirm_message(tr!("Are you sure you want to shut down the node?"))
- .on_activate(
- ctx.link()
- .callback(|_| Msg::RebootOrShutdown(NodePowerCommand::Shutdown)),
- )
- .icon_class("fa fa-power-off"),
- )
- .with_tool(
+ .with_child(node_info(status))
+ .with_optional_child(self.error.as_ref().map(|e| error_message(&e.to_string())));
+
+ if ctx.props().fingerprint_button {
+ panel.add_tool(
Button::new(tr!("Show Fingerprint"))
.icon_class("fa fa-hashtag")
.class(ColorScheme::Primary)
@@ -232,10 +196,10 @@ impl LoadableComponent for ProxmoxNodeStatusPanel {
ctx.link()
.change_view_callback(|_| ViewState::FingerprintDialog),
),
- )
- .with_child(node_info(status))
- .with_optional_child(self.error.as_ref().map(|e| error_message(&e.to_string())))
- .into()
+ );
+ }
+
+ panel.into()
}
}
--
2.47.3
More information about the pdm-devel
mailing list