Add disk quota display to services widget
Implement disk quota/total display in services widget showing usage/quota format. When services don't have specific disk quotas configured, use system total disk capacity as the quota value. Changes: - Add disk_quota_gb field to ServiceData struct in agent - Add disk_quota_gb field to ServiceInfo struct in dashboard - Update format_disk_value to show usage/quota format - Use system disk total capacity as default quota for services - Rename DiskUsage.total_gb to total_capacity_gb for clarity Services will now display disk usage as "5.2/500.0 GB" format where 500.0 GB is either the service's specific quota or system total capacity.
This commit is contained in:
@@ -117,6 +117,8 @@ pub struct ServiceInfo {
|
||||
#[serde(default)]
|
||||
pub disk_used_gb: f32,
|
||||
#[serde(default)]
|
||||
pub disk_quota_gb: f32,
|
||||
#[serde(default)]
|
||||
pub description: Option<Vec<String>>,
|
||||
#[serde(default)]
|
||||
pub sub_service: Option<String>,
|
||||
|
||||
@@ -126,7 +126,7 @@ fn render_metrics(
|
||||
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),
|
||||
format_disk_value(svc.disk_used_gb, svc.disk_quota_gb),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -158,14 +158,19 @@ fn format_cpu_value(cpu_percent: f32) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn format_disk_value(used: f32) -> String {
|
||||
if used >= 1.0 {
|
||||
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 {
|
||||
} else if used > 0.0 {
|
||||
"<1 MB".to_string()
|
||||
} else {
|
||||
"—".to_string() // Em dash for no disk usage
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user