From 142ce6581fda0e43adf5c623546e007571a7d0e4 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 12 Sep 2024 16:22:35 +1000 Subject: [PATCH] feat: Update style and cleanup ui --- server.py | 11 +++- templates/assets/css/index.css | 9 ++- templates/index.html | 100 ++++++++++++++++++--------------- 3 files changed, 72 insertions(+), 48 deletions(-) diff --git a/server.py b/server.py index 4ff13b3..0909197 100644 --- a/server.py +++ b/server.py @@ -589,7 +589,7 @@ def convert_nodes_to_dict(nodes): # region API routes @app.route("/api/nodes") def api_nodes(): - node_status = check_nodes() + node_status = check_nodes_from_log() return jsonify(node_status) @@ -686,6 +686,15 @@ def index(): history_summary["nodes"] = convert_nodes_to_dict(history_summary["nodes"]) last_check = format_last_check(last_log) + # Replace true/false with up/down + for node in node_status: + for key in ["plain_dns", "doh", "dot"]: + if node[key]: + node[key] = "Up" + else: + node[key] = "Down" + + return render_template( "index.html", nodes=node_status, diff --git a/templates/assets/css/index.css b/templates/assets/css/index.css index 7a23aee..b3d67e7 100644 --- a/templates/assets/css/index.css +++ b/templates/assets/css/index.css @@ -2,7 +2,7 @@ margin: 25px; border: solid; border-radius: 20px; - padding-inline: 50px; + padding: 20px; max-width: 90%; } @@ -15,4 +15,11 @@ width: 1000px; max-width: 95%; margin-top: 20px; +} +.node-info { + margin-top: 5px; + margin-bottom: 5px; +} +.node-info > p{ + margin: 0; } \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 44ee4f3..5b9374d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -42,23 +42,24 @@
+
-

HNS DoH

+

HNS DoH Status

{% if warnings %} - + {% endif %}
@@ -66,45 +67,52 @@
-
-

Nodes

- Last check: {{last_check}} -
-
-
-

Overall

-
-
-
Stats
-

Plain DNS: {{history.overall.plain_dns.percentage}}% uptime (last down {{history.overall.plain_dns.last_down}})

-

DNS over HTTPS: {{history.overall.doh.percentage}}% uptime (last down {{history.overall.doh.last_down}})

-

DNS over TLS: {{history.overall.dot.percentage}}% uptime (last down {{history.overall.dot.last_down}})

-
-
-
- {% for node in nodes %} -
-
-

{{node.location}}

-

({{ node.name }})

-
-
-
Current Status
-

Plain DNS: {{node.plain_dns}}

-

DNS over HTTPS: {{node.doh}}

-

DNS over TLS: {{node.dot}}

-

Certificate: {{node.cert.valid}} (expires {{node.cert.expires}})

-
-
-
Stats
-

Plain DNS: {{history.nodes[node.name].plain_dns.percentage}}% uptime (last down {{history.nodes[node.name].plain_dns.last_down}})

-

DNS over HTTPS: {{history.nodes[node.name].doh.percentage}}% uptime (last down {{history.nodes[node.name].doh.last_down}})

-

DNS over TLS: {{history.nodes[node.name].dot.percentage}}% uptime (last down {{history.nodes[node.name].dot.last_down}})

-
-
- - {% endfor %} +
+ Last check: {{last_check}} +
+
+
+

Overall Stats

+
+
+

Plain DNS: {{history.overall.plain_dns.percentage}}% uptime (last down + {{history.overall.plain_dns.last_down}})

+

DNS over HTTPS: {{history.overall.doh.percentage}}% uptime (last down + {{history.overall.doh.last_down}})

+

DNS over TLS: {{history.overall.dot.percentage}}% uptime (last down + {{history.overall.dot.last_down}})

+
+
+ {% for node in nodes %} +
+
+

{{node.location}}

+
+
+
Current Status
+

Plain DNS: {{node.plain_dns}}

+

DNS over HTTPS: {{node.doh}}

+

DNS over TLS: {{node.dot}}

+

Certificate: {% if node.cert.valid %} Valid {% else %} Invalid {% endif %} (expires + {{node.cert.expires}})

+
+
+
Stats
+

Plain DNS: {{history.nodes[node.name].plain_dns.percentage}}% uptime (last down + {{history.nodes[node.name].plain_dns.last_down}})

+

DNS over HTTPS: {{history.nodes[node.name].doh.percentage}}% uptime (last down + {{history.nodes[node.name].doh.last_down}})

+

DNS over TLS: {{history.nodes[node.name].dot.percentage}}% uptime (last down + {{history.nodes[node.name].dot.last_down}})

+
+
+

{{node.name}}: {{node.ip}}

+
+
+ + {% endfor %} +