diff --git a/public/views/cards/inbox.js b/public/views/cards/inbox.js new file mode 100644 index 0000000..e1ebfd7 --- /dev/null +++ b/public/views/cards/inbox.js @@ -0,0 +1,25 @@ +// public/views/cards/inbox.js +import { el, mount } from '../../dom.js'; +import { api } from '../../api.js'; + +let body, timer; +async function load() { + if (!body) return; + try { + const rows = await api.get('/api/pending-changes'); + mount(body, + el('div', { class: 'sv-row', style: { fontSize: '22px' } }, + el('span', { style: { fontFamily: 'var(--font-mono)' } }, String(rows.length)), + el('span', { class: 'k' }, 'awaiting review')), + el('a', { href: '#/inbox', class: 'k', style: { display: 'block', marginTop: '8px' } }, 'Open Inbox →') + ); + } catch (e) { + mount(body, el('span', { class: 'muted' }, e.status === 403 ? 'Owner only' : 'Inbox unavailable')); + } +} +export default { + id: 'inbox', title: 'Inbox', size: 's', + mount(el_) { body = el_; load(); }, + start() { timer = setInterval(load, 10000); }, + stop() { clearInterval(timer); body = null; } +}; diff --git a/public/views/sacred_valley.js b/public/views/sacred_valley.js index 7876cb9..358f2aa 100644 --- a/public/views/sacred_valley.js +++ b/public/views/sacred_valley.js @@ -7,8 +7,9 @@ import clock from './cards/clock.js'; import weather from './cards/weather.js'; import hostPerf from './cards/host_perf.js'; import jobs from './cards/jobs.js'; +import inbox from './cards/inbox.js'; -const CARD_MODULES = [clock, weather, hostPerf, jobs]; // grows in later tasks +const CARD_MODULES = [clock, weather, hostPerf, jobs, inbox]; // grows in later tasks let active = []; // mounted cards needing stop() export async function render(main) {