Clean up services widget column headers and units

Standardize all services widget columns to show units in headers
and remove units from metric values for cleaner display.

Changes:
- Update column headers: "RAM (GB)", "CPU (%)", "Disk (GB)"
- Remove units from metric values:
  - RAM: "5.2/32.0" (no GB)
  - CPU: "2.5" (no %)
  - Disk: "1.5/500.0" (no GB)
- Simplify disk formatting to always show GB format

All columns now consistently display units in headers with
clean, uncluttered metric values.
This commit is contained in:
Christoffer Martinsson 2025-10-14 10:36:38 +02:00
parent 4be1223a8d
commit 8de3d2ba79

View File

@ -50,7 +50,7 @@ fn render_metrics(
let mut data = WidgetData::new(
title,
Some(WidgetStatus::new(widget_status)),
vec!["Service".to_string(), "RAM (GB)".to_string(), "CPU".to_string(), "Disk".to_string()]
vec!["Service".to_string(), "RAM (GB)".to_string(), "CPU (%)".to_string(), "Disk (GB)".to_string()]
);
@ -152,25 +152,14 @@ fn format_memory_value(used: f32, quota: f32) -> String {
fn format_cpu_value(cpu_percent: f32) -> String {
if cpu_percent >= 0.1 {
format!("{:.1}%", cpu_percent)
format!("{:.1}", cpu_percent)
} else {
"0.0%".to_string()
"0.0".to_string()
}
}
fn format_disk_value(used: f32, quota: f32) -> String {
if quota > 0.05 {
// Show usage/quota format when quota is set
format!("{:.1}/{:.1} GB", used, quota)
} else if used >= 1.0 {
format!("{:.1} GB", used)
} else if used >= 0.001 {
// 1 MB or more
format!("{:.0} MB", used * 1000.0)
} else if used > 0.0 {
"<1 MB".to_string()
} else {
"".to_string() // Em dash for no disk usage
}
// Always show in GB format with usage/quota, no units (units in column header)
format!("{:.1}/{:.1}", used, quota)
}