From 47ab1e387d4e7ec38d99369c83e90ef1f97a5f2f Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Mon, 1 Dec 2025 15:11:16 +0100 Subject: [PATCH] Add Status::Info for informational sub-services Agent uses Status enum to control display: - Status::Info: no icon, no status text (VPN IP) - Other statuses: icon + text (containers, nginx sites) Dashboard checks status, no hardcoded service_type exceptions. Version: v0.1.237 --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- agent/src/collectors/systemd.rs | 2 +- dashboard/Cargo.toml | 2 +- dashboard/src/ui/theme.rs | 3 +++ dashboard/src/ui/widgets/services.rs | 7 +++++-- shared/Cargo.toml | 2 +- shared/src/metrics.rs | 24 ++++++++++++++++++------ 8 files changed, 33 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 14ab373..e5f9b7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.236" +version = "0.1.237" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.236" +version = "0.1.237" dependencies = [ "anyhow", "async-trait", @@ -325,7 +325,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.236" +version = "0.1.237" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 3d1c40d..5b1b6d3 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.236" +version = "0.1.237" edition = "2021" [dependencies] diff --git a/agent/src/collectors/systemd.rs b/agent/src/collectors/systemd.rs index 30c49be..49f65a1 100644 --- a/agent/src/collectors/systemd.rs +++ b/agent/src/collectors/systemd.rs @@ -168,7 +168,7 @@ impl SystemdCollector { sub_services.push(SubServiceData { name: format!("ip: {}", external_ip), - service_status: Status::Ok, + service_status: Status::Info, metrics, service_type: "vpn_route".to_string(), }); diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index d9418bf..04bfdd2 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.236" +version = "0.1.237" edition = "2021" [dependencies] diff --git a/dashboard/src/ui/theme.rs b/dashboard/src/ui/theme.rs index 955244b..75028b9 100644 --- a/dashboard/src/ui/theme.rs +++ b/dashboard/src/ui/theme.rs @@ -142,6 +142,7 @@ impl Theme { /// Get color for status level pub fn status_color(status: Status) -> Color { match status { + Status::Info => Self::muted_text(), // Gray for informational data Status::Ok => Self::success(), Status::Inactive => Self::muted_text(), // Gray for inactive services in service list Status::Pending => Self::highlight(), // Blue for pending @@ -240,6 +241,7 @@ impl StatusIcons { /// Get status icon symbol pub fn get_icon(status: Status) -> &'static str { match status { + Status::Info => "", // No icon for informational data Status::Ok => "●", Status::Inactive => "○", // Empty circle for inactive services Status::Pending => "◉", // Hollow circle for pending @@ -254,6 +256,7 @@ impl StatusIcons { pub fn create_status_spans(status: Status, text: &str) -> Vec> { let icon = Self::get_icon(status); let status_color = match status { + Status::Info => Theme::muted_text(), // Gray for info Status::Ok => Theme::success(), // Green Status::Inactive => Theme::muted_text(), // Gray for inactive services Status::Pending => Theme::highlight(), // Blue diff --git a/dashboard/src/ui/widgets/services.rs b/dashboard/src/ui/widgets/services.rs index ddb008d..62b26a2 100644 --- a/dashboard/src/ui/widgets/services.rs +++ b/dashboard/src/ui/widgets/services.rs @@ -156,6 +156,7 @@ impl ServicesWidget { // Convert Status enum to display text let status_str = match info.widget_status { + Status::Info => "", // Shouldn't happen for parent services Status::Ok => "active", Status::Inactive => "inactive", Status::Critical => "failed", @@ -239,6 +240,7 @@ impl ServicesWidget { // Get status icon and text let icon = StatusIcons::get_icon(info.widget_status); let status_color = match info.widget_status { + Status::Info => Theme::muted_text(), Status::Ok => Theme::success(), Status::Inactive => Theme::muted_text(), Status::Pending => Theme::highlight(), @@ -259,6 +261,7 @@ impl ServicesWidget { } else { // Convert Status enum to display text for sub-services match info.widget_status { + Status::Info => "", Status::Ok => "active", Status::Inactive => "inactive", Status::Critical => "failed", @@ -298,8 +301,8 @@ impl ServicesWidget { .bg(Theme::background()), ), ] - } else if info.service_type == "vpn_route" { - // VPN route info - no status icon + } else if info.widget_status == Status::Info { + // Informational data - no status icon vec![ // Indentation and tree prefix ratatui::text::Span::styled( diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 4e099e1..9962dbf 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.236" +version = "0.1.237" edition = "2021" [dependencies] diff --git a/shared/src/metrics.rs b/shared/src/metrics.rs index 913344f..c4a3231 100644 --- a/shared/src/metrics.rs +++ b/shared/src/metrics.rs @@ -82,12 +82,13 @@ impl MetricValue { /// Health status for metrics #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] pub enum Status { - Inactive, // Lowest priority - Unknown, // - Offline, // - Pending, // - Ok, // 5th place - good status has higher priority than unknown states - Warning, // + Info, // Lowest priority - informational data with no status (no icon) + Inactive, // + Unknown, // + Offline, // + Pending, // + Ok, // Good status has higher priority than unknown states + Warning, // Critical, // Highest priority } @@ -223,6 +224,17 @@ impl HysteresisThresholds { Status::Ok } } + Status::Info => { + // Informational data shouldn't be used with hysteresis calculations + // Treat like Unknown if it somehow ends up here + if value >= self.critical_high { + Status::Critical + } else if value >= self.warning_high { + Status::Warning + } else { + Status::Ok + } + } } } }