diff --git a/system_status/server.py b/system_status/server.py index 49a24c5..2a936a5 100644 --- a/system_status/server.py +++ b/system_status/server.py @@ -4,7 +4,6 @@ import requests from dataclasses import dataclass from typing import List -import time from zoneinfo import ZoneInfo from urllib.parse import urljoin @@ -15,6 +14,9 @@ from fastapi.staticfiles import StaticFiles +DISPLAY_TIMEZONE = ZoneInfo("America/Los_Angeles") + + @dataclass class TimestampAndValuePair: timestamp: str @@ -125,7 +127,10 @@ def get_prometheus_data() -> list[PrometheusData]: timestamps_and_values = [] for epoch_time, value in maybe_values: - timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(epoch_time)) + local_timestamp = datetime.datetime.fromtimestamp( + epoch_time, DISPLAY_TIMEZONE + ) + timestamp = local_timestamp.strftime("%Y-%m-%d | %H:%M:%S %Z") timestamps_and_values.append(TimestampAndValuePair(timestamp, value)) # the service is up if the maximum timestamp's value is "1" @@ -147,7 +152,7 @@ def get_prometheus_data() -> list[PrometheusData]: # expects an optional parameter as the target URL @app.get("/", response_class=HTMLResponse) def page_generator(request: Request): - local_datetime = datetime.datetime.now(ZoneInfo("America/Los_Angeles")) + local_datetime = datetime.datetime.now(DISPLAY_TIMEZONE) fetch_time = local_datetime.strftime("%Y-%m-%d %H:%M:%S") data = get_prometheus_data() diff --git a/system_status/templates/my_template.html b/system_status/templates/my_template.html index 44a2049..377f3a1 100644 --- a/system_status/templates/my_template.html +++ b/system_status/templates/my_template.html @@ -74,6 +74,57 @@ margin-right: 2px; } + .history-marker { + position: relative; + display: inline-block; + cursor: help; + outline-offset: 2px; + } + + .history-marker::before { + content: attr(data-tooltip); + position: absolute; + left: 50%; + bottom: calc(100% + 8px); + transform: translateX(-50%); + visibility: hidden; + opacity: 0; + z-index: 10; + padding: 6px 8px; + border-radius: 4px; + background-color: #222; + color: #fff; + font-family: Arial, sans-serif; + font-size: 13px; + font-weight: normal; + line-height: 1; + white-space: nowrap; + pointer-events: none; + transition: opacity 0.15s ease-in-out; + } + + .history-marker::after { + content: ""; + position: absolute; + left: 50%; + bottom: calc(100% + 2px); + transform: translateX(-50%); + visibility: hidden; + opacity: 0; + border: 4px solid transparent; + border-top-color: #222; + pointer-events: none; + transition: opacity 0.15s ease-in-out; + } + + .history-marker:hover::before, + .history-marker:hover::after, + .history-marker:focus::before, + .history-marker:focus::after { + visibility: visible; + opacity: 1; + } + #info_container{ display: inline-block; } @@ -99,11 +150,11 @@

Fetch Time: {{ fetch_time }}

Status Detail -
Prev. Day
+
Most Recent
◀➖➖➖➖➖➖➖➖
History of past 24 Hours
➖➖➖➖➖➖➖➖▶
-
Now
+
Earlier
{% for item in data %} @@ -121,12 +172,13 @@

Fetch Time: {{ fetch_time }}

{{ detail }} {# THIS IS THE CORRECTED SECTION for the EMOJI HISTORY #} - {% for value in item.values %} - {% if value.value == "1" %} - ✅ - {% else %} - ❌ - {% endif %} + {% for value in item.values | reverse %} + {% if value.value == "1" %}✅{% else %}❌{% endif %} {# the below if-statement adds a vertical line for every four entries #} {% if (not loop.index % 4) and loop.index < 24%} |