feat: add stats polling interval + correct health polling default to Settings
CI / Test & Lint (push) Canceled after 0s
CI / Security audit (push) Canceled after 0s

- Add 'Stats Polling Interval' (default 30s) field to Health -> Configure ->
  Global Settings, alongside the existing 'Polling Interval' which is now
  relabeled 'Health Check Polling Interval' with the correct default of 60s.
- Persist/load statsPollingInterval via the health-settings localStorage key
  (same mechanism as the other settings).
- Wire the persisted statsPollingInterval into DC.POLL.STATS so the resource
  monitor / monitoring widgets honor the configured cadence (seconds -> ms).
- Update the setup wizard disk-safety 'Recommended after setup' list to
  mention both polling intervals.
- Rebuild dist bundles (core.js, features.js) and bump service-worker cache.
This commit is contained in:
Hermes
2026-08-13 11:03:57 -07:00
parent 234df5038c
commit 7f97ff4a7f
6 changed files with 272 additions and 239 deletions
+38 -38
View File
File diff suppressed because one or more lines are too long
+195 -190
View File
File diff suppressed because one or more lines are too long
+2
View File
@@ -705,6 +705,8 @@
<strong style="font-size: 0.9rem;">📋 Recommended after setup</strong>
<ul style="margin: 8px 0 0; padding-left: 20px; font-size: 0.85rem; color: var(--muted); line-height: 1.6;">
<li>Open <strong>Health → Configure → Global Settings</strong></li>
<li>Set a <strong>health check polling interval</strong> (default: 60s)</li>
<li>Set a <strong>stats polling interval</strong> (default: 30s)</li>
<li>Set a <strong>data retention period</strong> (default: 30 days)</li>
<li>Cap <strong>max entries per service</strong> (default: 500)</li>
<li>Set a <strong>disk-usage warning threshold</strong> (default: 80%)</li>
+19 -1
View File
@@ -1,10 +1,28 @@
// ===== DASHBOARD CONSTANTS =====
// Honor persisted health retention settings for polling cadences so the
// Settings → Health → Global Settings panel actually takes effect. The
// STATS interval (resource/container stat sampling) is driven from the
// user-configurable statsPollingInterval. HEALTH is the lightweight card
// badge refresh and stays at its fast default unless overridden.
(function applyHealthPollingSettings() {
try {
var raw = (typeof localStorage !== 'undefined' && localStorage.getItem('dashcaddy-health-settings')) || null;
if (raw) {
var s = JSON.parse(raw);
// values are stored in seconds; DC.POLL expects milliseconds
if (s.statsPollingInterval && s.statsPollingInterval >= 5 && s.statsPollingInterval <= 3600) {
window.__DC_STATS_OVERRIDE = s.statsPollingInterval * 1000;
}
}
} catch (_) { /* ignore — fall back to defaults below */ }
})();
const DC = {
NAME: 'DashCaddy',
POLL: {
DASHBOARD: 10000, // 10s — main refreshAll interval
LOGS: 3000, // 3s — log viewer updates
STATS: 5000, // 5s — resource monitor refresh
STATS: (typeof window !== 'undefined' && window.__DC_STATS_OVERRIDE) || 5000, // 5s default — resource monitor refresh (overridable via Settings → Health)
WEATHER: 600000, // 10m — weather widget refresh
HEALTH: 1000, // 1s — card health badge refresh
DEPLOY_SSL: 5000, // 5s — SSL cert check during deploy
+17 -9
View File
@@ -34,26 +34,31 @@
<div class="panel-empty"><span class="empty-icon">⚙️</span> Loading configuration...</div>
</div>
<!-- Global Settings: retention, polling interval, disk-usage threshold -->
<!-- Global Settings: retention, polling intervals, max entries, disk-usage threshold -->
<div id="health-global-settings" style="margin-top: 16px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card-base);">
<h4 style="margin: 0 0 4px;">🌍 Global Settings</h4>
<p class="text-muted-sm" style="margin: 0 0 12px;">Applies to all health checks. Settings are stored locally in this browser.</p>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 12px;">
<div>
<label class="text-muted-sm">Data Retention (days)</label>
<input type="number" id="health-setting-retention" value="30" min="1" max="3650" class="form-input" />
<div style="font-size: 0.72rem; color: var(--muted); margin-top: 2px;">Health history older than this is pruned.</div>
<label class="text-muted-sm">Health Check Polling Interval (seconds)</label>
<input type="number" id="health-setting-interval" value="60" min="5" max="3600" class="form-input" />
<div style="font-size: 0.72rem; color: var(--muted); margin-top: 2px;">How often each service's health endpoint is checked.</div>
</div>
<div>
<label class="text-muted-sm">Polling Interval (seconds)</label>
<input type="number" id="health-setting-interval" value="30" min="5" max="3600" class="form-input" />
<div style="font-size: 0.72rem; color: var(--muted); margin-top: 2px;">How often each service is checked.</div>
<label class="text-muted-sm">Stats Polling Interval (seconds)</label>
<input type="number" id="health-setting-stats-interval" value="30" min="5" max="3600" class="form-input" />
<div style="font-size: 0.72rem; color: var(--muted); margin-top: 2px;">How often container statistics (CPU/memory) are sampled.</div>
</div>
<div>
<label class="text-muted-sm">Max Entries Per Service</label>
<input type="number" id="health-setting-max-entries" value="500" min="10" max="100000" class="form-input" />
<div style="font-size: 0.72rem; color: var(--muted); margin-top: 2px;">Cap on stored history records per service.</div>
</div>
<div>
<label class="text-muted-sm">Data Retention (days)</label>
<input type="number" id="health-setting-retention" value="30" min="1" max="3650" class="form-input" />
<div style="font-size: 0.72rem; color: var(--muted); margin-top: 2px;">Health history older than this is pruned.</div>
</div>
<div>
<label class="text-muted-sm">Disk-Usage Warning (%)</label>
<input type="number" id="health-setting-disk-threshold" value="80" min="50" max="99" class="form-input" />
@@ -136,14 +141,15 @@
const formCancel = document.getElementById('health-form-cancel');
const formSave = document.getElementById('health-form-save');
// ---- Global health settings (retention, polling interval, disk threshold) ----
// ---- Global health settings (retention, polling intervals, max entries, disk threshold) ----
const HEALTH_SETTINGS_KEY = 'dashcaddy-health-settings';
const HEALTH_DEFAULTS = { retentionDays: 30, pollingInterval: 30, maxEntriesPerService: 500, diskUsageThreshold: 80 };
const HEALTH_DEFAULTS = { retentionDays: 30, pollingInterval: 60, statsPollingInterval: 30, maxEntriesPerService: 500, diskUsageThreshold: 80 };
const globalSaveBtn = document.getElementById('health-global-save');
const globalResetBtn = document.getElementById('health-global-reset');
const globalStatusSpan = document.getElementById('health-global-status');
const retentionInput = document.getElementById('health-setting-retention');
const intervalInput = document.getElementById('health-setting-interval');
const statsIntervalInput = document.getElementById('health-setting-stats-interval');
const maxEntriesInput = document.getElementById('health-setting-max-entries');
const diskThresholdInput = document.getElementById('health-setting-disk-threshold');
@@ -161,6 +167,7 @@
const s = loadHealthSettings();
if (retentionInput) retentionInput.value = s.retentionDays;
if (intervalInput) intervalInput.value = s.pollingInterval;
if (statsIntervalInput) statsIntervalInput.value = s.statsPollingInterval;
if (maxEntriesInput) maxEntriesInput.value = s.maxEntriesPerService;
if (diskThresholdInput) diskThresholdInput.value = s.diskUsageThreshold;
}
@@ -169,6 +176,7 @@
const settings = {
retentionDays: Math.max(1, Math.min(3650, parseInt(retentionInput?.value) || HEALTH_DEFAULTS.retentionDays)),
pollingInterval: Math.max(5, Math.min(3600, parseInt(intervalInput?.value) || HEALTH_DEFAULTS.pollingInterval)),
statsPollingInterval: Math.max(5, Math.min(3600, parseInt(statsIntervalInput?.value) || HEALTH_DEFAULTS.statsPollingInterval)),
maxEntriesPerService: Math.max(10, Math.min(100000, parseInt(maxEntriesInput?.value) || HEALTH_DEFAULTS.maxEntriesPerService)),
diskUsageThreshold: Math.max(50, Math.min(99, parseInt(diskThresholdInput?.value) || HEALTH_DEFAULTS.diskUsageThreshold))
};
+1 -1
View File
@@ -1,4 +1,4 @@
const CACHE = 'dashcaddy-shell-d17fb082db';
const CACHE = 'dashcaddy-shell-f0ebe6ce4f';
const PRECACHE = [
'/',
'/index.html',