From e179709fc353e76d52aaddde7e89b660a2306db7 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Fri, 20 Mar 2026 11:16:18 -0400 Subject: [PATCH] Add lt.autoRefresh, fix showToast in admin, clean up inline styles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace all 8 showToast() calls in ApiKeysView.php with lt.toast.* — all toast calls in the codebase now use lt.toast directly - Add .duplicate-list, .duplicate-meta, .duplicate-hint CSS classes to dashboard.css; replace inline styles in duplicate detection JS with them - Add dashboardAutoRefresh() using lt.autoRefresh — reloads page every 5 minutes, skipping if a modal is open or user is typing in an input - Add REFRESH button to dashboard header that triggers lt.autoRefresh.now() for immediate manual refresh with timer restart Co-Authored-By: Claude Sonnet 4.6 --- assets/css/dashboard.css | 26 ++++++++++++++++++++++++++ assets/js/dashboard.js | 24 ++++++++++++++++++++++++ views/CreateTicketView.php | 10 +++++----- views/DashboardView.php | 5 +++++ views/admin/ApiKeysView.php | 16 ++++++++-------- 5 files changed, 68 insertions(+), 13 deletions(-) diff --git a/assets/css/dashboard.css b/assets/css/dashboard.css index 739d0d9..b9981bd 100644 --- a/assets/css/dashboard.css +++ b/assets/css/dashboard.css @@ -4642,6 +4642,32 @@ table td:nth-child(4) { border-top: 1px solid var(--terminal-green); } +/* ===== DUPLICATE DETECTION LIST ===== */ + +.duplicate-list { + margin: 0; + padding-left: 1.5rem; + color: var(--terminal-green); +} + +.duplicate-list li { + margin-bottom: 0.5rem; +} + +.duplicate-list a { + color: var(--terminal-green); +} + +.duplicate-meta { + color: var(--terminal-amber); +} + +.duplicate-hint { + margin-top: 0.5rem; + font-size: 0.85rem; + color: var(--terminal-green-dim); +} + /* ===== INLINE ALERT BOXES ===== */ .inline-error { diff --git a/assets/js/dashboard.js b/assets/js/dashboard.js index 1ad290e..a7acea3 100644 --- a/assets/js/dashboard.js +++ b/assets/js/dashboard.js @@ -1819,6 +1819,30 @@ function hideLoadingOverlay(element) { } } +// ======================================== +// AUTO-REFRESH (lt.autoRefresh integration) +// ======================================== + +/** + * Reload the dashboard, but skip if a modal is open or user is typing. + * Registered with lt.autoRefresh so it runs every 5 minutes automatically. + */ +function dashboardAutoRefresh() { + // Don't interrupt the user if a modal is open + if (document.querySelector('.lt-modal-overlay[aria-hidden="false"]')) return; + // Don't interrupt if focus is in a text input + const tag = document.activeElement?.tagName; + if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') return; + window.location.reload(); +} + +document.addEventListener('DOMContentLoaded', function() { + // Only run auto-refresh on the dashboard, not on ticket pages + if (!window.location.pathname.includes('/ticket/')) { + lt.autoRefresh.start(dashboardAutoRefresh, 5 * 60 * 1000); + } +}); + // ======================================== // RELATIVE TIMESTAMPS // ======================================== diff --git a/views/CreateTicketView.php b/views/CreateTicketView.php index d0cf543..3387256 100644 --- a/views/CreateTicketView.php +++ b/views/CreateTicketView.php @@ -295,18 +295,18 @@ $nonce = SecurityHeadersMiddleware::getNonce(); const listDiv = document.getElementById('duplicatesList'); if (data.success && data.duplicates && data.duplicates.length > 0) { - let html = '