feat: premium tier features — auto-backup scheduling, resource alerting, bundled workflows, one-click revert, notification manager

This commit is contained in:
Hermes
2026-05-27 23:39:46 -07:00
parent 6ce0a18f98
commit 11823a1466
19 changed files with 3686 additions and 407 deletions
+59 -1
View File
@@ -168,6 +168,9 @@
<label class="checkbox-label-sm">
<input type="checkbox" id="event-deploy-failed" checked /> Deployment Failed
</label>
<label class="checkbox-label-sm" style="grid-column: 1 / -1;">
<input type="checkbox" id="event-resource-alert" checked /> Resource Alerts
</label>
</div>
<!-- History -->
@@ -175,9 +178,11 @@
<div id="notification-history" style="max-height: 150px; overflow-y: auto; padding: 8px; background: var(--card-base); border-radius: 8px; border: 1px solid var(--border); font-size: 0.8rem;">
<div style="color: var(--muted); text-align: center; padding: 20px;">No notifications yet</div>
</div>
<div id="last-notification-sent" style="font-size: 0.75rem; color: var(--muted); text-align: center; margin-top: 6px;"></div>
<!-- Buttons -->
<div class="weather-modal-buttons modal-footer-bar">
<button id="notifications-send-test" class="btn-secondary" style="margin-right: auto;">Send Test</button>
<button id="notifications-cancel">Cancel</button>
<button id="notifications-save" class="btn-accent">Save Settings</button>
</div>
@@ -254,6 +259,7 @@
document.getElementById('event-container-up').checked = config.events?.containerUp !== false;
document.getElementById('event-deploy-success').checked = config.events?.deploymentSuccess !== false;
document.getElementById('event-deploy-failed').checked = config.events?.deploymentFailed !== false;
document.getElementById('event-resource-alert').checked = config.events?.resourceAlert !== false;
}
} catch (error) {
errorHandler.logError('[Notifications] Load Config', error, { function: 'loadConfig' });
@@ -329,7 +335,8 @@
containerDown: document.getElementById('event-container-down').checked,
containerUp: document.getElementById('event-container-up').checked,
deploymentSuccess: document.getElementById('event-deploy-success').checked,
deploymentFailed: document.getElementById('event-deploy-failed').checked
deploymentFailed: document.getElementById('event-deploy-failed').checked,
resourceAlert: document.getElementById('event-resource-alert').checked
},
healthCheck: {
enabled: document.getElementById('health-check-enabled').checked,
@@ -404,5 +411,56 @@
});
saveBtn?.addEventListener('click', saveNotificationConfig);
// Send Test button - sends test notification to all enabled providers
document.getElementById('notifications-send-test')?.addEventListener('click', async () => {
const btn = document.getElementById('notifications-send-test');
const originalText = btn.textContent;
btn.textContent = 'Sending...';
btn.disabled = true;
try {
const response = await secureFetch('/api/v1/notifications/send', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
event: 'test',
data: { message: 'This is a test notification from DashCaddy.' },
type: 'info'
})
});
const data = await response.json();
if (data.success) {
showNotification('Test notification sent!', 'success', 3000);
// Update last sent timestamp
loadNotificationStatus();
} else {
showNotification(`Test failed: ${data.results?.map(r => `${r.provider}: ${r.error || 'ok'}`).join(', ')}`, 'error', 5000);
}
} catch (error) {
showNotification(`Error: ${error.message}`, 'error', 3000);
} finally {
btn.textContent = originalText;
btn.disabled = false;
}
});
// Load notification status (last sent timestamp)
async function loadNotificationStatus() {
try {
const response = await fetch('/api/v1/notifications/status');
const data = await response.json();
if (data.success && data.lastSent) {
const lastSentEl = document.getElementById('last-notification-sent');
if (lastSentEl) {
lastSentEl.textContent = `Last sent: ${new Date(data.lastSent).toLocaleString()}`;
}
}
} catch (error) {
// Silently fail - status is not critical
}
}
wireModal(modal, cancelBtn);
})();