- NTP client syncs from configurable pools and servers - NTP server mode serves time to LAN clients - Web UI dashboard showing sync status, sources, and clients - Supports iburst and maxsources options Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
478 lines
16 KiB
HTML
478 lines
16 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Chrony NTP Server</title>
|
|
<style>
|
|
:root {
|
|
--primary-color: #03a9f4;
|
|
--background-color: #1c1c1c;
|
|
--card-background: #2c2c2c;
|
|
--text-color: #e0e0e0;
|
|
--text-secondary: #9e9e9e;
|
|
--success-color: #4caf50;
|
|
--warning-color: #ff9800;
|
|
--error-color: #f44336;
|
|
--border-color: #404040;
|
|
}
|
|
|
|
* {
|
|
box-sizing: border-box;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
background-color: var(--background-color);
|
|
color: var(--text-color);
|
|
line-height: 1.6;
|
|
padding: 20px;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 30px;
|
|
padding-bottom: 20px;
|
|
border-bottom: 1px solid var(--border-color);
|
|
}
|
|
|
|
h1 {
|
|
font-size: 24px;
|
|
font-weight: 500;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
|
|
h1 .icon {
|
|
font-size: 28px;
|
|
}
|
|
|
|
.status-badge {
|
|
padding: 6px 12px;
|
|
border-radius: 20px;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.status-synced {
|
|
background-color: rgba(76, 175, 80, 0.2);
|
|
color: var(--success-color);
|
|
}
|
|
|
|
.status-warning {
|
|
background-color: rgba(255, 152, 0, 0.2);
|
|
color: var(--warning-color);
|
|
}
|
|
|
|
.status-error {
|
|
background-color: rgba(244, 67, 54, 0.2);
|
|
color: var(--error-color);
|
|
}
|
|
|
|
.grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
|
|
gap: 20px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.card {
|
|
background-color: var(--card-background);
|
|
border-radius: 12px;
|
|
padding: 20px;
|
|
border: 1px solid var(--border-color);
|
|
}
|
|
|
|
.card h2 {
|
|
font-size: 16px;
|
|
font-weight: 500;
|
|
color: var(--text-secondary);
|
|
margin-bottom: 15px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
.stat-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(2, 1fr);
|
|
gap: 15px;
|
|
}
|
|
|
|
.stat {
|
|
padding: 10px 0;
|
|
}
|
|
|
|
.stat-label {
|
|
font-size: 12px;
|
|
color: var(--text-secondary);
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: 18px;
|
|
font-weight: 500;
|
|
color: var(--text-color);
|
|
}
|
|
|
|
.stat-value.mono {
|
|
font-family: 'SF Mono', Monaco, 'Courier New', monospace;
|
|
}
|
|
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
}
|
|
|
|
th, td {
|
|
text-align: left;
|
|
padding: 12px 8px;
|
|
border-bottom: 1px solid var(--border-color);
|
|
}
|
|
|
|
th {
|
|
font-size: 12px;
|
|
color: var(--text-secondary);
|
|
font-weight: 500;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
td {
|
|
font-size: 14px;
|
|
}
|
|
|
|
.source-state {
|
|
display: inline-block;
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
margin-right: 8px;
|
|
}
|
|
|
|
.source-state.synced { background-color: var(--success-color); }
|
|
.source-state.combined { background-color: #8bc34a; }
|
|
.source-state.candidate { background-color: var(--primary-color); }
|
|
.source-state.unreachable { background-color: var(--text-secondary); }
|
|
.source-state.falseticker { background-color: var(--error-color); }
|
|
.source-state.variable { background-color: var(--warning-color); }
|
|
|
|
.button-group {
|
|
display: flex;
|
|
gap: 10px;
|
|
margin-top: 15px;
|
|
}
|
|
|
|
.btn {
|
|
padding: 10px 20px;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.btn-primary {
|
|
background-color: var(--primary-color);
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background-color: #0288d1;
|
|
}
|
|
|
|
.btn-secondary {
|
|
background-color: var(--border-color);
|
|
color: var(--text-color);
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
background-color: #505050;
|
|
}
|
|
|
|
.config-list {
|
|
list-style: none;
|
|
}
|
|
|
|
.config-list li {
|
|
padding: 8px 0;
|
|
border-bottom: 1px solid var(--border-color);
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.config-list li:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.tag {
|
|
font-size: 12px;
|
|
padding: 2px 8px;
|
|
border-radius: 4px;
|
|
background-color: var(--border-color);
|
|
}
|
|
|
|
.tag.enabled {
|
|
background-color: rgba(76, 175, 80, 0.2);
|
|
color: var(--success-color);
|
|
}
|
|
|
|
.refresh-info {
|
|
font-size: 12px;
|
|
color: var(--text-secondary);
|
|
text-align: center;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.toast {
|
|
position: fixed;
|
|
bottom: 20px;
|
|
right: 20px;
|
|
padding: 12px 24px;
|
|
border-radius: 8px;
|
|
background-color: var(--card-background);
|
|
border: 1px solid var(--border-color);
|
|
display: none;
|
|
animation: slideIn 0.3s ease;
|
|
}
|
|
|
|
.toast.success { border-color: var(--success-color); }
|
|
.toast.error { border-color: var(--error-color); }
|
|
|
|
@keyframes slideIn {
|
|
from { transform: translateY(100px); opacity: 0; }
|
|
to { transform: translateY(0); opacity: 1; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<header>
|
|
<h1>
|
|
<span class="icon">🕐</span>
|
|
Chrony NTP Server
|
|
</h1>
|
|
{% if status.tracking.stratum and status.tracking.stratum != '0' %}
|
|
<span class="status-badge status-synced">● Synchronized</span>
|
|
{% else %}
|
|
<span class="status-badge status-warning">● Synchronizing</span>
|
|
{% endif %}
|
|
</header>
|
|
|
|
<div class="grid">
|
|
<div class="card">
|
|
<h2>Time Synchronization Status</h2>
|
|
<div class="stat-grid">
|
|
<div class="stat">
|
|
<div class="stat-label">Reference Server</div>
|
|
<div class="stat-value">{{ status.tracking.reference_name or 'N/A' }}</div>
|
|
</div>
|
|
<div class="stat">
|
|
<div class="stat-label">Stratum</div>
|
|
<div class="stat-value">{{ status.tracking.stratum or 'N/A' }}</div>
|
|
</div>
|
|
<div class="stat">
|
|
<div class="stat-label">System Time Offset</div>
|
|
<div class="stat-value mono">{{ status.tracking.system_time or 'N/A' }}</div>
|
|
</div>
|
|
<div class="stat">
|
|
<div class="stat-label">Frequency</div>
|
|
<div class="stat-value mono">{{ status.tracking.frequency or 'N/A' }} ppm</div>
|
|
</div>
|
|
<div class="stat">
|
|
<div class="stat-label">Root Delay</div>
|
|
<div class="stat-value mono">{{ status.tracking.root_delay or 'N/A' }}</div>
|
|
</div>
|
|
<div class="stat">
|
|
<div class="stat-label">Update Interval</div>
|
|
<div class="stat-value mono">{{ status.tracking.update_interval or 'N/A' }}s</div>
|
|
</div>
|
|
</div>
|
|
<div class="button-group">
|
|
<button class="btn btn-primary" onclick="forceSync()">Force Sync</button>
|
|
<button class="btn btn-secondary" onclick="burstSync()">Burst Mode</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h2>Configuration</h2>
|
|
<ul class="config-list">
|
|
<li>
|
|
<span>NTP Server Mode</span>
|
|
{% if options.enable_ntp_server %}
|
|
<span class="tag enabled">Enabled</span>
|
|
{% else %}
|
|
<span class="tag">Disabled</span>
|
|
{% endif %}
|
|
</li>
|
|
<li>
|
|
<span>Detailed Logging</span>
|
|
{% if options.detailed_logging %}
|
|
<span class="tag enabled">Enabled</span>
|
|
{% else %}
|
|
<span class="tag">Disabled</span>
|
|
{% endif %}
|
|
</li>
|
|
<li>
|
|
<span>NTP Pools</span>
|
|
<span class="tag">{{ options.ntp_pools|default([])|length }}</span>
|
|
</li>
|
|
<li>
|
|
<span>NTP Servers</span>
|
|
<span class="tag">{{ options.ntp_servers|default([])|length }}</span>
|
|
</li>
|
|
<li>
|
|
<span>Allowed Networks</span>
|
|
<span class="tag">{{ options.allow_clients|length }}</span>
|
|
</li>
|
|
</ul>
|
|
<p style="margin-top: 15px; font-size: 13px; color: var(--text-secondary);">
|
|
To modify settings, go to Add-on Configuration in Home Assistant.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h2>NTP Sources</h2>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Status</th>
|
|
<th>Server</th>
|
|
<th>Stratum</th>
|
|
<th>Poll</th>
|
|
<th>Reach</th>
|
|
<th>Offset</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for source in status.sources %}
|
|
<tr>
|
|
<td>
|
|
{% if source.state == '*' %}
|
|
<span class="source-state synced"></span>Synced
|
|
{% elif source.state == '+' %}
|
|
<span class="source-state combined"></span>Combined
|
|
{% elif source.state == '-' %}
|
|
<span class="source-state candidate"></span>Candidate
|
|
{% elif source.state == '?' %}
|
|
<span class="source-state unreachable"></span>Unreachable
|
|
{% elif source.state == 'x' %}
|
|
<span class="source-state falseticker"></span>Falseticker
|
|
{% elif source.state == '~' %}
|
|
<span class="source-state variable"></span>Variable
|
|
{% else %}
|
|
<span class="source-state unreachable"></span>Unknown
|
|
{% endif %}
|
|
</td>
|
|
<td>{{ source.name }}</td>
|
|
<td>{{ source.stratum }}</td>
|
|
<td>{{ (2 ** (source.poll | int)) }}s</td>
|
|
<td>{{ source.reach }}</td>
|
|
<td>{{ source.last_sample_offset }}</td>
|
|
</tr>
|
|
{% else %}
|
|
<tr>
|
|
<td colspan="6" style="text-align: center; color: var(--text-secondary);">
|
|
No sources available yet. Chrony may still be starting up.
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
{% if options.enable_ntp_server %}
|
|
<div class="card" style="margin-top: 20px;">
|
|
<h2>Connected Clients</h2>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Client</th>
|
|
<th>NTP Requests</th>
|
|
<th>Dropped</th>
|
|
<th>Last Seen</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for client in status.clients %}
|
|
<tr>
|
|
<td>{{ client.hostname }}</td>
|
|
<td>{{ client.ntp_requests }}</td>
|
|
<td>{{ client.drop }}</td>
|
|
<td>{{ client.last_rx }}</td>
|
|
</tr>
|
|
{% else %}
|
|
<tr>
|
|
<td colspan="4" style="text-align: center; color: var(--text-secondary);">
|
|
No clients have connected yet.
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
|
|
<h3 style="margin-top: 20px; font-size: 14px; color: var(--text-secondary);">Allowed Networks</h3>
|
|
<ul class="config-list" style="margin-top: 10px;">
|
|
{% for network in options.allow_clients %}
|
|
<li>{{ network }}</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<p class="refresh-info">Page auto-refreshes every 30 seconds • Last updated: <span id="lastUpdate"></span></p>
|
|
</div>
|
|
|
|
<div id="toast" class="toast"></div>
|
|
|
|
<script>
|
|
// Get base path for API calls (handles HA ingress prefix)
|
|
const basePath = window.location.pathname.replace(/\/$/, '');
|
|
|
|
// Update timestamp
|
|
document.getElementById('lastUpdate').textContent = new Date().toLocaleTimeString();
|
|
|
|
// Auto-refresh every 30 seconds
|
|
setTimeout(() => location.reload(), 30000);
|
|
|
|
function showToast(message, type) {
|
|
const toast = document.getElementById('toast');
|
|
toast.textContent = message;
|
|
toast.className = 'toast ' + type;
|
|
toast.style.display = 'block';
|
|
setTimeout(() => toast.style.display = 'none', 3000);
|
|
}
|
|
|
|
function forceSync() {
|
|
fetch(basePath + '/api/force-sync', { method: 'POST' })
|
|
.then(r => r.json())
|
|
.then(data => {
|
|
showToast(data.message, data.success ? 'success' : 'error');
|
|
if (data.success) setTimeout(() => location.reload(), 1000);
|
|
})
|
|
.catch(() => showToast('Failed to connect', 'error'));
|
|
}
|
|
|
|
function burstSync() {
|
|
fetch(basePath + '/api/burst', { method: 'POST' })
|
|
.then(r => r.json())
|
|
.then(data => {
|
|
showToast(data.message, data.success ? 'success' : 'error');
|
|
})
|
|
.catch(() => showToast('Failed to connect', 'error'));
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|