fix: always populate glance-strip for all hosts on page load
fetchHostGlance was only called for the initially expanded host, leaving all other hosts showing "—" until manually expanded. Now fetches glance for every host-card on DOMContentLoaded and refreshes all (not just expanded) on the 30s auto-refresh interval. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1305,9 +1305,12 @@
|
||||
// ── Auto-refresh (30 s) ─────────────────────────────────────────────────
|
||||
|
||||
setInterval(() => {
|
||||
document.querySelectorAll('.host-card').forEach(card => {
|
||||
fetchHostGlance(card.dataset.hostname);
|
||||
});
|
||||
|
||||
document.querySelectorAll('.host-card:not(.collapsed)').forEach(card => {
|
||||
const hostname = card.dataset.hostname;
|
||||
fetchHostGlance(hostname);
|
||||
|
||||
card.querySelectorAll('.plugin-accordion:not(.collapsed)').forEach(acc => {
|
||||
const pname = acc.dataset.plugin;
|
||||
@@ -1327,15 +1330,16 @@
|
||||
// ── Init ────────────────────────────────────────────────────────────────
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// If a host fragment is in the URL, expand and scroll to that host;
|
||||
// otherwise expand the first host as before.
|
||||
const hash = window.location.hash;
|
||||
if (hash) {
|
||||
const hostname = decodeURIComponent(hash.slice(1));
|
||||
// Fetch glance data for every host immediately so the strip is always populated.
|
||||
document.querySelectorAll('.host-card').forEach(card => {
|
||||
fetchHostGlance(card.dataset.hostname);
|
||||
});
|
||||
|
||||
// Expand and load info for the target host (URL hash or first host).
|
||||
function expandHost(hostname) {
|
||||
const card = document.querySelector(`.host-card[data-hostname="${hostname}"]`);
|
||||
if (card) {
|
||||
if (!card) return false;
|
||||
card.classList.remove('collapsed');
|
||||
fetchHostGlance(hostname);
|
||||
fetchHostInfo(hostname).then(data => {
|
||||
infoCache[hostname] = data;
|
||||
renderInfoSection(hostname, data);
|
||||
@@ -1343,23 +1347,22 @@
|
||||
const el = document.getElementById(`info-${hostname}`);
|
||||
if (el) el.innerHTML = '<div class="info-loading">Could not load host info.</div>';
|
||||
});
|
||||
setTimeout(() => card.scrollIntoView({ behavior: 'smooth', block: 'start' }), 150);
|
||||
return true;
|
||||
}
|
||||
|
||||
const hash = window.location.hash;
|
||||
if (hash) {
|
||||
const hostname = decodeURIComponent(hash.slice(1));
|
||||
if (expandHost(hostname)) {
|
||||
setTimeout(() => {
|
||||
const card = document.querySelector(`.host-card[data-hostname="${hostname}"]`);
|
||||
if (card) card.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
}, 150);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const first = document.querySelector('.host-card');
|
||||
if (first) {
|
||||
const hostname = first.dataset.hostname;
|
||||
first.classList.remove('collapsed');
|
||||
fetchHostGlance(hostname);
|
||||
fetchHostInfo(hostname).then(data => {
|
||||
infoCache[hostname] = data;
|
||||
renderInfoSection(hostname, data);
|
||||
}).catch(() => {
|
||||
const el = document.getElementById(`info-${hostname}`);
|
||||
if (el) el.innerHTML = '<div class="info-loading">Could not load host info.</div>';
|
||||
});
|
||||
}
|
||||
if (first) expandHost(first.dataset.hostname);
|
||||
});
|
||||
// ── Host action helpers ──────────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user