From 211a3f94771254829b10c846210d1fd12a9bef93 Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Wed, 1 May 2019 16:15:18 -0400 Subject: [PATCH] more ui work --- src/handlers.rs | 3 ++- src/main.rs | 3 ++- src/updater.rs | 3 ++- templates/index.html | 36 +++++++++++++++++++++++++----------- 4 files changed, 31 insertions(+), 14 deletions(-) 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 -%}