From f728da5216d1fd9373c2fc02647d56ceb0381355 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 6 May 2024 10:04:45 +0200 Subject: status summary --- src/style.css | 27 +++++++++++++++++++++++++-- src/web.rs | 13 ++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/style.css b/src/style.css index 0ebbed6..ef024f4 100644 --- a/src/style.css +++ b/src/style.css @@ -9,6 +9,9 @@ body { background-color: white; + --ok: rgb(130, 255, 80); + --error: rgb(255, 80, 80); + --degraded: rgb(255, 152, 68); } main { @@ -23,10 +26,12 @@ h1 { color: black; text-align: center; } + footer { text-align: center; margin-bottom: 5em; } + a { font-weight: bold; } @@ -37,6 +42,7 @@ h2 { color: black; } +div.summary, div.service, div.log { padding: 1em; @@ -44,12 +50,25 @@ div.log { box-shadow: 0 10px 60px rgba(0, 0, 0, 0.15); border-radius: 10px; } + +div.summary.ok { + background-color: var(--ok); +} +div.summary.error { + background-color: var(--error); +} +div.summary.degraded { + background-color: var(--degraded); +} + div.service.ok { - border-top: 12px solid rgb(130, 255, 80); + border-top: 12px solid var(--ok); } + div.service.error { - border-top: 12px solid rgb(255, 80, 80); + border-top: 12px solid var(--error); } + div.service a { color: black; float: inline-end; @@ -60,6 +79,7 @@ div.checks { width: 100%; grid-template-columns: 30% 10% 50% 10%; } + div.checks span { text-overflow: ellipsis; overflow: hidden; @@ -72,12 +92,15 @@ footer, footer a { color: rgb(173, 173, 173); } + span.status { font-weight: bolder; } + span.status.ok { color: rgb(39, 138, 0); } + span.status.error { color: rgb(158, 0, 0); } diff --git a/src/web.rs b/src/web.rs index c7bff3d..6437420 100644 --- a/src/web.rs +++ b/src/web.rs @@ -14,7 +14,11 @@ pub async fn make_html_page(config: Arc) -> String { let css = include_str!("style.css"); #[cfg(debug_assertions)] let css = tokio::fs::read_to_string("src/style.css").await.unwrap(); - + + + let total_err = status.values().map(|s|s.status.is_err() as usize).sum::(); + let total_ok = status.values().map(|s|s.status.is_ok() as usize).sum::(); + markup::new! { @doctype() html { @@ -27,6 +31,13 @@ pub async fn make_html_page(config: Arc) -> String { body { main { h1 { @config.title } + @if total_err == 0 { + div.summary.ok { "All services operational." } + } else if total_ok == 0 { + div.summary.error { "All services are broken." } + } else { + div.summary.degraded { "Degraded service. (" @total_ok " working, " @total_err " broken)" } + } @for (i, service) in config.services.iter().enumerate() { @ServiceCard { i, status, service } } -- cgit v1.2.3-70-g09d2