Add disk-usage warnings and global health-check settings

- Setup wizard summary step: add disk-safety info box warning about
  health-check data accumulation and pointing to retention settings
- Setup wizard showSummary(): add dynamic disk-space tip with defaults
- Health Configure tab: add Global Settings section with data retention
  (default 30 days), polling interval (default 30s), and disk-usage
  warning threshold (default 80%), persisted to localStorage
- Rebuild dist bundles
This commit is contained in:
Hermes
2026-08-12 18:51:46 -07:00
parent e7a7e1efa4
commit cf57093388
8 changed files with 425 additions and 254 deletions
+1
View File
File diff suppressed because one or more lines are too long
+295 -253
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+17
View File
@@ -652,6 +652,23 @@
<!-- Will be filled dynamically -->
</div>
<!-- Disk safety info: health checks accumulate data over time -->
<div style="margin-top: 16px; padding: 14px 16px; background: color-mix(in srgb, var(--warn-fg, #f39c12) 10%, transparent); border-radius: 8px; border: 1px solid var(--warn-fg, #f39c12);">
<div style="display: flex; gap: 10px; align-items: flex-start;">
<span style="font-size: 1.2rem; line-height: 1;">💾</span>
<div>
<strong style="color: var(--warn-fg, #f39c12);">Disk Usage &amp; Health-Check Data</strong>
<div style="font-size: 0.85rem; margin-top: 4px; color: var(--muted); line-height: 1.45;">
DashCaddy's health checks log response times, uptime history, and incidents for every monitored service.
Over time this data accumulates and can consume significant disk space — especially on small VPS or
SD-card installs. After setup, open <strong>Health → Configure → Global Settings</strong> to set a
<strong>data retention period</strong> (default 30 days), adjust the <strong>polling interval</strong>,
and configure a <strong>disk-usage warning threshold</strong> so you're alerted before storage runs low.
</div>
</div>
</div>
</div>
<div style="margin-top: 24px; padding: 16px; background: color-mix(in srgb, var(--ok-fg) 10%, transparent); border-radius: 8px; border: 1px solid var(--ok-fg);">
<strong style="color: var(--ok-fg);">✓ You can change these settings later</strong>
<div style="font-size: 0.85rem; margin-top: 4px; color: var(--muted);">
+93
View File
@@ -34,6 +34,34 @@
<div class="panel-empty"><span class="empty-icon">⚙️</span> Loading configuration...</div>
</div>
<!-- Global Settings: retention, polling interval, 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 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>
</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>
</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" />
<div style="font-size: 0.72rem; color: var(--muted); margin-top: 2px;">Warn when disk usage exceeds this level.</div>
</div>
</div>
<div style="margin-top: 12px; display: flex; gap: 8px; align-items: center;">
<button id="health-global-save" class="btn-accent-solid">Save Global Settings</button>
<button id="health-global-reset" class="btn-sm">Reset to Defaults</button>
<span id="health-global-status" style="font-size: 0.8rem; color: var(--muted);"></span>
</div>
</div>
<!-- Add/Edit Health Check Form -->
<div id="health-config-form" style="display: none; margin-top: 16px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card-base);">
<h4 id="health-form-title" style="margin: 0 0 12px;">Add Health Check</h4>
@@ -103,6 +131,71 @@
const formCancel = document.getElementById('health-form-cancel');
const formSave = document.getElementById('health-form-save');
// ---- Global health settings (retention, polling interval, disk threshold) ----
const HEALTH_SETTINGS_KEY = 'dashcaddy-health-settings';
const HEALTH_DEFAULTS = { retentionDays: 30, pollingInterval: 30, 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 diskThresholdInput = document.getElementById('health-setting-disk-threshold');
function loadHealthSettings() {
try {
const raw = safeGet(HEALTH_SETTINGS_KEY);
const saved = raw ? JSON.parse(raw) : {};
return Object.assign({}, HEALTH_DEFAULTS, saved);
} catch (_) {
return Object.assign({}, HEALTH_DEFAULTS);
}
}
function applyHealthSettingsToUI() {
const s = loadHealthSettings();
if (retentionInput) retentionInput.value = s.retentionDays;
if (intervalInput) intervalInput.value = s.pollingInterval;
if (diskThresholdInput) diskThresholdInput.value = s.diskUsageThreshold;
}
function saveHealthSettings() {
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)),
diskUsageThreshold: Math.max(50, Math.min(99, parseInt(diskThresholdInput?.value) || HEALTH_DEFAULTS.diskUsageThreshold))
};
try {
safeSet(HEALTH_SETTINGS_KEY, JSON.stringify(settings));
applyHealthSettingsToUI();
if (globalStatusSpan) {
globalStatusSpan.textContent = 'Saved ✓';
globalStatusSpan.style.color = 'var(--ok-fg)';
setTimeout(() => { if (globalStatusSpan) globalStatusSpan.textContent = ''; }, 2500);
}
if (typeof showNotification === 'function') showNotification('Global health settings saved', 'success');
} catch (e) {
if (globalStatusSpan) { globalStatusSpan.textContent = 'Save failed'; globalStatusSpan.style.color = 'var(--bad-fg)'; }
if (typeof showNotification === 'function') showNotification('Failed to save settings: ' + e.message, 'error');
}
}
function resetHealthSettings() {
try {
safeSet(HEALTH_SETTINGS_KEY, JSON.stringify(HEALTH_DEFAULTS));
} catch (_) { /* ignore */ }
applyHealthSettingsToUI();
if (globalStatusSpan) {
globalStatusSpan.textContent = 'Reset to defaults ✓';
globalStatusSpan.style.color = 'var(--ok-fg)';
setTimeout(() => { if (globalStatusSpan) globalStatusSpan.textContent = ''; }, 2500);
}
}
applyHealthSettingsToUI();
globalSaveBtn?.addEventListener('click', saveHealthSettings);
globalResetBtn?.addEventListener('click', resetHealthSettings);
// ---- End global health settings ----
let editingId = null;
function uptimeColor(pct) {
+16
View File
@@ -135,6 +135,22 @@ window.populateTimezoneSelect = function(selectEl, selectedTz) {
</div>
`;
// Disk-safety reminder (universal across all config types)
html += `
<div style="margin-top: 12px; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--warn-fg, #f39c12); background: color-mix(in srgb, var(--warn-fg, #f39c12) 8%, transparent);">
<div style="display: flex; gap: 8px; align-items: flex-start;">
<span style="font-size: 1.1rem;">💾</span>
<div style="font-size: 0.85rem; line-height: 1.45;">
<strong style="color: var(--warn-fg, #f39c12);">Disk-space tip:</strong>
Health-check monitoring records uptime, response-time, and incident data continuously.
By default DashCaddy keeps <strong>30 days</strong> of history and warns at <strong>80% disk usage</strong>.
You can tune the retention period, polling interval, and disk threshold later under
<strong>Health → Configure → Global Settings</strong>.
</div>
</div>
</div>
`;
html += '</div>';
summaryContent.innerHTML = html;
showStep('setup-step-summary');
+1 -1
View File
@@ -1,4 +1,4 @@
const CACHE = 'dashcaddy-shell-c4c69c2c4c';
const CACHE = 'dashcaddy-shell-d655ab9676';
const PRECACHE = [
'/',
'/index.html',