fix(client_details.html): fix up code for AJAX loading

This commit is contained in:
2026-03-12 20:42:45 +01:00
parent c442dca520
commit 762256c3cd

View File

@@ -1,30 +1,28 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Details for client {{ client.id }}</title>
<link
rel="stylesheet"
href="{{ url_for('static', filename='css/style.css') }}"
/>
</head>
<body>
<div class="details-header">
<p>Machine {{ client.id }}</p>
</div>
<div class="details-container">
<div class="details-sidebar">
<ul>
<li>
<a href="?tab=summary">
<i class="fi fi-ss-summary-check"></i>
<span>Summary</span>
</a>
</li>
</ul>
</div>
<div class="details-content">
<h1>Details for client {{ client.id }}</h1>
<p><strong>ID:</strong> {{ client.id }}</p>
<p><strong>IP Address:</strong> {{ client.addr[0] }}</p>
<p><strong>Port:</strong> {{ client.addr[1] }}</p>
<p>
<strong>Last Seen:</strong>
<span id="last-seen">{{ client.last_seen }}</span>
</p>
<p>
<strong>Initial:</strong>
<pre>{{ client.initial_telemetry | tojson(indent=2) }}</pre>
</p>
</body>
</div>
</div>
<script>
<script>
function updateLastSeen() {
const lastSeenElement = document.getElementById("last-seen");
const lastSeenTimestamp = parseInt(lastSeenElement.textContent);
@@ -32,6 +30,17 @@
lastSeenElement.textContent = lastSeenDate.toLocaleString();
}
$(".details-sidebar > ul > li > a").click(function (e) {
e.preventDefault();
const tab = $(this).attr("href").split("=")[1];
const urlParams = new URLSearchParams(window.location.search);
urlParams.set("tab", tab);
window.history.pushState(
{},
"",
`${window.location.pathname}?${urlParams}`,
);
});
updateLastSeen();
</script>
</html>
</script>