2026-03-04 19:42:38 -06:00
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="en">
|
|
|
|
|
<head>
|
2026-03-04 22:58:00 -06:00
|
|
|
<meta charset="UTF-8">
|
2026-03-04 19:42:38 -06:00
|
|
|
<title>UniFi Access Attendance</title>
|
2026-03-04 22:58:00 -06:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
2026-03-04 19:42:38 -06:00
|
|
|
<style>
|
2026-03-04 22:58:00 -06:00
|
|
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
2026-03-04 19:42:38 -06:00
|
|
|
:root {
|
2026-03-04 22:58:00 -06:00
|
|
|
--bg: #050508; --bg-card: #111113; --gold: #d4af37; --gold-soft: #b89630;
|
|
|
|
|
--text: #f5f5f5; --muted: #888; --danger: #ff4d4f; --success: #2ecc71;
|
|
|
|
|
--warn: #f39c12; --border: #222;
|
2026-03-04 19:42:38 -06:00
|
|
|
}
|
|
|
|
|
body {
|
2026-03-04 22:58:00 -06:00
|
|
|
background: radial-gradient(circle at top, #18181c 0%, #050508 55%);
|
2026-03-04 19:42:38 -06:00
|
|
|
color: var(--text);
|
|
|
|
|
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
2026-03-04 22:58:00 -06:00
|
|
|
min-height: 100vh; display: flex; justify-content: center; padding: 32px 16px;
|
2026-03-04 19:42:38 -06:00
|
|
|
}
|
|
|
|
|
.app-shell {
|
2026-03-04 19:53:39 -06:00
|
|
|
width: 100%; max-width: 1280px;
|
2026-03-04 19:42:38 -06:00
|
|
|
background: rgba(5,5,8,0.96);
|
2026-03-04 22:58:00 -06:00
|
|
|
border-radius: 20px; border: 1px solid rgba(212,175,55,0.3);
|
2026-03-04 19:42:38 -06:00
|
|
|
box-shadow: 0 32px 80px rgba(0,0,0,0.7);
|
|
|
|
|
padding: 24px 24px 32px;
|
|
|
|
|
}
|
2026-03-04 22:58:00 -06:00
|
|
|
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 16px; }
|
2026-03-04 19:42:38 -06:00
|
|
|
.title-block { display: flex; flex-direction: column; gap: 4px; }
|
2026-03-04 19:53:39 -06:00
|
|
|
h1 { font-size: 1.6rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
|
2026-03-04 19:42:38 -06:00
|
|
|
.subtitle { font-size: 0.9rem; color: var(--muted); }
|
|
|
|
|
.badge {
|
2026-03-04 22:58:00 -06:00
|
|
|
border-radius: 999px; border: 1px solid rgba(212,175,55,0.5);
|
|
|
|
|
padding: 4px 10px; font-size: 0.75rem; text-transform: uppercase;
|
|
|
|
|
letter-spacing: 0.12em; color: var(--gold-soft);
|
|
|
|
|
background: linear-gradient(90deg, rgba(212,175,55,0.1), rgba(212,175,55,0.02));
|
2026-03-04 19:42:38 -06:00
|
|
|
}
|
2026-03-04 22:58:00 -06:00
|
|
|
.controls { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; align-items: center; }
|
2026-03-04 19:42:38 -06:00
|
|
|
.control-group { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
|
2026-03-04 19:53:39 -06:00
|
|
|
.spacer { flex: 1; }
|
2026-03-04 19:42:38 -06:00
|
|
|
label { font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
|
2026-03-04 19:53:39 -06:00
|
|
|
input {
|
2026-03-04 22:58:00 -06:00
|
|
|
background: var(--bg-card); border-radius: 999px; border: 1px solid var(--border);
|
|
|
|
|
padding: 8px 14px; font-size: 0.9rem; color: var(--text); outline: none; min-width: 130px;
|
2026-03-04 19:42:38 -06:00
|
|
|
}
|
2026-03-04 19:53:39 -06:00
|
|
|
input:focus { border-color: var(--gold-soft); box-shadow: 0 0 0 1px rgba(212,175,55,0.4); }
|
2026-03-04 19:42:38 -06:00
|
|
|
button {
|
2026-03-04 22:58:00 -06:00
|
|
|
border-radius: 999px; border: 1px solid rgba(212,175,55,0.7);
|
|
|
|
|
background: radial-gradient(circle at top, rgba(212,175,55,0.35), rgba(2,2,4,0.95));
|
|
|
|
|
color: var(--text); padding: 8px 18px; font-size: 0.85rem;
|
|
|
|
|
letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer;
|
|
|
|
|
transition: transform 0.08s, box-shadow 0.08s; white-space: nowrap;
|
2026-03-04 19:42:38 -06:00
|
|
|
}
|
|
|
|
|
button:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
|
2026-03-04 19:53:39 -06:00
|
|
|
button:active { transform: translateY(1px); box-shadow: none; }
|
|
|
|
|
button:disabled { opacity: 0.45; cursor: default; transform: none; }
|
2026-03-04 22:58:00 -06:00
|
|
|
.sync-btn { border-color: rgba(100,180,255,0.6); background: radial-gradient(circle at top, rgba(100,180,255,0.18), rgba(2,2,4,0.95)); }
|
|
|
|
|
.reset-btn { border-color: rgba(255,100,100,0.6); background: radial-gradient(circle at top, rgba(255,80,80,0.18), rgba(2,2,4,0.95)); }
|
|
|
|
|
.summary-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; font-size: 0.85rem; }
|
|
|
|
|
.summary-pill { display: inline-flex; align-items: center; gap: 8px; background: var(--bg-card); border-radius: 999px; padding: 6px 14px; border: 1px solid var(--border); color: var(--muted); }
|
2026-03-04 19:42:38 -06:00
|
|
|
.dot { width: 9px; height: 9px; border-radius: 50%; }
|
|
|
|
|
.dot.on { background: var(--success); box-shadow: 0 0 10px rgba(46,204,113,0.7); }
|
|
|
|
|
.dot.off { background: var(--danger); box-shadow: 0 0 10px rgba(255,77,79,0.7); }
|
|
|
|
|
.dot.all { background: var(--gold-soft); box-shadow: 0 0 10px rgba(184,150,48,0.5); }
|
|
|
|
|
.table-card {
|
2026-03-04 22:58:00 -06:00
|
|
|
background: linear-gradient(135deg, rgba(17,17,19,0.98), rgba(8,8,10,0.98));
|
|
|
|
|
border-radius: 14px; border: 1px solid rgba(255,255,255,0.04); overflow: hidden;
|
2026-03-04 19:42:38 -06:00
|
|
|
}
|
|
|
|
|
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
|
2026-03-04 22:58:00 -06:00
|
|
|
thead { background: radial-gradient(circle at top left, rgba(212,175,55,0.22), rgba(10,10,12,0.9)); }
|
|
|
|
|
th, td { padding: 10px 16px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.04); white-space: nowrap; }
|
2026-03-04 19:53:39 -06:00
|
|
|
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
|
2026-03-04 19:42:38 -06:00
|
|
|
tbody tr:last-child td { border-bottom: none; }
|
|
|
|
|
tbody tr:hover { background: rgba(212,175,55,0.04); }
|
2026-03-04 22:58:00 -06:00
|
|
|
.name-cell { font-weight: 500; color: var(--text); }
|
|
|
|
|
.muted-cell { color: var(--muted); font-size: 0.82rem; }
|
2026-03-04 19:42:38 -06:00
|
|
|
.align-center { text-align: center; }
|
2026-03-04 22:58:00 -06:00
|
|
|
.time-first { color: var(--text); font-weight: 500; }
|
2026-03-04 19:53:39 -06:00
|
|
|
.time-latest { color: var(--muted); font-size: 0.85rem; }
|
2026-03-04 22:58:00 -06:00
|
|
|
.same-badge { color: #555; font-size: 0.82rem; font-style: italic; }
|
2026-03-04 19:42:38 -06:00
|
|
|
.status-chip {
|
2026-03-04 19:53:39 -06:00
|
|
|
display: inline-flex; align-items: center; justify-content: center;
|
|
|
|
|
min-width: 88px; padding: 5px 12px; border-radius: 999px;
|
2026-03-04 22:58:00 -06:00
|
|
|
font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em;
|
2026-03-04 19:42:38 -06:00
|
|
|
}
|
2026-03-04 19:53:39 -06:00
|
|
|
.status-on { background: rgba(46,204,113,0.1); color: #c9f7dc; border: 1px solid rgba(46,204,113,0.65); box-shadow: 0 0 14px rgba(46,204,113,0.2); }
|
|
|
|
|
.status-off { background: rgba(255,77,79,0.1); color: #ffd6d7; border: 1px solid rgba(255,77,79,0.75); box-shadow: 0 0 14px rgba(255,77,79,0.2); }
|
|
|
|
|
.chip-dot { width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: currentColor; }
|
|
|
|
|
.empty-state { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 0.9rem; }
|
|
|
|
|
.empty-state span { color: var(--gold-soft); }
|
|
|
|
|
/* Modal */
|
2026-03-04 22:58:00 -06:00
|
|
|
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(4px); z-index: 100; align-items: center; justify-content: center; }
|
2026-03-04 19:53:39 -06:00
|
|
|
.modal-overlay.open { display: flex; }
|
2026-03-04 22:58:00 -06:00
|
|
|
.modal { background: var(--bg-card); border: 1px solid rgba(255,100,100,0.5); border-radius: 16px; padding: 28px 32px; max-width: 400px; width: 90%; text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,0.8); }
|
2026-03-04 19:53:39 -06:00
|
|
|
.modal h2 { color: var(--danger); font-size: 1.1rem; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.08em; }
|
2026-03-04 22:58:00 -06:00
|
|
|
.modal p { color: var(--muted); font-size: 0.9rem; margin-bottom: 22px; line-height: 1.6; }
|
2026-03-04 19:53:39 -06:00
|
|
|
.modal p strong { color: var(--text); }
|
|
|
|
|
.modal-actions { display: flex; gap: 12px; justify-content: center; }
|
2026-03-04 22:58:00 -06:00
|
|
|
.modal-cancel { border-color: rgba(255,255,255,0.15); background: rgba(255,255,255,0.05); }
|
2026-03-04 19:53:39 -06:00
|
|
|
.modal-confirm { border-color: rgba(255,100,100,0.6); background: rgba(255,80,80,0.18); }
|
|
|
|
|
/* Toast */
|
2026-03-04 19:42:38 -06:00
|
|
|
.toast {
|
2026-03-04 22:58:00 -06:00
|
|
|
position: fixed; bottom: 24px; right: 24px; background: var(--bg-card);
|
|
|
|
|
border: 1px solid rgba(212,175,55,0.5); border-radius: 12px; padding: 12px 18px;
|
|
|
|
|
font-size: 0.85rem; color: var(--gold); opacity: 0; transform: translateY(12px);
|
|
|
|
|
transition: opacity 0.25s, transform 0.25s; pointer-events: none; z-index: 200;
|
2026-03-04 19:42:38 -06:00
|
|
|
}
|
|
|
|
|
.toast.show { opacity: 1; transform: translateY(0); }
|
2026-03-04 19:53:39 -06:00
|
|
|
@media (max-width: 800px) {
|
2026-03-04 19:42:38 -06:00
|
|
|
header { flex-direction: column; align-items: flex-start; }
|
|
|
|
|
.controls { flex-direction: column; align-items: stretch; }
|
2026-03-04 19:53:39 -06:00
|
|
|
input, button { width: 100%; }
|
2026-03-04 19:42:38 -06:00
|
|
|
th:nth-child(4), td:nth-child(4) { display: none; }
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
2026-03-04 19:53:39 -06:00
|
|
|
<div class="app-shell">
|
|
|
|
|
<header>
|
|
|
|
|
<div class="title-block">
|
|
|
|
|
<h1>Building Access</h1>
|
2026-03-04 22:58:00 -06:00
|
|
|
<div class="subtitle">Daily badge-in attendance — powered by UniFi Access</div>
|
2026-03-04 19:53:39 -06:00
|
|
|
</div>
|
|
|
|
|
<div class="badge">LIVE ATTENDANCE DASHBOARD</div>
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
<section class="controls">
|
|
|
|
|
<div class="control-group">
|
|
|
|
|
<label for="date">Date</label>
|
2026-03-04 22:58:00 -06:00
|
|
|
<input type="date" id="date">
|
2026-03-04 19:53:39 -06:00
|
|
|
</div>
|
|
|
|
|
<div class="control-group">
|
|
|
|
|
<label for="cutoff">Badged in by</label>
|
2026-03-04 22:58:00 -06:00
|
|
|
<input type="time" id="cutoff" value="09:00">
|
2026-03-04 19:53:39 -06:00
|
|
|
</div>
|
|
|
|
|
<div class="spacer"></div>
|
|
|
|
|
<div class="control-group">
|
|
|
|
|
<button id="refresh-btn">↻ Refresh</button>
|
|
|
|
|
<button class="sync-btn" id="sync-btn">↻ Sync Users</button>
|
|
|
|
|
<button class="reset-btn" id="reset-btn">✕ Reset Day</button>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class="summary-row">
|
2026-03-04 22:58:00 -06:00
|
|
|
<div class="summary-pill"><div class="dot on"></div><span id="on-time-count">0</span> on time</div>
|
|
|
|
|
<div class="summary-pill"><div class="dot off"></div><span id="late-count">0</span> late</div>
|
|
|
|
|
<div class="summary-pill"><div class="dot all"></div><span id="total-count">0</span> total</div>
|
2026-03-04 19:53:39 -06:00
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class="table-card">
|
|
|
|
|
<table>
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>#</th>
|
|
|
|
|
<th>Name</th>
|
|
|
|
|
<th>First Badge In</th>
|
|
|
|
|
<th>Latest Badge In</th>
|
|
|
|
|
<th>Actor ID</th>
|
|
|
|
|
<th class="align-center">Status</th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody id="table-body">
|
|
|
|
|
<tr><td colspan="6" class="empty-state">No data yet. <span>Badge into a door</span> and press Refresh.</td></tr>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Reset confirmation modal -->
|
|
|
|
|
<div class="modal-overlay" id="reset-modal">
|
|
|
|
|
<div class="modal">
|
|
|
|
|
<h2>⚠ Reset Day</h2>
|
2026-03-04 22:58:00 -06:00
|
|
|
<p>This will permanently delete all badge-in records for <strong id="modal-date-label"></strong>.<br>Use this for testing only.</p>
|
2026-03-04 19:53:39 -06:00
|
|
|
<div class="modal-actions">
|
|
|
|
|
<button class="modal-cancel" id="modal-cancel">Cancel</button>
|
|
|
|
|
<button class="modal-confirm" id="modal-confirm">Yes, Reset</button>
|
|
|
|
|
</div>
|
2026-03-04 19:42:38 -06:00
|
|
|
</div>
|
2026-03-04 19:53:39 -06:00
|
|
|
</div>
|
2026-03-04 19:42:38 -06:00
|
|
|
|
2026-03-04 19:53:39 -06:00
|
|
|
<div class="toast" id="toast"></div>
|
2026-03-04 19:42:38 -06:00
|
|
|
|
2026-03-04 19:53:39 -06:00
|
|
|
<script>
|
|
|
|
|
function isoToday() {
|
|
|
|
|
return new Date().toISOString().slice(0, 10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showToast(msg, duration = 3000) {
|
|
|
|
|
const t = document.getElementById('toast');
|
|
|
|
|
t.textContent = msg;
|
|
|
|
|
t.classList.add('show');
|
|
|
|
|
clearTimeout(t._timer);
|
|
|
|
|
t._timer = setTimeout(() => t.classList.remove('show'), duration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function loadData() {
|
|
|
|
|
const date = document.getElementById('date').value || isoToday();
|
|
|
|
|
const cutoff = document.getElementById('cutoff').value || '09:00';
|
|
|
|
|
const params = new URLSearchParams({ date, cutoff });
|
|
|
|
|
|
2026-03-04 22:58:00 -06:00
|
|
|
let data;
|
2026-03-04 19:53:39 -06:00
|
|
|
try {
|
|
|
|
|
const res = await fetch('/api/first-badge-status?' + params.toString());
|
|
|
|
|
data = await res.json();
|
|
|
|
|
} catch {
|
2026-03-04 22:58:00 -06:00
|
|
|
showToast('Could not load data');
|
2026-03-04 19:53:39 -06:00
|
|
|
return;
|
2026-03-04 19:42:38 -06:00
|
|
|
}
|
|
|
|
|
|
2026-03-04 19:53:39 -06:00
|
|
|
const tbody = document.getElementById('table-body');
|
|
|
|
|
tbody.innerHTML = '';
|
|
|
|
|
|
|
|
|
|
if (!data.length) {
|
|
|
|
|
tbody.innerHTML = '<tr><td colspan="6" class="empty-state">No badge-in records for this day.</td></tr>';
|
|
|
|
|
['on-time-count','late-count','total-count'].forEach(id => {
|
2026-03-04 22:58:00 -06:00
|
|
|
document.getElementById(id).textContent = '0';
|
2026-03-04 19:53:39 -06:00
|
|
|
});
|
|
|
|
|
return;
|
2026-03-04 19:42:38 -06:00
|
|
|
}
|
|
|
|
|
|
2026-03-04 19:53:39 -06:00
|
|
|
let onTime = 0, late = 0;
|
|
|
|
|
|
|
|
|
|
data.forEach((row, i) => {
|
|
|
|
|
const tr = document.createElement('tr');
|
|
|
|
|
|
|
|
|
|
// # column
|
|
|
|
|
const numTd = document.createElement('td');
|
|
|
|
|
numTd.className = 'muted-cell';
|
|
|
|
|
numTd.textContent = i + 1;
|
|
|
|
|
tr.appendChild(numTd);
|
2026-03-04 19:42:38 -06:00
|
|
|
|
2026-03-04 22:58:00 -06:00
|
|
|
// Name — use row.name directly (server resolves Unknown fallback)
|
2026-03-04 19:53:39 -06:00
|
|
|
const nameTd = document.createElement('td');
|
|
|
|
|
nameTd.className = 'name-cell';
|
2026-03-04 22:58:00 -06:00
|
|
|
nameTd.textContent = row.name;
|
2026-03-04 19:53:39 -06:00
|
|
|
tr.appendChild(nameTd);
|
2026-03-04 19:42:38 -06:00
|
|
|
|
2026-03-04 22:58:00 -06:00
|
|
|
// First badge in
|
2026-03-04 19:53:39 -06:00
|
|
|
const firstTd = document.createElement('td');
|
|
|
|
|
firstTd.className = 'time-first';
|
2026-03-04 22:58:00 -06:00
|
|
|
firstTd.textContent = row.first_ts || '—';
|
2026-03-04 19:53:39 -06:00
|
|
|
tr.appendChild(firstTd);
|
|
|
|
|
|
2026-03-04 22:58:00 -06:00
|
|
|
// Latest badge in
|
2026-03-04 19:53:39 -06:00
|
|
|
const latestTd = document.createElement('td');
|
2026-03-04 22:58:00 -06:00
|
|
|
if (!row.latest_ts) {
|
2026-03-04 19:53:39 -06:00
|
|
|
latestTd.className = 'same-badge';
|
|
|
|
|
latestTd.textContent = '— same';
|
|
|
|
|
} else {
|
|
|
|
|
latestTd.className = 'time-latest';
|
2026-03-04 22:58:00 -06:00
|
|
|
latestTd.textContent = row.latest_ts;
|
2026-03-04 19:42:38 -06:00
|
|
|
}
|
2026-03-04 19:53:39 -06:00
|
|
|
tr.appendChild(latestTd);
|
2026-03-04 19:42:38 -06:00
|
|
|
|
2026-03-04 19:53:39 -06:00
|
|
|
// Actor ID (truncated)
|
|
|
|
|
const idTd = document.createElement('td');
|
|
|
|
|
idTd.className = 'muted-cell';
|
2026-03-04 22:58:00 -06:00
|
|
|
idTd.textContent = row.actor_id ? row.actor_id.slice(0, 8) + '...' : '—';
|
2026-03-04 19:53:39 -06:00
|
|
|
tr.appendChild(idTd);
|
2026-03-04 19:42:38 -06:00
|
|
|
|
2026-03-04 19:53:39 -06:00
|
|
|
// Status chip
|
|
|
|
|
const statusTd = document.createElement('td');
|
|
|
|
|
statusTd.className = 'align-center';
|
|
|
|
|
const chip = document.createElement('div');
|
2026-03-04 22:58:00 -06:00
|
|
|
const isOnTime = row.status === 'ON TIME';
|
|
|
|
|
chip.className = 'status-chip ' + (isOnTime ? 'status-on' : 'status-off');
|
|
|
|
|
chip.innerHTML = '<span class="chip-dot"></span>' + (isOnTime ? 'ON TIME' : 'LATE');
|
2026-03-04 19:53:39 -06:00
|
|
|
statusTd.appendChild(chip);
|
|
|
|
|
tr.appendChild(statusTd);
|
|
|
|
|
|
|
|
|
|
tbody.appendChild(tr);
|
2026-03-04 22:58:00 -06:00
|
|
|
|
|
|
|
|
isOnTime ? onTime++ : late++;
|
2026-03-04 19:53:39 -06:00
|
|
|
});
|
|
|
|
|
|
2026-03-04 22:58:00 -06:00
|
|
|
document.getElementById('on-time-count').textContent = onTime;
|
|
|
|
|
document.getElementById('late-count').textContent = late;
|
|
|
|
|
document.getElementById('total-count').textContent = onTime + late;
|
2026-03-04 19:53:39 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function syncUsers() {
|
|
|
|
|
const btn = document.getElementById('sync-btn');
|
2026-03-04 22:58:00 -06:00
|
|
|
btn.textContent = 'Syncing…';
|
|
|
|
|
btn.disabled = true;
|
2026-03-04 19:53:39 -06:00
|
|
|
try {
|
|
|
|
|
await fetch('/api/sync-users');
|
2026-03-04 22:58:00 -06:00
|
|
|
showToast('User list synced from UniFi Access');
|
2026-03-04 19:53:39 -06:00
|
|
|
await loadData();
|
|
|
|
|
} catch {
|
2026-03-04 22:58:00 -06:00
|
|
|
showToast('Sync failed — check server logs');
|
2026-03-04 19:53:39 -06:00
|
|
|
} finally {
|
2026-03-04 22:58:00 -06:00
|
|
|
btn.textContent = '⟳ Sync Users';
|
|
|
|
|
btn.disabled = false;
|
2026-03-04 19:42:38 -06:00
|
|
|
}
|
2026-03-04 19:53:39 -06:00
|
|
|
}
|
2026-03-04 19:42:38 -06:00
|
|
|
|
2026-03-04 22:58:00 -06:00
|
|
|
// Reset day modal
|
2026-03-04 19:53:39 -06:00
|
|
|
document.getElementById('reset-btn').addEventListener('click', () => {
|
|
|
|
|
const date = document.getElementById('date').value || isoToday();
|
|
|
|
|
document.getElementById('modal-date-label').textContent = date;
|
|
|
|
|
document.getElementById('reset-modal').classList.add('open');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
document.getElementById('modal-cancel').addEventListener('click', () => {
|
|
|
|
|
document.getElementById('reset-modal').classList.remove('open');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
document.getElementById('modal-confirm').addEventListener('click', async () => {
|
|
|
|
|
document.getElementById('reset-modal').classList.remove('open');
|
|
|
|
|
const date = document.getElementById('date').value || isoToday();
|
|
|
|
|
try {
|
|
|
|
|
const res = await fetch('/api/reset-day?date=' + date, { method: 'DELETE' });
|
|
|
|
|
const json = await res.json();
|
2026-03-04 22:58:00 -06:00
|
|
|
showToast(`Reset complete — ${json.deleted} record(s) deleted for ${date}`);
|
2026-03-04 19:53:39 -06:00
|
|
|
await loadData();
|
|
|
|
|
} catch {
|
2026-03-04 22:58:00 -06:00
|
|
|
showToast('Reset failed — check server logs');
|
2026-03-04 19:42:38 -06:00
|
|
|
}
|
2026-03-04 19:53:39 -06:00
|
|
|
});
|
2026-03-04 19:42:38 -06:00
|
|
|
|
2026-03-04 19:53:39 -06:00
|
|
|
document.getElementById('reset-modal').addEventListener('click', e => {
|
|
|
|
|
if (e.target === document.getElementById('reset-modal'))
|
|
|
|
|
document.getElementById('reset-modal').classList.remove('open');
|
|
|
|
|
});
|
2026-03-04 19:42:38 -06:00
|
|
|
|
2026-03-04 19:53:39 -06:00
|
|
|
document.getElementById('refresh-btn').addEventListener('click', loadData);
|
|
|
|
|
document.getElementById('sync-btn').addEventListener('click', syncUsers);
|
|
|
|
|
|
|
|
|
|
window.addEventListener('load', () => {
|
|
|
|
|
const dateInput = document.getElementById('date');
|
|
|
|
|
if (!dateInput.value) dateInput.value = isoToday();
|
|
|
|
|
loadData();
|
|
|
|
|
});
|
|
|
|
|
</script>
|
2026-03-04 19:42:38 -06:00
|
|
|
</body>
|
|
|
|
|
</html>
|