Fix dashboard UI: correct pending color (blue) and use host_status_summary metric
This commit is contained in:
@@ -357,23 +357,41 @@ impl TuiApp {
|
||||
return Status::Unknown;
|
||||
}
|
||||
|
||||
// Check if any metric is critical
|
||||
if metrics.iter().any(|m| m.status == Status::Critical) {
|
||||
return Status::Critical;
|
||||
// First check if we have the aggregated host status summary from the agent
|
||||
if let Some(host_summary_metric) = metric_store.get_metric(hostname, "host_status_summary") {
|
||||
return host_summary_metric.status;
|
||||
}
|
||||
|
||||
// Check if any metric is warning
|
||||
if metrics.iter().any(|m| m.status == Status::Warning) {
|
||||
return Status::Warning;
|
||||
// Fallback to old aggregation logic with proper Pending handling
|
||||
let mut has_critical = false;
|
||||
let mut has_warning = false;
|
||||
let mut has_pending = false;
|
||||
let mut ok_count = 0;
|
||||
let mut total_count = 0;
|
||||
|
||||
for metric in &metrics {
|
||||
total_count += 1;
|
||||
match metric.status {
|
||||
Status::Critical => has_critical = true,
|
||||
Status::Warning => has_warning = true,
|
||||
Status::Pending => has_pending = true,
|
||||
Status::Ok => ok_count += 1,
|
||||
Status::Unknown => {} // Ignore unknown for aggregation
|
||||
}
|
||||
}
|
||||
|
||||
// Check if all metrics are ok
|
||||
if metrics.iter().all(|m| m.status == Status::Ok) {
|
||||
return Status::Ok;
|
||||
// Priority order: Critical > Warning > Pending > Ok > Unknown
|
||||
if has_critical {
|
||||
Status::Critical
|
||||
} else if has_warning {
|
||||
Status::Warning
|
||||
} else if has_pending {
|
||||
Status::Pending
|
||||
} else if ok_count > 0 {
|
||||
Status::Ok
|
||||
} else {
|
||||
Status::Unknown
|
||||
}
|
||||
|
||||
// Default to unknown if mixed statuses
|
||||
Status::Unknown
|
||||
}
|
||||
|
||||
fn render_system_panel(&mut self, frame: &mut Frame, area: Rect, metric_store: &MetricStore) {
|
||||
|
||||
@@ -143,7 +143,7 @@ impl Theme {
|
||||
pub fn status_color(status: Status) -> Color {
|
||||
match status {
|
||||
Status::Ok => Self::success(),
|
||||
Status::Pending => Self::info(), // Blue for pending
|
||||
Status::Pending => Self::highlight(), // Blue for pending
|
||||
Status::Warning => Self::warning(),
|
||||
Status::Critical => Self::error(),
|
||||
Status::Unknown => Self::muted_text(),
|
||||
@@ -258,7 +258,7 @@ impl StatusIcons {
|
||||
let icon = Self::get_icon(status);
|
||||
let status_color = match status {
|
||||
Status::Ok => Theme::success(), // Green
|
||||
Status::Pending => Theme::info(), // Blue
|
||||
Status::Pending => Theme::highlight(), // Blue
|
||||
Status::Warning => Theme::warning(), // Yellow
|
||||
Status::Critical => Theme::error(), // Red
|
||||
Status::Unknown => Theme::muted_text(), // Gray
|
||||
|
||||
@@ -156,7 +156,7 @@ impl ServicesWidget {
|
||||
|
||||
let status_color = match info.widget_status {
|
||||
Status::Ok => Theme::success(),
|
||||
Status::Pending => Theme::info(),
|
||||
Status::Pending => Theme::highlight(),
|
||||
Status::Warning => Theme::warning(),
|
||||
Status::Critical => Theme::error(),
|
||||
Status::Unknown => Theme::muted_text(),
|
||||
|
||||
Reference in New Issue
Block a user