Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions clusters.html
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ <h1>Cluster Status</h1>
<div class="stat-box">
<div class="stat-label">API Version</div>
<div class="stat-value" id="api-version">--</div>
<div class="stat-subvalue">Payload version for this endpoint</div>
<div class="stat-subvalue" id="api-version-note">Payload version for this endpoint</div>
</div>
<div class="stat-box">
<div class="stat-label">Server Uptime</div>
Expand Down Expand Up @@ -657,6 +657,8 @@ <h2>Clusters</h2>
<script>
const gauges = {};
const latencyCapMs = 300;
const tabStorageKey = 'clusterDashboard.activeTab';
const validTabs = ['overview', 'system', 'latency', 'clusters'];

const gaugeNeedle = {
id: 'gaugeNeedle',
Expand Down Expand Up @@ -788,9 +790,10 @@ <h3 class="detail-card-title">${title}</h3>
const container = document.getElementById('system-details');
container.innerHTML = '';
const coreInfo = getCoreSummaryInfo(systemStats);
const apiVersion = data.version ?? data.api_version ?? data.payload_version ?? null;

const topRows = [];
addDetailRow(topRows, 'API Version', data.version);
addDetailRow(topRows, 'API Version', apiVersion ?? 'Not reported');
addDetailRow(topRows, 'Bot Uptime', data.bot_uptime);
addDetailRow(topRows, 'Server Uptime', data.server_uptime);
addDetailRow(topRows, 'Clusters Reported', Array.isArray(data.clusters) ? data.clusters.length : 0);
Expand Down Expand Up @@ -893,21 +896,39 @@ <h3 class="detail-card-title">${title}</h3>
}

function setActiveTab(tabName) {
const resolvedTab = validTabs.includes(tabName) ? tabName : 'overview';
const tabs = document.querySelectorAll('.tab-button');
const panels = document.querySelectorAll('.tab-panel');

tabs.forEach(tab => {
const isActive = tab.dataset.tab === tabName;
const isActive = tab.dataset.tab === resolvedTab;
tab.setAttribute('aria-selected', String(isActive));
});

panels.forEach(panel => {
const isActive = panel.id === `panel-${tabName}`;
const isActive = panel.id === `panel-${resolvedTab}`;
panel.classList.toggle('is-active', isActive);
panel.hidden = !isActive;
});

try {
localStorage.setItem(tabStorageKey, resolvedTab);
} catch (error) {
// Ignore storage failures in private or restricted browsing modes.
}
}

function getStoredTab() {
try {
const storedTab = localStorage.getItem(tabStorageKey);
return validTabs.includes(storedTab) ? storedTab : 'overview';
} catch (error) {
return 'overview';
}
}

setActiveTab(getStoredTab());

document.querySelectorAll('.tab-button').forEach(button => {
button.addEventListener('click', () => setActiveTab(button.dataset.tab));
});
Expand All @@ -931,8 +952,10 @@ <h3 class="detail-card-title">${title}</h3>
const swapTotal = Number(sys.swap_total_gb ?? 0);
const botRam = Number(sys.bot_ram_gb ?? sys.process_rss_gb ?? 0);
const botLimit = Number(sys.bot_ram_limit_gb ?? 0);
const apiVersion = data.version ?? data.api_version ?? data.payload_version ?? null;

document.getElementById('api-version').innerText = data.version || 'Unknown';
document.getElementById('api-version').innerText = apiVersion || 'Not reported';
document.getElementById('api-version-note').innerText = apiVersion ? 'Payload version for this endpoint' : 'Version field not present in payload';
document.getElementById('bot-uptime').innerText = data.bot_uptime || 'Unknown';
document.getElementById('server-uptime').innerText = data.server_uptime || 'Unknown';
document.getElementById('platform').innerText = sys.platform || 'Linux x86_64';
Expand Down
Loading