Add manual refresh buttons for all servers and individual servers
All checks were successful
Build-Publish / build (linux/amd64) (push) Successful in 4s
Build-Publish / build (linux/arm64) (push) Successful in 12s
Build-Publish / create-manifest (push) Successful in 1s
Build-Publish / publish-template (push) Successful in 8s

This commit is contained in:
j
2026-03-08 16:31:03 +13:00
parent 939a79a91e
commit 4428ed60c4
3 changed files with 118 additions and 1 deletions

View File

@@ -10,6 +10,7 @@
<header>
<h1>Infrastructure Map</h1>
<span class="subtitle">Auto-refreshes every 60s | Built: {{ build_date }}</span>
<button class="refresh-btn" onclick="triggerRefresh(this)" title="Force re-collect from all servers">&#x21bb; Refresh</button>
</header>
<main>
@@ -52,6 +53,7 @@
{% if server.url %}
<a href="{{ server.url }}" class="server-link" target="_blank" rel="noopener" onclick="event.stopPropagation();" title="{{ server.url }}">&#x2197;</a>
{% endif %}
<button class="refresh-btn-sm" onclick="event.stopPropagation(); refreshServer(this, {{ server.id }})" title="Refresh this server">&#x21bb;</button>
</div>
<div class="server-ip">{{ server.primary_ip or 'No IP' }}</div>
<div class="server-os">{% if sys.get('platform') %}{{ sys.get('platform')|capitalize }} {{ sys.get('platform_version', '') }} / {% endif %}{{ sys.get('os_pretty', '') }}</div>
@@ -411,6 +413,22 @@
if (card) toggleDetails(card);
}
function refreshServer(btn, serverId) {
btn.disabled = true;
btn.textContent = '...';
fetch('/api/servers/' + serverId + '/refresh', {method: 'POST'})
.then(() => location.reload());
}
function triggerRefresh(btn) {
btn.disabled = true;
btn.textContent = 'Collecting...';
fetch('/api/refresh', {method: 'POST'}).then(() => {
// Wait a few seconds for collection to finish, then reload
setTimeout(() => location.reload(), 8000);
});
}
// If no servers have data yet, refresh quickly; otherwise every 60s
const hasData = document.querySelectorAll('.server-card').length > 0;
const refreshMs = hasData ? 60000 : 5000;