233 lines
7.9 KiB
HTML
233 lines
7.9 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: 20px;
|
|
}
|
|
|
|
/* Suchfeld Styling */
|
|
.search-container {
|
|
max-width: 1000px;
|
|
margin-bottom: 30px;
|
|
}
|
|
#searchInput {
|
|
width: 100%;
|
|
padding: 12px 15px;
|
|
border-radius: 6px;
|
|
border: 1px solid #333;
|
|
background-color: #1e1e1e;
|
|
color: #fff;
|
|
font-size: 1rem;
|
|
box-sizing: border-box;
|
|
transition: border-color 0.2s;
|
|
}
|
|
#searchInput:focus {
|
|
outline: none;
|
|
border-color: #4da6ff;
|
|
}
|
|
#searchInput::placeholder {
|
|
color: #888;
|
|
}
|
|
|
|
#dashboard {
|
|
max-width: 1000px;
|
|
}
|
|
|
|
/* Server-Block Überschrift */
|
|
.server-group-title {
|
|
font-size: 1.1rem;
|
|
color: #4da6ff;
|
|
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 */
|
|
.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 class="search-container">
|
|
<input type="text" id="searchInput" placeholder="🔍 Nodes durchsuchen..." autocomplete="off">
|
|
</div>
|
|
|
|
<div id="dashboard">
|
|
<p>Lade Status-Daten...</p>
|
|
</div>
|
|
|
|
<script>
|
|
const API_URL = 'api.php';
|
|
|
|
// Such-Logik
|
|
function applySearchFilter() {
|
|
const searchTerm = document.getElementById('searchInput').value.toLowerCase();
|
|
const serverGroups = document.querySelectorAll('.server-group-title');
|
|
const nodeLists = document.querySelectorAll('.node-list');
|
|
|
|
nodeLists.forEach((list, index) => {
|
|
let hasVisibleNodes = false;
|
|
const rows = list.querySelectorAll('.node-row');
|
|
|
|
rows.forEach(row => {
|
|
const clientName = row.querySelector('.client-name').textContent.toLowerCase();
|
|
|
|
// Zeile anzeigen, wenn Suchbegriff im Client-Namen enthalten ist
|
|
if (clientName.includes(searchTerm)) {
|
|
row.style.display = 'flex';
|
|
hasVisibleNodes = true;
|
|
} else {
|
|
row.style.display = 'none';
|
|
}
|
|
});
|
|
|
|
// Gesamte Server-Überschrift ausblenden, wenn kein Client darin den Suchkriterien entspricht
|
|
if (serverGroups[index]) {
|
|
serverGroups[index].style.display = hasVisibleNodes ? 'flex' : 'none';
|
|
}
|
|
});
|
|
}
|
|
|
|
// Event-Listener an das Suchfeld hängen
|
|
document.getElementById('searchInput').addEventListener('input', applySearchFilter);
|
|
|
|
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 => {
|
|
if (node.server !== currentServer) {
|
|
currentServer = node.server;
|
|
|
|
const header = document.createElement('h2');
|
|
header.className = 'server-group-title';
|
|
header.innerHTML = `🖥️ ${node.server}`;
|
|
dashboard.appendChild(header);
|
|
|
|
currentListContainer = document.createElement('div');
|
|
currentListContainer.className = 'node-list';
|
|
dashboard.appendChild(currentListContainer);
|
|
}
|
|
|
|
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.';
|
|
|
|
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);
|
|
});
|
|
|
|
// Suchfilter nach dem Neuladen der Daten direkt wieder anwenden
|
|
applySearchFilter();
|
|
|
|
} catch (err) {
|
|
console.error("Fehler beim Abrufen der Daten:", err);
|
|
}
|
|
}
|
|
|
|
fetchStatus();
|
|
setInterval(fetchStatus, 30000); // 30 Sekunden Refresh
|
|
</script>
|
|
</body>
|
|
</html> |