feat(card): inbox
This commit is contained in:
25
public/views/cards/inbox.js
Normal file
25
public/views/cards/inbox.js
Normal file
@@ -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; }
|
||||||
|
};
|
||||||
@@ -7,8 +7,9 @@ import clock from './cards/clock.js';
|
|||||||
import weather from './cards/weather.js';
|
import weather from './cards/weather.js';
|
||||||
import hostPerf from './cards/host_perf.js';
|
import hostPerf from './cards/host_perf.js';
|
||||||
import jobs from './cards/jobs.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()
|
let active = []; // mounted cards needing stop()
|
||||||
|
|
||||||
export async function render(main) {
|
export async function render(main) {
|
||||||
|
|||||||
Reference in New Issue
Block a user