From 128d20f3fe9a78225b1ed3f56a9cda135524c85a Mon Sep 17 00:00:00 2001
From: root <root@firmware.selfhosted.de>
Date: Sun, 3 Jan 2021 11:41:51 +0000
Subject: [PATCH] add HTML page

---
 update_checker.html | 87 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 update_checker.html

diff --git a/update_checker.html b/update_checker.html
new file mode 100644
index 0000000..591ca4b
--- /dev/null
+++ b/update_checker.html
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<html>
+<head>
+	<title>Update Checker</title>
+	<meta charset="utf-8">
+	<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
+	<style type="text/css">
+		body { font-family: sans-serif; }
+		.green { color: green; }
+		.red { color: red; }
+		table { border-collapse: collapse; }
+		table td, table th { border: 1px solid #000; border-left:0; border-right:0 }
+	</style>
+	<script>
+		function refreshUpdates() {
+			$.getJSON("/update_checker/data.json", function(data) {
+				$("#lastUpdate").text(data.timestamp)
+				var downloadedOffline = $("#downloadedOffline")
+				var downloaded = $("#downloaded")
+				downloadedOffline.empty()
+				downloaded.empty()
+				$.each(data["update_events"], function(k, upd) {
+					var line = $("<tr/>")
+					console.log(upd)
+					var maplink = "https://map.freifunk-stuttgart.de/#!/en/map/" + upd.mac.replace(/:/g, "").toLowerCase()
+					$("<td/>").append($("<a/>").text(upd.hostname).attr("href", maplink)).appendTo(line)
+					$("<td/>").text(upd.mac).appendTo(line)
+					$("<td/>").text(upd.from_release).appendTo(line)
+					$("<td/>").text(upd.to_release).appendTo(line)
+					$("<td/>").text(upd.model).appendTo(line)
+					var status = $("<td/>").text(upd.status)
+					if(upd.status) {
+						status.addClass("green")
+					} else {
+						status.addClass("red")
+					}
+					status.appendTo(line)
+					$("<td/>").text(upd.download_count).appendTo(line)
+					$("<td/>").text(upd.last_date).appendTo(line)
+
+					console.log(line)
+					if (upd.status) {
+						downloaded.append(line)
+					} else {
+						downloadedOffline.append(line)
+					}
+				})
+			})
+		}
+		$(document).ready(function() {
+			refreshUpdates()
+			//window.setInterval(refreshUpdates, 60*1000);
+		})
+	</script>
+</head>
+<body>
+	<h1>Update downloaded and offline</h1>
+	<p>Last update: <span id="lastUpdate">(never)</span></p>
+	<table>
+		<tr>
+			<th>Hostname</th>
+			<th>MAC</th>
+			<th>From Version</th>
+			<th>To Version</th>
+			<th>Model</th>
+			<th>Status</th>
+			<th>Download Count</th>
+			<th>Date</th>
+		</tr>
+		<tbody id="downloadedOffline"></tbody>
+	</table>
+	<h1>Update downloaded</h1>
+	<table>
+		<tr>
+			<th>Hostname</th>
+			<th>MAC</th>
+			<th>From Version</th>
+			<th>To Version</th>
+			<th>Model</th>
+			<th>Status</th>
+			<th>Download Count</th>
+			<th>Last Download</th>
+		</tr>
+		<tbody id="downloaded"></tbody>
+	</table>
+</body>
+</html>
-- 
GitLab