Compare commits

...
Author SHA1 Message Date
Hermes 5844bfed72 Add i18n language selector to dashboard frontend
CI / Test & Lint (push) Canceled after 0s
CI / Security audit (push) Canceled after 0s
- New i18n.js module: window.DCI18n.t(key), language dropdown selector
- Supports 5 languages (en, es, fr, de, ar) with RTL for Arabic
- Translations loaded from /api/v1/i18n/translations/:lang
- Language preference persisted in localStorage
- Added to features.js bundle
2026-08-12 18:53:59 -07:00
Hermes cf57093388 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
2026-08-12 18:51:46 -07:00
Hermes e7a7e1efa4 feat: add 16 new app templates (92 total)
Added: authelia, keycloak, vikunja, openproject, plane, hedgedoc, yacht,
openvpn, forgejo, gitlab, prometheus, netdata, kibana, openhab, bitwarden, subsonic

Authelia includes DashCaddy forward_auth integration metadata.
GitLab and Bitwarden include resourceWarning for minimum RAM.
Prometheus includes DashCaddy metrics endpoint as setup instruction.
All templates follow existing patterns (subpathSupport, healthCheck, setupInstructions).
2026-08-12 18:04:57 -07:00
Hermes 50391d692d fix: disk explosion prevention + auth leak fix + health endpoint routing
CI / Test & Lint (push) Canceled after 0s
CI / Security audit (push) Canceled after 0s
- health-checker.js: Strip response headers from history, cap at 500 entries per service, compact JSON save
- resource-monitor.js: Cap at 500 entries per container, compact JSON save
- middleware.js: Block sensitive API routes from external access when TOTP disabled
- Caddyfile: Add health probe routes (/healthz, /readyz, /csrf-token) before SPA fallback
- MCP bridge: Fix internal IP leak in .well-known/mcp.json

Found during comprehensive QA audit of test.dashcaddy.net.
2026-08-12 17:48:28 -07:00
13 changed files with 1030 additions and 256 deletions
+380 -1
View File
@@ -2541,7 +2541,386 @@ const APP_TEMPLATES = {
fix: "Check that uvicorn is binding 127.0.0.1:8765 (not 0.0.0.0). Use `ss -tlnp | grep 8765` to confirm."
}
]
}
},
"authelia": {
name: "Authelia",
description: "Single sign-on portal and authentication gateway for web apps",
icon: "\u{1F6E1}\u{FE0F}",
category: "Security",
popularity: 82,
difficulty: "Advanced",
docker: {
image: "authelia/authelia:latest",
ports: ["{{PORT}}:9091"],
volumes: ["/opt/authelia/config:/config"],
environment: {
"AUTHELIA_STORAGE": "local",
"AUTHELIA_STORAGE_LOCAL_PATH": "/config/db.sqlite3"
}
},
subdomain: "authelia",
defaultPort: 9091,
healthCheck: "/api/health",
subpathSupport: 'native',
setupInstructions: [
"Edit /opt/authelia/config/configuration.yml with your domain and settings",
"Configure users in /opt/authelia/config/users_database.yml",
"Set up Caddy forward_auth to protect your services behind Authelia",
"Configure 2FA (TOTP, WebAuthn) in the Authelia portal"
],
dashcaddyIntegration: {
ssoCompatible: true,
forwardAuth: true,
caddySnippet: "forward_auth authelia.<domain>:9091 { uri /api/verify?rd=https://authelia.<domain> copy_headers Remote-User Remote-Groups Remote-Name Remote-Email }"
}
},
"keycloak": {
name: "Keycloak",
description: "Open source identity and access management with SSO, OIDC, and SAML",
icon: "\u{1F511}",
category: "Security",
popularity: 85,
difficulty: "Advanced",
docker: {
image: "quay.io/keycloak/keycloak:latest",
ports: ["{{PORT}}:8080"],
volumes: ["/opt/keycloak/data:/opt/keycloak/data"],
environment: {
"KEYCLOAK_ADMIN": "admin",
"KEYCLOAK_ADMIN_PASSWORD": "{{GENERATED_SECRET}}",
"KC_DB": "dev-file",
"KC_HOSTNAME": "{{SUBDOMAIN}}.{{TLD}}"
},
command: ["start-dev"]
},
subdomain: "keycloak",
defaultPort: 8090,
healthCheck: "/health/ready",
subpathSupport: 'none',
setupInstructions: [
"Log in with admin / generated password",
"Create a realm for your applications",
"Configure OIDC clients for each app you want to protect",
"Set up identity providers (Google, GitHub, etc.) for social login"
],
secrets: [{
envVar: "GENERATED_SECRET",
label: "Keycloak Admin Password",
description: "Initial admin password",
type: "password",
required: true,
generate: "alphanumeric",
length: 32
}]
},
"vikunja": {
name: "Vikunja",
description: "Self-hosted to-do app with lists, kanban boards, and teams",
icon: "\u2705",
category: "Productivity",
popularity: 72,
difficulty: "Easy",
docker: {
image: "vikunja/vikunja:latest",
ports: ["{{PORT}}:3456"],
volumes: ["/opt/vikunja/files:/app/vikunja/files", "/opt/vikunja/db:/app/vikunja/database"],
environment: {
"VIKUNJA_SERVICE_JWTSECRET": "{{GENERATED_SECRET}}",
"VIKUNJA_SERVICE_FRONTENDURL": "https://{{SUBDOMAIN}}.{{TLD}}"
}
},
subdomain: "vikunja",
defaultPort: 3456,
healthCheck: "/api/v1/info",
subpathSupport: 'native',
setupInstructions: ["Register the first user account", "Create projects and tasks", "Set up teams for shared task management"],
secrets: [{
envVar: "GENERATED_SECRET",
label: "JWT Secret",
description: "Secret for signing auth tokens",
type: "password",
required: true,
generate: "alphanumeric",
length: 48
}]
},
"openproject": {
name: "OpenProject",
description: "Project management with Gantt charts, time tracking, and Scrum boards",
icon: "\u{1F4CB}",
category: "Productivity",
popularity: 75,
difficulty: "Intermediate",
docker: {
image: "openproject/openproject:latest",
ports: ["{{PORT}}:80"],
volumes: ["/opt/openproject/pgdata:/var/openproject/pgdata", "/opt/openproject/assets:/var/openproject/assets"],
environment: { "OPENPROJECT_HOST__NAME": "{{SUBDOMAIN}}.{{TLD}}", "OPENPROJECT_HTTPS": "true" }
},
subdomain: "projects",
defaultPort: 8091,
healthCheck: "/",
subpathSupport: 'none',
setupInstructions: ["Complete the initial setup wizard", "Create your first project", "Add team members and configure permissions"]
},
"plane": {
name: "Plane",
description: "Open-source Jira alternative with issues, cycles, and modules",
icon: "\u2708\uFE0F",
category: "Productivity",
popularity: 70,
difficulty: "Intermediate",
docker: {
image: "makeplane/plane-frontend:latest",
ports: ["{{PORT}}:3000"],
volumes: ["/opt/plane/data:/app/data"],
environment: { "NEXT_PUBLIC_API_BASE_URL": "https://{{SUBDOMAIN}}.{{TLD}}/api" }
},
subdomain: "plane",
defaultPort: 8092,
healthCheck: "/",
subpathSupport: 'none',
setupInstructions: ["Plane requires multiple containers - use the recipe for full stack deploy", "Create an organization and invite team members", "Set up cycles and modules for project tracking"]
},
"hedgedoc": {
name: "HedgeDoc",
description: "Collaborative markdown editor with real-time editing",
icon: "\u{1F4DD}",
category: "Productivity",
popularity: 68,
difficulty: "Easy",
docker: {
image: "quay.io/hedgedoc/hedgedoc:latest",
ports: ["{{PORT}}:3000"],
volumes: ["/opt/hedgedoc/uploads:/hedgedoc/public/uploads"],
environment: {
"CMD_DOMAIN": "{{SUBDOMAIN}}.{{TLD}}",
"CMD_URL_ADDPORT": "false",
"CMD_PROTOCOL_USESSL": "true",
"CMD_DB_URL": "sqlite:/hedgedoc/database.sqlite"
}
},
subdomain: "notes",
defaultPort: 8093,
healthCheck: "/status",
subpathSupport: 'native',
setupInstructions: ["Register an account or use guest mode", "Create collaborative markdown documents", "Share links for real-time co-editing"]
},
"yacht": {
name: "Yacht",
description: "Web-based Docker container manager with template support",
icon: "\u26F5",
category: "Management",
popularity: 65,
difficulty: "Easy",
docker: {
image: "selfhostedpro/yacht:latest",
ports: ["{{PORT}}:8000"],
volumes: ["/opt/yacht/config:/config", "/var/run/docker.sock:/var/run/docker.sock"],
environment: { "PUID": "1000", "PGID": "1000" }
},
subdomain: "yacht",
defaultPort: 8094,
healthCheck: "/",
subpathSupport: 'strip',
setupInstructions: ["Set up admin account on first launch", "Add compose templates for one-click deployments", "Manage containers through the web interface"]
},
"openvpn": {
name: "OpenVPN",
description: "Virtual private network server for secure remote access",
icon: "\u{1F512}",
category: "Security",
popularity: 78,
difficulty: "Intermediate",
docker: {
image: "kylemanna/openvpn:latest",
ports: ["{{PORT}}:1194/udp"],
volumes: ["/opt/openvpn:/etc/openvpn"],
environment: {},
cap_add: ["NET_ADMIN"]
},
subdomain: "openvpn",
defaultPort: 1194,
healthCheck: null,
subpathSupport: 'none',
setupInstructions: ["Initialize the PKI: docker exec openvpn ovpn_initpki", "Generate client certificates for each device", "Download client configs and import into OpenVPN client"]
},
"forgejo": {
name: "Forgejo",
description: "Self-hosted Git service - soft fork of Gitea with enhanced features",
icon: "\u{1F527}",
category: "Development",
popularity: 73,
difficulty: "Easy",
docker: {
image: "codeberg.org/forgejo/forgejo:latest",
ports: ["{{PORT}}:3000", "2222:22"],
volumes: ["/opt/forgejo/data:/data", "/etc/localtime:/etc/localtime:ro"],
environment: { "USER_UID": "1000", "USER_GID": "1000" }
},
subdomain: "forgejo",
defaultPort: 8095,
healthCheck: "/api/v1/version",
subpathSupport: 'native',
setupInstructions: ["Configure database on first run", "Create admin account and disable open registration", "Migrate repos from GitHub/GitLab via the built-in migration tool", "Set up Actions for CI/CD pipelines"]
},
"gitlab": {
name: "GitLab",
description: "Complete DevOps platform with Git, CI/CD, and project management",
icon: "\u{1F99A}",
category: "Development",
popularity: 88,
difficulty: "Advanced",
docker: {
image: "gitlab/gitlab-ce:latest",
ports: ["{{PORT}}:80", "8443:443", "2223:22"],
volumes: ["/opt/gitlab/config:/etc/gitlab", "/opt/gitlab/logs:/var/log/gitlab", "/opt/gitlab/data:/var/opt/gitlab"],
environment: { "GITLAB_OMNIBUS_CONFIG": "external_url https://{{SUBDOMAIN}}.{{TLD}}" },
shm_size: "256m"
},
subdomain: "gitlab",
defaultPort: 8096,
healthCheck: "/-/health",
subpathSupport: 'none',
setupInstructions: ["Requires at least 4GB RAM and 2 CPU cores", "Wait 5-10 minutes for first boot", "Set root password on first login", "Configure runners for CI/CD pipelines"],
resourceWarning: { minMemoryMB: 4096, minCpuCores: 2, message: "GitLab requires at least 4GB RAM. Deploying on a smaller server may cause instability." }
},
"prometheus": {
name: "Prometheus",
description: "Monitoring system with time-series database and alerting",
icon: "\u{1F525}",
category: "Monitoring",
popularity: 85,
difficulty: "Intermediate",
docker: {
image: "prom/prometheus:latest",
ports: ["{{PORT}}:9090"],
volumes: ["/opt/prometheus/data:/prometheus", "/opt/prometheus/config:/etc/prometheus"],
environment: {},
command: ["--config.file=/etc/prometheus/prometheus.yml", "--storage.tsdb.path=/prometheus", "--web.enable-lifecycle"]
},
subdomain: "prometheus",
defaultPort: 9090,
healthCheck: "/-/healthy",
subpathSupport: 'native',
setupInstructions: ["Edit /opt/prometheus/config/prometheus.yml to add scrape targets", "Add DashCaddy /api/v1/metrics/prometheus as a scrape target", "Pair with Grafana for dashboards", "Configure alert rules"]
},
"netdata": {
name: "Netdata",
description: "Real-time system metrics with zero configuration monitoring",
icon: "\u{1F4C8}",
category: "Monitoring",
popularity: 82,
difficulty: "Easy",
docker: {
image: "netdata/netdata:latest",
ports: ["{{PORT}}:19999"],
volumes: ["/opt/netdata/config:/etc/netdata", "/opt/netdata/lib:/var/lib/netdata", "/opt/netdata/cache:/var/cache/netdata", "/proc:/host/proc:ro", "/sys:/host/sys:ro", "/etc/os-release:/host/etc/os-release:ro"],
environment: { "NETDATA_CLAIM_URL": "https://app.netdata.cloud" },
cap_add: ["SYS_PTRACE"],
security_opt: ["apparmor:unconfined"]
},
subdomain: "netdata",
defaultPort: 19999,
healthCheck: "/api/v1/info",
subpathSupport: 'native',
setupInstructions: ["Dashboard is immediately available with zero configuration", "Monitor CPU, RAM, disk, network, Docker in real-time", "Configure alarms for resource thresholds", "Optional: claim to Netdata Cloud for centralized monitoring"]
},
"kibana": {
name: "Kibana",
description: "Visualization dashboard for Elasticsearch data analytics",
icon: "\u{1F4C9}",
category: "Monitoring",
popularity: 70,
difficulty: "Advanced",
docker: {
image: "kibana:8.12.0",
ports: ["{{PORT}}:5601"],
volumes: ["/opt/kibana/config:/usr/share/kibana/config"],
environment: { "ELASTICSEARCH_HOSTS": "http://elasticsearch:9200" }
},
subdomain: "kibana",
defaultPort: 5601,
healthCheck: "/api/status",
subpathSupport: 'native',
setupInstructions: ["Requires an Elasticsearch instance running first", "Consider deploying via the ELK Stack recipe", "Create index patterns for your data", "Build dashboards and visualizations"]
},
"openhab": {
name: "OpenHAB",
description: "Open source home automation platform with broad device support",
icon: "\u2699\uFE0F",
category: "Home Automation",
popularity: 72,
difficulty: "Intermediate",
docker: {
image: "openhab/openhab:latest",
ports: ["{{PORT}}:8080", "8444:8443"],
volumes: ["/opt/openhab/conf:/openhab/conf", "/opt/openhab/userdata:/openhab/userdata", "/opt/openhab/addons:/openhab/addons", "/etc/localtime:/etc/localtime:ro"],
environment: { "OPENHAB_HTTP_PORT": "8080", "OPENHAB_HTTPS_PORT": "8443", "EXTRA_JAVA_OPTS": "-Duser.timezone={{TIMEZONE}}" }
},
subdomain: "openhab",
defaultPort: 8097,
healthCheck: "/start/index",
subpathSupport: 'none',
setupInstructions: ["Choose your preferred package (Standard, Demo, or Minimal)", "Install bindings for your smart home devices", "Create items, sitemaps, and rules", "Access the Paper UI for configuration"]
},
"bitwarden": {
name: "Bitwarden",
description: "Official Bitwarden password manager server (unified self-hosted)",
icon: "\u{1F510}",
category: "Security",
popularity: 80,
difficulty: "Advanced",
docker: {
image: "bitwarden/self-host:latest",
ports: ["{{PORT}}:8080"],
volumes: ["/opt/bitwarden/data:/etc/bitwarden"],
environment: { "BW_DOMAIN": "{{SUBDOMAIN}}.{{TLD}}" }
},
subdomain: "bitwarden",
defaultPort: 8098,
healthCheck: "/health",
subpathSupport: 'none',
setupInstructions: ["Complete the Bitwarden unified installation", "Generate installation ID and key at bitwarden.com/host", "Configure SMTP for email verification", "Note: Vaultwarden is recommended for smaller deployments"],
resourceWarning: { minMemoryMB: 2048, message: "Official Bitwarden requires 2GB+ RAM. For lightweight deployments, use Vaultwarden instead." }
},
"subsonic": {
name: "Subsonic",
description: "Web-based media streamer for music with wide client support",
icon: "\u{1F3B5}",
category: "Media",
popularity: 60,
difficulty: "Easy",
docker: {
image: "linuxserver/subsonic:latest",
ports: ["{{PORT}}:4040"],
volumes: ["/opt/subsonic/config:/config", "/opt/subsonic/music:/music", "/opt/subsonic/podcasts:/podcasts", "/opt/subsonic/playlists:/playlists"],
environment: { "PUID": "1000", "PGID": "1000", "TZ": "{{TIMEZONE}}" }
},
subdomain: "subsonic",
defaultPort: 4040,
healthCheck: "/",
subpathSupport: 'native',
setupInstructions: ["Set admin password on first launch", "Add music folders in Settings", "Install Subsonic-compatible apps on your devices", "Note: Airsonic Advanced is also available as a fully open-source alternative"],
mediaMount: { required: true, containerPath: "/music", label: "Music Library", description: "Folder containing your music files", defaultPath: "/media/music" }
},
};
// Template categories for organization
@@ -19,6 +19,7 @@ const STATS_HOURLY_FILE = process.env.STATS_HOURLY_FILE || path.join(platformPat
const STATS_DAILY_FILE = process.env.STATS_DAILY_FILE || path.join(platformPaths.dataDir, 'container-stats-daily.json');
const ALERT_CONFIG_FILE = process.env.ALERT_CONFIG_FILE || path.join(platformPaths.dataDir, 'alert-config.json');
const ALERT_HISTORY_FILE = process.env.ALERT_HISTORY_FILE || path.join(platformPaths.dataDir, 'alert-history.json');
const MAX_STATS_PER_CONTAINER = parseInt(process.env.STATS_MAX_ENTRIES || '500', 10); // Cap to prevent disk explosion
const STATS_RETENTION_HOURS = parseInt(process.env.STATS_RETENTION_HOURS || '168', 10); // 7 days raw
const STATS_HOURLY_RETENTION_DAYS = parseInt(process.env.STATS_HOURLY_RETENTION_DAYS || '30', 10); // 30 days hourly
const STATS_DAILY_RETENTION_DAYS = parseInt(process.env.STATS_DAILY_RETENTION_DAYS || '365', 10); // 365 days daily
@@ -242,6 +243,11 @@ class ResourceMonitor extends EventEmitter {
containerStats.history = containerStats.history.filter(s =>
new Date(s.timestamp).getTime() > cutoffTime
);
// Also cap total entries per container (disk explosion fix)
if (containerStats.history.length > MAX_STATS_PER_CONTAINER) {
containerStats.history = containerStats.history.slice(-MAX_STATS_PER_CONTAINER);
}
}
/**
@@ -620,7 +626,7 @@ class ResourceMonitor extends EventEmitter {
saveStats() {
try {
const data = Object.fromEntries(this.stats);
fs.writeFileSync(STATS_FILE, JSON.stringify(data, null, 2));
fs.writeFileSync(STATS_FILE, JSON.stringify(data)); // Compact JSON to reduce file size
} catch (error) {
log.error('monitor', error, { operation: 'saveStats' });
}
+12 -2
View File
@@ -30,6 +30,7 @@ const LEGACY_HEALTH_CONFIG_FILE = path.join(__dirname, 'health-config.json');
const LEGACY_HEALTH_HISTORY_FILE = path.join(__dirname, 'health-history.json');
const CHECK_INTERVAL = parseInt(process.env.HEALTH_CHECK_INTERVAL || '30000', 10); // 30 seconds
const MAX_CHECK_INTERVAL = parseInt(process.env.HEALTH_CHECK_MAX_INTERVAL || '300000', 10); // 5 minutes max backoff
const MAX_ENTRIES_PER_SERVICE = parseInt(process.env.HEALTH_MAX_ENTRIES || '500', 10); // Cap to prevent disk explosion
const HISTORY_RETENTION_DAYS = parseInt(process.env.HEALTH_HISTORY_RETENTION || '30', 10);
class HealthChecker extends EventEmitter {
@@ -217,7 +218,7 @@ class HealthChecker extends EventEmitter {
statusCode: res.statusCode,
message: healthy ? 'Service is healthy' : 'Service check failed',
details: {
headers: res.headers,
headers: res.headers ? { server: res.headers.server } : undefined, // Compact: disk explosion fix
bodyLength: data.length
}
});
@@ -285,6 +286,11 @@ class HealthChecker extends EventEmitter {
}
this.history[serviceId].push(status);
// Cap entries to prevent unbounded growth (disk explosion fix)
if (this.history[serviceId].length > MAX_ENTRIES_PER_SERVICE) {
this.history[serviceId] = this.history[serviceId].slice(-MAX_ENTRIES_PER_SERVICE);
}
// Emit status event
this.emit('status-check', status);
@@ -565,6 +571,10 @@ class HealthChecker extends EventEmitter {
this.history[serviceId] = this.history[serviceId].filter(h =>
new Date(h.timestamp).getTime() > cutoffTime
);
// Also cap total entries per service
if (this.history[serviceId].length > MAX_ENTRIES_PER_SERVICE) {
this.history[serviceId] = this.history[serviceId].slice(-MAX_ENTRIES_PER_SERVICE);
}
}
}
@@ -616,7 +626,7 @@ class HealthChecker extends EventEmitter {
*/
saveHistory() {
try {
fs.writeFileSync(HEALTH_HISTORY_FILE, JSON.stringify(this.history, null, 2));
fs.writeFileSync(HEALTH_HISTORY_FILE, JSON.stringify(this.history)); // Compact JSON (no pretty-print) to reduce file size
} catch (error) {
this.emit('log', 'error', `Error saving history: ${error.message}`);
}
+1
View File
@@ -77,6 +77,7 @@ const bundles = {
// window.wireModal + window.injectModal + window.escapeHtml helpers
// defined in globals.js (already in core.js).
JS('share-modal.js'),
JS('i18n.js'),
],
'onboarding.js': [
JS('driver.min.js'),
+1
View File
File diff suppressed because one or more lines are too long
+293 -251
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) {
+207
View File
@@ -0,0 +1,207 @@
/**
* DC-077: i18n Frontend — Language selector and translation system
*
* Provides window.DCI18n.t(key) for the dashboard frontend.
* Loads translations from /api/v1/i18n/translations/:lang
* Language preference stored in localStorage.
* Handles RTL for Arabic.
*/
(function () {
'use strict';
const STORAGE_KEY = 'dashcaddy-language';
const DEFAULT_LANG = 'en';
const SUPPORTED_LANGS = ['en', 'es', 'fr', 'de', 'ar'];
const LANG_NAMES = {
en: 'English', es: 'Español', fr: 'Français', de: 'Deutsch', ar: 'العربية',
};
let currentLang = localStorage.getItem(STORAGE_KEY) || DEFAULT_LANG;
let translations = {};
let loaded = false;
async function loadTranslations(lang) {
if (lang === DEFAULT_LANG) {
translations = {}; // English is the default — no translation needed
loaded = true;
return;
}
try {
const res = await fetch(`/api/v1/i18n/translations/${lang}`);
if (res.ok) {
const data = await res.json();
translations = data.translations || {};
loaded = true;
}
} catch (e) {
console.warn('[i18n] Failed to load translations for', lang, e);
}
}
function t(key) {
if (currentLang === DEFAULT_LANG) return key;
return translations[key] || key;
}
function setLanguage(lang) {
if (!SUPPORTED_LANGS.includes(lang)) return;
currentLang = lang;
localStorage.setItem(STORAGE_KEY, lang);
// RTL handling
const isRtl = lang === 'ar';
document.documentElement.dir = isRtl ? 'rtl' : 'ltr';
document.documentElement.lang = lang;
loadTranslations(lang).then(() => {
applyTranslations();
});
}
function getLanguage() {
return currentLang;
}
function applyTranslations() {
// Apply translations to elements with data-i18n attributes
document.querySelectorAll('[data-i18n]').forEach(el => {
const key = el.getAttribute('data-i18n');
const translated = t(key);
if (translated && translated !== key) {
el.textContent = translated;
}
});
// Apply to placeholders
document.querySelectorAll('[data-i18n-placeholder]').forEach(el => {
const key = el.getAttribute('data-i18n-placeholder');
const translated = t(key);
if (translated && translated !== key) {
el.placeholder = translated;
}
});
// Apply to titles
document.querySelectorAll('[data-i18n-title]').forEach(el => {
const key = el.getAttribute('data-i18n-title');
const translated = t(key);
if (translated && translated !== key) {
el.title = translated;
}
});
}
function createLanguageSelector() {
// Find the top bar area to insert the selector
// Look for the auth-settings area or the header actions
const targetContainer = document.querySelector('.header-actions') ||
document.querySelector('#auth-settings-btn')?.parentElement ||
document.querySelector('.top-bar-actions');
if (!targetContainer) {
// If we can't find a target, try to add it near the settings button
const settingsBtn = document.getElementById('auth-settings-btn');
if (settingsBtn && settingsBtn.parentElement) {
return createDropdown(settingsBtn.parentElement);
}
return null;
}
return createDropdown(targetContainer);
}
function createDropdown(container) {
// Check if selector already exists
if (document.getElementById('dc-lang-selector')) return;
const wrapper = document.createElement('div');
wrapper.id = 'dc-lang-selector';
wrapper.style.cssText = 'display: inline-flex; align-items: center; gap: 4px; margin: 0 8px; position: relative;';
const btn = document.createElement('button');
btn.id = 'dc-lang-btn';
btn.className = 'lang-selector-btn';
btn.style.cssText = 'background: var(--card-base, #2a2a3e); border: 1px solid var(--border, #3a3a4e); color: var(--text-primary, #e0e0e0); padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 0.8rem; display: flex; align-items: center; gap: 4px;';
btn.innerHTML = `🌐 <span class="lang-current">${currentLang.toUpperCase()}</span>`;
btn.title = 'Language / Idioma / Langue / Sprache / اللغة';
const dropdown = document.createElement('div');
dropdown.id = 'dc-lang-dropdown';
dropdown.style.cssText = 'display: none; position: absolute; top: 100%; right: 0; margin-top: 4px; background: var(--card-base, #2a2a3e); border: 1px solid var(--border, #3a3a4e); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); z-index: 9999; min-width: 140px; overflow: hidden;';
SUPPORTED_LANGS.forEach(lang => {
const item = document.createElement('div');
item.className = 'lang-option';
item.style.cssText = 'padding: 8px 14px; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-primary, #e0e0e0);';
item.onmouseenter = () => item.style.background = 'var(--card-hover, rgba(255,255,255,0.05))';
item.onmouseleave = () => item.style.background = 'transparent';
const flag = document.createElement('span');
flag.textContent = lang === currentLang ? '✓' : '';
flag.style.cssText = 'width: 16px; color: var(--ok-fg, #4ade80);';
const name = document.createElement('span');
name.textContent = LANG_NAMES[lang];
item.appendChild(flag);
item.appendChild(name);
item.onclick = () => {
setLanguage(lang);
dropdown.style.display = 'none';
// Update button text
btn.querySelector('.lang-current').textContent = lang.toUpperCase();
// Update checkmarks
dropdown.querySelectorAll('.lang-option').forEach((opt, i) => {
opt.querySelector('span').textContent = SUPPORTED_LANGS[i] === lang ? '✓' : '';
});
// Show notification
if (window.showNotification) {
window.showNotification(`Language: ${LANG_NAMES[lang]}`, 'info');
}
};
dropdown.appendChild(item);
});
btn.onclick = (e) => {
e.stopPropagation();
dropdown.style.display = dropdown.style.display === 'none' ? 'block' : 'none';
};
// Close on outside click
document.addEventListener('click', (e) => {
if (!wrapper.contains(e.target)) {
dropdown.style.display = 'none';
}
});
wrapper.appendChild(btn);
wrapper.appendChild(dropdown);
container.insertBefore(wrapper, container.firstChild);
return wrapper;
}
// Initialize on page load
function init() {
// Set initial RTL if needed
if (currentLang === 'ar') {
document.documentElement.dir = 'rtl';
document.documentElement.lang = 'ar';
}
// Create the language selector after DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => {
createLanguageSelector();
if (currentLang !== DEFAULT_LANG) loadTranslations(currentLang).then(applyTranslations);
});
} else {
createLanguageSelector();
if (currentLang !== DEFAULT_LANG) loadTranslations(currentLang).then(applyTranslations);
}
}
// Expose globally
window.DCI18n = { t, setLanguage, getLanguage, applyTranslations, loadTranslations };
// Auto-init
init();
})();
+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-c775f8444e';
const PRECACHE = [
'/',
'/index.html',