@@ -599,17 +596,8 @@ function buildBoardHtml(rows: ProjectRow[], updatedAt: string, todos: TodoRow[] el.textContent = ts ? '(' + timeAgo(ts) + ')' : ''; }); - // Countdown + auto-refresh - var secs = 60; - var cdEl = document.getElementById('countdown'); - setInterval(function() { - secs--; - if (secs <= 0) { location.reload(); return; } - if (cdEl) { - cdEl.textContent = secs + 's'; - cdEl.className = 'countdown' + (secs <= 10 ? ' warn' : ''); - } - }, 1000); + // Auto-refresh + setInterval(function() { location.reload(); }, 60000); // TODO CRUD (only active when token is writable) var TOKEN = '${rawToken}'; diff --git a/relay/test/relay.test.ts b/relay/test/relay.test.ts index 61ccf90..da4f1c8 100644 --- a/relay/test/relay.test.ts +++ b/relay/test/relay.test.ts @@ -462,7 +462,7 @@ describe('Tend Relay', () => { expect(html).not.toContain(`data-ts="${oldTs}"`); }); - it('auto-refresh countdown script is present', async () => { + it('auto-refresh script is present', async () => { const token = await registerToken(); const request = new Request(`http://localhost/${token}`, { method: 'GET' }); const ctx = createExecutionContext(); @@ -470,7 +470,6 @@ describe('Tend Relay', () => { await waitOnExecutionContext(ctx); const html = await response.text(); expect(html).toContain('location.reload'); - expect(html).toContain('countdown'); }); it('isolates boards between tokens', async () => { diff --git a/src/commands/dashboard.ts b/src/commands/dashboard.ts index 003fc53..290ffaf 100644 --- a/src/commands/dashboard.ts +++ b/src/commands/dashboard.ts @@ -9,20 +9,14 @@ function formatTime(d: Date): string { return `${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`; } -function countdown(secs: number): string { - if (secs <= 0) return 'refreshing…'; - if (secs < 60) return `${secs}s`; - return `${Math.floor(secs / 60)}m ${secs % 60}s`; -} - /** Strip ANSI escape codes to measure visible width. */ function visibleLen(s: string): number { return s.replace(/\x1b\[[^m]*m/g, '').length; } -function renderHeaderLines(lastUpdated: string, secsLeft: number): string { +function renderHeaderLines(lastUpdated: string): string { const w = process.stdout.columns || 80; - const left = ` ${C.bold}tend${C.reset} dashboard · updated ${lastUpdated} · next refresh in ${countdown(secsLeft)}`; + const left = ` ${C.bold}tend${C.reset} dashboard · updated ${lastUpdated}`; const right = ` q to quit `; const pad = Math.max(0, w - visibleLen(left) - right.length); const line1 = left + ' '.repeat(pad) + right; @@ -70,7 +64,7 @@ export async function cmdDashboard(): Promise { /** Overwrite just the top two header lines without touching the board body. */ function updateHeader(): void { const w = process.stdout.columns || 80; - const statusLine = renderHeaderLines(lastUpdated, secsLeft).split('\n')[0]; + const statusLine = renderHeaderLines(lastUpdated).split('\n')[0]; const divider = '─'.repeat(w); // Move to row 1, clear it, write status; move to row 2, clear it, write divider process.stdout.write(`${ESC}[1;1H${ESC}[2K${statusLine}\n${ESC}[2K${divider}`); @@ -79,7 +73,7 @@ export async function cmdDashboard(): Promise { /** Full screen redraw: clear, write header, then board content. */ function fullDraw(): void { process.stdout.write(`${ESC}[2J${ESC}[H`); - process.stdout.write(renderHeaderLines(lastUpdated, secsLeft) + '\n'); + process.stdout.write(renderHeaderLines(lastUpdated) + '\n'); process.stdout.write(boardContent); } diff --git a/www/app/components.jsx b/www/app/components.jsx index 87ffdb8..29c62fb 100644 --- a/www/app/components.jsx +++ b/www/app/components.jsx @@ -143,18 +143,6 @@ export function ArrowRightIconExport() { } export function DashboardLive() { - const [tick, setTick] = useState(0) - const REFRESH_SECS = 60 - const REFRESH_WARNING_THRESHOLD = 10 - - useEffect(() => { - const interval = setInterval(() => setTick(t => t + 1), 1000) - return () => clearInterval(interval) - }, []) - - const secsLeft = Math.max(0, REFRESH_SECS - (tick % REFRESH_SECS)) - const countdown = secsLeft < REFRESH_SECS ? `${secsLeft}s` : '1m 0s' - const rows = [ { icon: '?', name: 'atlas-api', state: 'stuck', msg: 'needs database credentials for staging', right: '', stateColor: 'text-ember' }, { icon: '\u25d0', name: 'northstar', state: 'working', msg: 'refactoring auth middleware', right: '(8m)', stateColor: 'text-patina' }, @@ -181,8 +169,7 @@ export function DashboardLive() {
tend - {' '}dashboard \u00b7 updated {timeStr} \u00b7 next refresh in{' '} - {countdown} + {' '}dashboard \u00b7 updated {timeStr} q to quit