diff --git a/Cargo.lock b/Cargo.lock index ac43b28..525cccc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.148" +version = "0.1.149" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.148" +version = "0.1.149" dependencies = [ "anyhow", "async-trait", @@ -324,7 +324,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.148" +version = "0.1.149" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 6ee5787..35e4970 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.149" +version = "0.1.150" edition = "2021" [dependencies] diff --git a/agent/src/collectors/backup.rs b/agent/src/collectors/backup.rs index 8ef5a6a..b4c9e60 100644 --- a/agent/src/collectors/backup.rs +++ b/agent/src/collectors/backup.rs @@ -1,5 +1,5 @@ use async_trait::async_trait; -use chrono; +use chrono::{NaiveDateTime, DateTime}; use cm_dashboard_shared::{AgentData, BackupData, BackupDiskData}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -47,15 +47,7 @@ impl BackupCollector { /// Convert BackupStatusToml to BackupData and populate AgentData async fn populate_backup_data(&self, agent_data: &mut AgentData) -> Result<(), CollectorError> { if let Some(backup_status) = self.read_backup_status().await? { - // Parse start_time to get last_run timestamp - let last_run = if let Ok(parsed_time) = chrono::DateTime::parse_from_str(&backup_status.start_time, "%Y-%m-%d %H:%M:%S UTC") { - Some(parsed_time.timestamp() as u64) - } else { - None - }; - - // Calculate next_scheduled (if needed - may need to be provided by backup script) - let next_scheduled = None; // TODO: Extract from backup script if available + // Use raw start_time string from TOML // Extract disk information let repository_disk = if let Some(disk_space) = &backup_status.disk_space { @@ -89,12 +81,11 @@ impl BackupCollector { let backup_data = BackupData { status: backup_status.status, - last_run, - next_scheduled, total_size_gb: Some(total_size_gb), repository_health: Some("ok".to_string()), // Derive from status if needed repository_disk, last_backup_size_gb: None, // Not available in current TOML format + start_time_raw: Some(backup_status.start_time), }; agent_data.backup = backup_data; @@ -102,12 +93,11 @@ impl BackupCollector { // No backup status available - set default values agent_data.backup = BackupData { status: "unavailable".to_string(), - last_run: None, - next_scheduled: None, total_size_gb: None, repository_health: None, repository_disk: None, last_backup_size_gb: None, + start_time_raw: None, }; } diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 28b0afa..936d29c 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.149" +version = "0.1.150" edition = "2021" [dependencies] diff --git a/dashboard/src/ui/widgets/system.rs b/dashboard/src/ui/widgets/system.rs index 744e9ed..8ccb90b 100644 --- a/dashboard/src/ui/widgets/system.rs +++ b/dashboard/src/ui/widgets/system.rs @@ -39,8 +39,7 @@ pub struct SystemWidget { // Backup metrics backup_status: String, - backup_last_run: Option, - backup_next_scheduled: Option, + backup_start_time_raw: Option, backup_disk_serial: Option, backup_disk_usage_percent: Option, backup_disk_used_gb: Option, @@ -104,8 +103,7 @@ impl SystemWidget { tmpfs_mounts: Vec::new(), storage_pools: Vec::new(), backup_status: "unknown".to_string(), - backup_last_run: None, - backup_next_scheduled: None, + backup_start_time_raw: None, backup_disk_serial: None, backup_disk_usage_percent: None, backup_disk_used_gb: None, @@ -196,8 +194,7 @@ impl Widget for SystemWidget { // Extract backup data let backup = &agent_data.backup; self.backup_status = backup.status.clone(); - self.backup_last_run = backup.last_run; - self.backup_next_scheduled = backup.next_scheduled; + self.backup_start_time_raw = backup.start_time_raw.clone(); self.backup_last_size_gb = backup.last_backup_size_gb; if let Some(disk) = &backup.repository_disk { @@ -427,27 +424,17 @@ impl SystemWidget { let disk_spans = StatusIcons::create_status_spans(backup_status, &disk_text); lines.push(Line::from(disk_spans)); - // Last backup time - if let Some(last_run) = self.backup_last_run { - let time_ago = self.format_time_ago(last_run); - let last_text = if let Some(size) = self.backup_last_size_gb { - format!("Last: {} ({:.1}GB)", time_ago, size) + // Show backup time from TOML if available + if let Some(start_time) = &self.backup_start_time_raw { + let time_text = if let Some(size) = self.backup_last_size_gb { + format!("Time: {} ({:.1}GB)", start_time, size) } else { - format!("Last: {}", time_ago) + format!("Time: {}", start_time) }; lines.push(Line::from(vec![ Span::styled(" ├─ ", Typography::tree()), - Span::styled(last_text, Typography::secondary()) - ])); - } - - // Next backup time - if let Some(next_scheduled) = self.backup_next_scheduled { - let next_text = format!("Next: {}", self.format_time_until(next_scheduled)); - lines.push(Line::from(vec![ - Span::styled(" ├─ ", Typography::tree()), - Span::styled(next_text, Typography::secondary()) + Span::styled(time_text, Typography::secondary()) ])); } @@ -602,9 +589,6 @@ impl SystemWidget { // Backup section (if available) if self.backup_status != "unavailable" && self.backup_status != "unknown" { - lines.push(Line::from(vec![ - Span::styled("", Typography::secondary()) // Empty line for spacing - ])); lines.push(Line::from(vec![ Span::styled("Backup:", Typography::widget_title()) ])); diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 2bc1aea..88b0cb0 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.149" +version = "0.1.150" edition = "2021" [dependencies] diff --git a/shared/src/agent_data.rs b/shared/src/agent_data.rs index 11248fc..dd0f119 100644 --- a/shared/src/agent_data.rs +++ b/shared/src/agent_data.rs @@ -138,12 +138,11 @@ pub struct SubServiceMetric { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct BackupData { pub status: String, - pub last_run: Option, - pub next_scheduled: Option, pub total_size_gb: Option, pub repository_health: Option, pub repository_disk: Option, pub last_backup_size_gb: Option, + pub start_time_raw: Option, } /// Backup repository disk information @@ -193,12 +192,11 @@ impl AgentData { services: Vec::new(), backup: BackupData { status: "unknown".to_string(), - last_run: None, - next_scheduled: None, total_size_gb: None, repository_health: None, repository_disk: None, last_backup_size_gb: None, + start_time_raw: None, }, } }