public inbox for yew-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH proxmox-yew-comp] fix #7932: add missing uptime to the GUI
@ 2026-08-25 13:54 Shan Shaji
  2026-08-26  6:43 ` Dominik Csapak
  0 siblings, 1 reply; 2+ messages in thread
From: Shan Shaji @ 2026-08-25 13:54 UTC (permalink / raw)
  To: yew-devel

Previously, the uptime was not displayed in Proxmox Datacenter Manager.
This fixes the issue by wiring the property already available from
the /status endpoint into the UI.

Signed-off-by: Shan Shaji <s.shaji@proxmox.com>
---
 src/node_status_panel.rs | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/node_status_panel.rs b/src/node_status_panel.rs
index ec17a94..d1a02c2 100644
--- a/src/node_status_panel.rs
+++ b/src/node_status_panel.rs
@@ -8,13 +8,13 @@ use pwt::widget::form::DisplayField;
 use yew::virtual_dom::{VComp, VNode};
 
 use pwt::prelude::*;
-use pwt::widget::{error_message, Fa, Panel, Row, Tooltip};
+use pwt::widget::{Container, Fa, Panel, Row, Tooltip, error_message};
 use pwt::widget::{Button, Dialog};
 use pwt_macros::builder;
 
 use proxmox_node_status::{NodePowerCommand, NodeStatus};
 
-use crate::utils::copy_text_to_clipboard;
+use crate::utils::{copy_text_to_clipboard, format_duration_human};
 use crate::{
     http_get, http_post, node_info, ConfirmButton, LoadableComponent, LoadableComponentContext,
     LoadableComponentMaster, LoadableComponentScopeExt, LoadableComponentState,
@@ -146,6 +146,26 @@ impl ProxmoxNodeStatusPanel {
     }
 }
 
+fn uptime_html(node_status: Option<&node_info::NodeStatus>) -> Option<Html> {
+    let uptime =  match node_status {
+        Some(node_info::NodeStatus::Pve(node_status)) => node_status
+            .additional_properties
+            .get("uptime")
+            .and_then(|uptime| uptime.as_u64())
+            .unwrap_or_default(),
+        Some(node_info::NodeStatus::Pbs(node_status)) => node_status.uptime,
+        Some(node_info::NodeStatus::Common(node_status)) => node_status.uptime,
+        None => 0
+    };
+
+    if uptime == 0 {
+        return None;
+    }
+
+   let uptime_string = tr!("(Uptime: {})", format_duration_human(uptime as f64));
+   Some(Container::from_tag("span").with_child(uptime_string).into())
+}
+
 impl LoadableComponent for ProxmoxNodeStatusPanel {
     type Message = Msg;
     type ViewState = ViewState;
@@ -229,6 +249,7 @@ impl LoadableComponent for ProxmoxNodeStatusPanel {
                     .gap(2)
                     .with_child(Fa::new("book"))
                     .with_child(tr!("Node Status"))
+                    .with_optional_child(uptime_html(status.as_ref()))
                     .into_html(),
             )
             .with_child(node_info(status))
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH proxmox-yew-comp] fix #7932: add missing uptime to the GUI
  2026-08-25 13:54 [PATCH proxmox-yew-comp] fix #7932: add missing uptime to the GUI Shan Shaji
@ 2026-08-26  6:43 ` Dominik Csapak
  0 siblings, 0 replies; 2+ messages in thread
From: Dominik Csapak @ 2026-08-26  6:43 UTC (permalink / raw)
  To: Shan Shaji, yew-devel

see one comment inline

On 8/25/26 3:54 PM, Shan Shaji wrote:
> Previously, the uptime was not displayed in Proxmox Datacenter Manager.
> This fixes the issue by wiring the property already available from
> the /status endpoint into the UI.
> 
> Signed-off-by: Shan Shaji <s.shaji@proxmox.com>
> ---
>   src/node_status_panel.rs | 25 +++++++++++++++++++++++--
>   1 file changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/src/node_status_panel.rs b/src/node_status_panel.rs
> index ec17a94..d1a02c2 100644
> --- a/src/node_status_panel.rs
> +++ b/src/node_status_panel.rs
> @@ -8,13 +8,13 @@ use pwt::widget::form::DisplayField;
>   use yew::virtual_dom::{VComp, VNode};
>   
>   use pwt::prelude::*;
> -use pwt::widget::{error_message, Fa, Panel, Row, Tooltip};
> +use pwt::widget::{Container, Fa, Panel, Row, Tooltip, error_message};
>   use pwt::widget::{Button, Dialog};
>   use pwt_macros::builder;
>   
>   use proxmox_node_status::{NodePowerCommand, NodeStatus};
>   
> -use crate::utils::copy_text_to_clipboard;
> +use crate::utils::{copy_text_to_clipboard, format_duration_human};
>   use crate::{
>       http_get, http_post, node_info, ConfirmButton, LoadableComponent, LoadableComponentContext,
>       LoadableComponentMaster, LoadableComponentScopeExt, LoadableComponentState,
> @@ -146,6 +146,26 @@ impl ProxmoxNodeStatusPanel {
>       }
>   }
>   
> +fn uptime_html(node_status: Option<&node_info::NodeStatus>) -> Option<Html> {
> +    let uptime =  match node_status {

nit: whitespace issue after '='

please rustfmt your code before sending

> +        Some(node_info::NodeStatus::Pve(node_status)) => node_status
> +            .additional_properties
> +            .get("uptime")
> +            .and_then(|uptime| uptime.as_u64())
> +            .unwrap_or_default(),

the better way would be to properly add the uptime field to the
return schema in pve-manager. Then we have to update pve-api-types to
include the 'uptime' field and then we can simply use it here.

IMO the issue is not so pressing that we have to circumvent this
schema update -> api-types update dance.


while i looked at the code in pve-manager where we return this, I
noticed that we always return an 'idle' field with value 0.
we do read the idle value from /proc/uptime there, but don't assign
it to the return value. Maybe that is something you can fix too
(in a separate patch, also adding the idle field to the return schema)

> +        Some(node_info::NodeStatus::Pbs(node_status)) => node_status.uptime,
> +        Some(node_info::NodeStatus::Common(node_status)) => node_status.uptime,
> +        None => 0
> +    };
> +
> +    if uptime == 0 {
> +        return None;
> +    }
> +
> +   let uptime_string = tr!("(Uptime: {})", format_duration_human(uptime as f64));
> +   Some(Container::from_tag("span").with_child(uptime_string).into())
> +}
> +
>   impl LoadableComponent for ProxmoxNodeStatusPanel {
>       type Message = Msg;
>       type ViewState = ViewState;
> @@ -229,6 +249,7 @@ impl LoadableComponent for ProxmoxNodeStatusPanel {
>                       .gap(2)
>                       .with_child(Fa::new("book"))
>                       .with_child(tr!("Node Status"))
> +                    .with_optional_child(uptime_html(status.as_ref()))
>                       .into_html(),
>               )
>               .with_child(node_info(status))





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-26  6:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-25 13:54 [PATCH proxmox-yew-comp] fix #7932: add missing uptime to the GUI Shan Shaji
2026-08-26  6:43 ` Dominik Csapak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal