bethaus-app/templates/network.html
2025-03-22 17:03:26 +01:00

91 lines
3.0 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Recent Connections</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
/* Use full width */
.container-fluid {
height: 100%;
display: flex;
flex-direction: column;
}
/* Header area takes as much room as needed; the table container fills the rest */
.table-container {
flex: 1;
overflow-y: auto;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="p-3">
<h1 class="mb-4">Downloads in den letzten 10 Minute</h1>
<div class="mb-3">
<a href="{{ url_for('index') }}" class="btn btn-primary">Home</a>
<a href="{{ url_for('dashboard') }}" class="btn btn-primary">Dashboard</a>
</div>
</div>
<div class="table-responsive table-container">
<table class="table table-hover">
<thead class="table-info">
<tr>
<th>Timestamp</th>
<th>Full Path</th>
<th>IP Address</th>
<th>User Agent</th>
<th>Referrer</th>
</tr>
</thead>
<tbody id="connectionsTableBody">
<!-- Rows will be dynamically inserted here -->
</tbody>
</table>
</div>
</div>
<!-- Socket.IO client library -->
<script src="https://cdn.socket.io/4.0.0/socket.io.min.js"></script>
<!-- Using vanilla JavaScript for dynamic DOM updates -->
<script>
const socket = io();
socket.on('recent_connections', function(data) {
const tbody = document.getElementById('connectionsTableBody');
tbody.innerHTML = ''; // Clear previous content
data.forEach(record => {
const row = document.createElement('tr');
const timestampCell = document.createElement('td');
timestampCell.textContent = record.timestamp;
const fullPathCell = document.createElement('td');
fullPathCell.textContent = record.full_path;
const ipCell = document.createElement('td');
ipCell.textContent = record.ip_address;
const userAgentCell = document.createElement('td');
userAgentCell.textContent = record.user_agent;
const referrerCell = document.createElement('td');
referrerCell.textContent = record.referrer;
row.appendChild(timestampCell);
row.appendChild(fullPathCell);
row.appendChild(ipCell);
row.appendChild(userAgentCell);
row.appendChild(referrerCell);
tbody.appendChild(row);
});
});
</script>
<!-- Bootstrap 5 JS Bundle -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>