//! Operational Dashboard view model for nx9-wg appliance. use serde::{Deserialize, Serialize}; /// Dashboard summary state for system metrics, WireGuard, and network status. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct DashboardState { // System status pub hostname: String, pub os_version: String, pub uptime_formatted: String, pub is_operational: bool, pub load_average: String, // WireGuard pub total_interfaces: usize, pub active_interfaces: usize, pub total_peers: usize, pub online_peers: usize, pub latest_handshake_relative: String, // Networking pub wan_ip: Option, pub default_gateway: Option, pub ipv4_forwarding_enabled: bool, pub ipv6_forwarding_enabled: bool, pub nat_masquerade_active: bool, // Traffic telemetry pub aggregate_rx_bytes_formatted: String, pub aggregate_tx_bytes_formatted: String, // Diagnostics & Drift pub diagnostics_pass_count: usize, pub diagnostics_warning_count: usize, pub diagnostics_fail_count: usize, pub reconciliation_drift_detected: bool, } impl Default for DashboardState { fn default() -> Self { Self { hostname: "nx9-wg-appliance".to_string(), os_version: "Linux native (nx9-wg v0.1.0)".to_string(), uptime_formatted: "3d 14h 22m".to_string(), is_operational: true, load_average: "0.15, 0.08, 0.03".to_string(), total_interfaces: 1, active_interfaces: 1, total_peers: 0, online_peers: 0, latest_handshake_relative: "None".to_string(), wan_ip: Some("198.51.100.1".to_string()), default_gateway: Some("198.51.100.254".to_string()), ipv4_forwarding_enabled: true, ipv6_forwarding_enabled: false, nat_masquerade_active: true, aggregate_rx_bytes_formatted: "0 B".to_string(), aggregate_tx_bytes_formatted: "0 B".to_string(), diagnostics_pass_count: 10, diagnostics_warning_count: 0, diagnostics_fail_count: 0, reconciliation_drift_detected: false, } } } #[cfg(test)] mod tests { use super::*; #[test] fn test_dashboard_state_default() { let state = DashboardState::default(); assert!(state.is_operational); assert_eq!(state.total_interfaces, 1); assert!(!state.reconciliation_drift_detected); } }