diff --git a/src/handlers.rs b/src/handlers.rs index 09c49fb..3b4b7b8 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -18,7 +18,8 @@ pub struct Status { #[derive(Serialize, Debug)] pub struct QueryResults { - pub last_update: DateTime, + pub timestamp: DateTime, + pub timestamp_str: String, pub refresh_time: u64, pub config: Config, pub statuses: Vec, diff --git a/src/main.rs b/src/main.rs index d0e86ef..4424c1b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,7 +41,8 @@ fn main() { env_logger::init(); let state: State = Arc::new(RwLock::new(QueryResults { - last_update: Utc::now(), + timestamp: Utc::now(), + timestamp_str: Utc::now().format("%Y-%m-%d %H:%M:%S").to_string(), refresh_time: config.refresh_time.clone(), config: config.clone(), statuses: update_status(&config), diff --git a/src/updater.rs b/src/updater.rs index 58f6157..6b01048 100644 --- a/src/updater.rs +++ b/src/updater.rs @@ -5,7 +5,8 @@ use reqwest::{Client, Url, UrlError}; pub fn update_state(state: State) { let new_statuses = { Some(update_status(&state.read().unwrap().config)) }; let mut write_state = state.try_write().expect("Could not unlock"); - write_state.last_update = Utc::now(); + write_state.timestamp = Utc::now(); + write_state.timestamp_str = Utc::now().format("%Y-%m-%d %H:%M:%S").to_string(); write_state.statuses = new_statuses.unwrap(); } diff --git a/templates/index.html b/templates/index.html index e2142ab..69de65e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -4,30 +4,40 @@ Endstat +
-

Welcome!

-

{{ results.last_update }}

+
+

Status

+

{{ results.timestamp_str }}

+
{% for status in results.statuses -%}
-

{{ status.domain }}

-

{{ status.endpoint }}

-

{{ status.location }}

- {% if status.error %}

{{ status.error }}

{% endif %} -
- +
+ +

{{ status.endpoint }}

+

{{ status.location }}

+ {% if status.error %}

{{ status.error }}

{% endif %} +
+
{% endfor -%}