From 2069cb104544d4211763d5b8c4d241a7781fe4d8 Mon Sep 17 00:00:00 2001 From: Junior Date: Mon, 5 May 2025 21:41:26 -0400 Subject: [PATCH] Add devices tab with list of known devices/boards --- ajax/getdevices.php | 26 ++++++++++++++++++++++++++ css/main.css | 28 ++++++++++++++++++++++++++++ index.php | 5 +++++ js/minimal.js | 41 ++++++++++++++++++++++++++++++++++++++++- 4 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 ajax/getdevices.php diff --git a/ajax/getdevices.php b/ajax/getdevices.php new file mode 100644 index 0000000..f64a071 --- /dev/null +++ b/ajax/getdevices.php @@ -0,0 +1,26 @@ +prepare($query); +$sth->execute(); + +$data = array(); +while ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) { + $d = array(); + $d["mac"] = $row["mac"]; + $d["ipaddress"] = $row["ipaddress"]; + $d["label"] = $row["label"]; + $d["board"] = $row["board"]; + $d["firmware"] = $row["firmware"]; + $d["service"] = $row["service"]; + $d["lastupdate"] = $row["lastupdate"]; + $data[] = $d; +} + +header('Content-Type: application/json'); +echo json_encode($data); +exit(); + +// vim: et ai sw=3 ts=3: diff --git a/css/main.css b/css/main.css index f614511..e20bb7f 100755 --- a/css/main.css +++ b/css/main.css @@ -108,3 +108,31 @@ input[type=button] { color: #D8D8D8; padding: 0px; } +.devices { + width: 80%; + margin-left: auto; + margin-right: auto; +} +.device-container { + width: 100%; + text-align: left; + margin-top: 0.5em; + padding: 0.25em; + border: 2px solid gray; +} +.device-property { + width: 100%; + text-align: left; +} +.device-property-label { + width: 12em; + text-align: right; + font-weight: bold; + color: white; + display: inline-block; + margin-right: 1em; +} +.button-refresh { + margin-top: 0.5em; + width: 12em; +} diff --git a/index.php b/index.php index 397ec2e..79a8e66 100644 --- a/index.php +++ b/index.php @@ -14,6 +14,7 @@ require "htmlheader.php";

@@ -53,6 +54,10 @@ require "htmlheader.php";

+
+

+
+
]/g, function(match) { + switch (match) { + case '&': return '&'; + case '<': return '<'; + case '>': return '>'; + default: return match; + } + }); +} + +function getDevices() { + $.ajax({ + url: 'ajax/getdevices.php', + dataType: 'json', + success: function(data, stat, jqo) { + var div = $("#devices"); + div.html(""); + var html = ""; + data.forEach((device) => { + html += "
"; + html += "
Service:" + escapeHTML(device.service) + "
"; + html += "
Label:" + escapeHTML(device.label) + "
"; + html += "
Board:" + escapeHTML(device.board) + "
"; + html += "
IP Address:" + escapeHTML(device.ipaddress) + "
"; + html += "
Last Update:" + escapeHTML(device.lastupdate) + "
"; + html += "
"; + }); + div.html(html); + } + }); +} + function setTarget(id) { $.ajax({ url: 'ajax/ajax_settarget.php', @@ -58,3 +95,5 @@ function setTarget(id) { } }); } + +// vim: ts=3 sw=3 ai: