Testing
This commit is contained in:
@@ -48,7 +48,7 @@ fn render_metrics(
|
||||
let mut data = WidgetData::new(
|
||||
title,
|
||||
Some(WidgetStatus::new(widget_status)),
|
||||
vec!["Service".to_string(), "Memory".to_string(), "Disk".to_string()]
|
||||
vec!["Service".to_string(), "Memory".to_string(), "CPU".to_string(), "Disk".to_string()]
|
||||
);
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ fn render_metrics(
|
||||
"No services reported".to_string(),
|
||||
"".to_string(),
|
||||
"".to_string(),
|
||||
"".to_string(),
|
||||
],
|
||||
);
|
||||
render_widget_data(frame, area, data);
|
||||
@@ -94,6 +95,7 @@ fn render_metrics(
|
||||
vec![
|
||||
svc.name.clone(),
|
||||
format_memory_value(svc.memory_used_mb, svc.memory_quota_mb),
|
||||
format_cpu_value(svc.cpu_percent),
|
||||
format_disk_value(svc.disk_used_gb),
|
||||
],
|
||||
);
|
||||
@@ -140,6 +142,16 @@ 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)
|
||||
} else if cpu_percent > 0.0 {
|
||||
"<0.1%".to_string()
|
||||
} else {
|
||||
"—".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
fn format_disk_value(used: f32) -> String {
|
||||
if used >= 1.0 {
|
||||
format!("{:.1} GiB", used)
|
||||
|
||||
Reference in New Issue
Block a user