173 lines
6.0 KiB
HTML
173 lines
6.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Gateway Status</title>
|
|
<style>
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
background-color: #121212;
|
|
color: #e0e0e0;
|
|
margin: 0;
|
|
padding: 20px;
|
|
font-size: 14px;
|
|
}
|
|
h1 {
|
|
font-size: 1.5rem;
|
|
border-bottom: 2px solid #444;
|
|
padding-bottom: 10px;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
#dashboard {
|
|
max-width: 1000px;
|
|
}
|
|
|
|
/* Server-Block Überschrift */
|
|
.server-group-title {
|
|
font-size: 1.1rem;
|
|
color: #4da6ff; /* Ein schönes, techy Blau zur Abhebung */
|
|
margin-top: 35px;
|
|
margin-bottom: 12px;
|
|
padding-bottom: 6px;
|
|
border-bottom: 1px solid #333;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
.server-group-title:first-child {
|
|
margin-top: 0;
|
|
}
|
|
|
|
/* Kompaktes Listen-Layout */
|
|
.node-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 6px;
|
|
}
|
|
.node-row {
|
|
display: flex;
|
|
align-items: center;
|
|
background: #1e1e1e;
|
|
padding: 8px 12px;
|
|
border-radius: 6px;
|
|
border: 1px solid #2a2a2a;
|
|
transition: background 0.2s;
|
|
}
|
|
.node-row:hover { background: #252525; }
|
|
|
|
/* Status Indikator (Leuchtender Punkt) */
|
|
.status-dot {
|
|
width: 10px;
|
|
height: 10px;
|
|
border-radius: 50%;
|
|
margin-right: 15px;
|
|
flex-shrink: 0;
|
|
}
|
|
.online .status-dot { background-color: #00C851; box-shadow: 0 0 8px rgba(0, 200, 81, 0.5); }
|
|
.offline .status-dot { background-color: #ff4444; box-shadow: 0 0 8px rgba(255, 68, 68, 0.5); }
|
|
|
|
.client-name {
|
|
font-weight: 600;
|
|
width: 250px;
|
|
margin-right: 15px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.handshake {
|
|
color: #888;
|
|
font-size: 0.85rem;
|
|
flex-grow: 1;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.time {
|
|
color: #aaa;
|
|
font-size: 0.85rem;
|
|
text-align: right;
|
|
white-space: nowrap;
|
|
margin-left: 15px;
|
|
width: 90px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
/* Responsiv für Smartphones */
|
|
@media (max-width: 700px) {
|
|
.node-row { flex-wrap: wrap; gap: 5px; padding: 10px; }
|
|
.client-name { width: auto; margin-right: 10px; }
|
|
.handshake { width: 100%; margin-left: 25px; margin-top: 4px; }
|
|
.time { width: auto; margin-left: 25px; text-align: left; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Gateway Status Übersicht</h1>
|
|
<div id="dashboard">
|
|
<p>Lade Status-Daten...</p>
|
|
</div>
|
|
|
|
<script>
|
|
const API_URL = 'api.php';
|
|
|
|
async function fetchStatus() {
|
|
try {
|
|
const response = await fetch(API_URL);
|
|
const data = await response.json();
|
|
const dashboard = document.getElementById('dashboard');
|
|
dashboard.innerHTML = '';
|
|
|
|
let currentServer = null;
|
|
let currentListContainer = null;
|
|
|
|
data.forEach(node => {
|
|
// 1. Prüfen, ob wir einen neuen Server-Block anfangen müssen
|
|
if (node.server !== currentServer) {
|
|
currentServer = node.server;
|
|
|
|
// Überschrift für den Server anlegen
|
|
const header = document.createElement('h2');
|
|
header.className = 'server-group-title';
|
|
header.innerHTML = `🖥️ ${node.server}`;
|
|
dashboard.appendChild(header);
|
|
|
|
// Neuen Container für die Nodes dieses Servers anlegen
|
|
currentListContainer = document.createElement('div');
|
|
currentListContainer.className = 'node-list';
|
|
dashboard.appendChild(currentListContainer);
|
|
}
|
|
|
|
// 2. Zeit und Online/Offline Status berechnen
|
|
const lastSeen = new Date(node.last_seen + " UTC");
|
|
const now = new Date();
|
|
const diffMinutes = (now - lastSeen) / 1000 / 60;
|
|
|
|
const isOnline = (node.status === 'true' && diffMinutes < 5);
|
|
|
|
let timeText = Math.round(diffMinutes) + ' Min.';
|
|
if (diffMinutes < 1) timeText = '< 1 Min.';
|
|
|
|
// 3. Zeile erstellen und in den AKTUELLEN Server-Container einfügen
|
|
const row = document.createElement('div');
|
|
row.className = `node-row ${isOnline ? 'online' : 'offline'}`;
|
|
|
|
row.innerHTML = `
|
|
<div class="status-dot"></div>
|
|
<div class="client-name">${node.client}</div>
|
|
<div class="handshake">Handshake: ${node.handshake}</div>
|
|
<div class="time" title="Letztes Update: ${lastSeen.toLocaleString()}">vor ${timeText}</div>
|
|
`;
|
|
currentListContainer.appendChild(row);
|
|
});
|
|
} catch (err) {
|
|
console.error("Fehler beim Abrufen der Daten:", err);
|
|
}
|
|
}
|
|
|
|
fetchStatus();
|
|
setInterval(fetchStatus, 30000); // 30 Sekunden Refresh
|
|
</script>
|
|
</body>
|
|
</html> |