diff --git a/public/router.js b/public/router.js index 48492af..4737314 100644 --- a/public/router.js +++ b/public/router.js @@ -10,6 +10,8 @@ // #/sacred-valley dashboard placeholder // #/sentinel Yerin security view // #/little-blue Little Blue caretaker view +// #/timelapse Timelapse iframe embed +// #/ai-usage AI Usage iframe embed // Anything unrecognized falls through to the home handler. const ROUTES = [ diff --git a/public/views/embed.js b/public/views/embed.js index 921270d..c700719 100644 --- a/public/views/embed.js +++ b/public/views/embed.js @@ -6,16 +6,15 @@ import { el, mount } from '../dom.js'; export function embedView({ title, sub, src, allow }) { return async function render(main) { + const frame = el('iframe', { src, class: 'term-frame', title, ...(allow ? { allow } : {}) }); mount(main, el('div', { class: 'term-bar' }, el('span', { class: 'term-title' }, '◆ ' + title), sub ? el('span', { class: 'muted', style: { fontSize: '11px' } }, sub) : null, el('a', { class: 'ghost', style: { marginLeft: 'auto' }, href: src, target: '_blank', rel: 'noopener' }, '↗ Open'), - el('button', { class: 'ghost', onclick: () => { - const f = document.getElementById('embed-frame'); if (f) f.src = f.src; - } }, '⟳ Reload') + el('button', { class: 'ghost', onclick: () => { frame.src = frame.src; } }, '⟳ Reload') ), - el('iframe', { id: 'embed-frame', src, class: 'term-frame', ...(allow ? { allow } : {}) }) + frame ); }; } diff --git a/tests/frontend/embed.test.js b/tests/frontend/embed.test.js index 43df36f..0c4f07a 100644 --- a/tests/frontend/embed.test.js +++ b/tests/frontend/embed.test.js @@ -31,4 +31,11 @@ describe('embedView + wrappers', () => { await (await import('../../public/views/aiusage.js')).render(main); expect(main.querySelector('iframe.term-frame').getAttribute('src')).toBe('https://aiusage.hynesy.com/'); }); + + it('omits the allow attribute when not provided', async () => { + const { embedView } = await import('../../public/views/embed.js'); + const main = document.getElementById('main'); + await embedView({ title: 'AI Usage', src: 'https://aiusage.hynesy.com/' })(main); + expect(main.querySelector('iframe.term-frame').hasAttribute('allow')).toBe(false); + }); });