Display mount points instead of pool names in storage section

- Add mount_point field to StoragePool struct
- Create mapping from pool names to mount points
- Update display to show user-friendly mount points (/, /mnt/steampool)
- Keep device detection for SMART data (temperature, wear)
- Resolves disk name confusion on different hosts
This commit is contained in:
Christoffer Martinsson 2025-10-23 18:19:14 +02:00
parent d0ce1726e8
commit 473f89fb57

View File

@ -43,6 +43,7 @@ pub struct SystemWidget {
#[derive(Clone)]
struct StoragePool {
name: String,
mount_point: String,
pool_type: String, // "Single", "Raid0", etc.
drives: Vec<StorageDrive>,
usage_percent: Option<f32>,
@ -125,6 +126,17 @@ impl SystemWidget {
}
}
/// Get mount point for a pool name
fn get_mount_point_for_pool(&self, pool_name: &str) -> String {
match pool_name {
"root" => "/".to_string(),
"steampool" => "/mnt/steampool".to_string(),
"steampool_1" => "/steampool_1".to_string(),
"steampool_2" => "/steampool_2".to_string(),
_ => format!("/{}", pool_name), // Default fallback
}
}
/// Parse storage metrics into pools and drives
fn update_storage_from_metrics(&mut self, metrics: &[&Metric]) {
let mut pools: std::collections::HashMap<String, StoragePool> = std::collections::HashMap::new();
@ -132,8 +144,10 @@ impl SystemWidget {
for metric in metrics {
if metric.name.starts_with("disk_") {
if let Some(pool_name) = self.extract_pool_name(&metric.name) {
let mount_point = self.get_mount_point_for_pool(&pool_name);
let pool = pools.entry(pool_name.clone()).or_insert_with(|| StoragePool {
name: pool_name.clone(),
mount_point: mount_point.clone(),
pool_type: "Single".to_string(), // Default, could be enhanced
drives: Vec::new(),
usage_percent: None,
@ -246,7 +260,7 @@ impl SystemWidget {
let pool_spans = StatusIcons::create_status_spans(
pool.status.clone(),
&format!("{} ({}):", pool.name, pool.pool_type)
&format!("{} ({}):", pool.mount_point, pool.pool_type)
);
lines.push(Line::from(pool_spans));