diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-12 15:56:07 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:16 -0300 |
| commit | d4dfee52a67d2e2b9a52f7e7b18b3b3cc185fac4 (patch) | |
| tree | 3c1737d474bcebedb0783655ff74e7d850c06258 /web/static/catalog.js | |
| parent | fd7775b4e9c24b6bb8f664beb7d4fd2ccecd8d85 (diff) | |
| download | cloud9-d4dfee52a67d2e2b9a52f7e7b18b3b3cc185fac4.tar.gz cloud9-d4dfee52a67d2e2b9a52f7e7b18b3b3cc185fac4.zip | |
9web: integrate sites and services into the file browser views
Replace the standalone dark dashboard with Files, Sites and Services navigation in the existing application shell. Reuse the shared stylesheet, tables and controls; open site files and logs in the normal file browser and send build commands through the existing HTTP-to-9P mapping.
Support direct tab URLs, browser history, preserved unsaved edits and focused controls, and pause catalogue polling in hidden views. Keep catalogue tabs hidden for ordinary upstream gateways. Remove the standalone page, script and log dialog.
Document the integrated views and add a real Chromium regression suite with desktop/mobile screenshots. Validation: catalogue and HTTP filesystem suites, integrated UI suite, and all 32 original browser E2E scenarios.
Diffstat (limited to 'web/static/catalog.js')
| -rw-r--r-- | web/static/catalog.js | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/web/static/catalog.js b/web/static/catalog.js deleted file mode 100644 index f868a16..0000000 --- a/web/static/catalog.js +++ /dev/null @@ -1,56 +0,0 @@ -const $ = id => document.getElementById(id); -let activeLog = null; -const element = (tag, text) => { const e = document.createElement(tag); e.textContent = text; return e; }; -function url(address, port, protocol = 'http') { - let host = address; - if (!host || host === '0.0.0.0' || host === '::') host = location.hostname; - host = host.replace(/^\[|\]$/g, ''); - return `${protocol}://${host.includes(':') ? `[${host}]` : host}:${port}/`; -} -async function control(name, command) { - try { - const r = await fetch(`/_cloud9/sites/${encodeURIComponent(name)}/ctl`, { method:'POST', headers:{'Content-Type':'text/plain'}, body:command }); - if (!r.ok) throw new Error(await r.text()); - $('message').textContent = `${name}: ${command} requested`; - await refresh(); - } catch (e) { $('message').textContent = e.message; } -} -function button(text, action, disabled = false) { const b = element('button', text); b.disabled = disabled; b.onclick = action; return b; } -function listenerRow(item) { - const tr = element('tr', ''); - const name = element('td', ''); - if (item.protocol !== 'unknown') { - const a = element('a', item.service); a.href = url(item.address, item.port, item.protocol); name.append(a); - } else name.textContent = item.process || 'Unknown'; - tr.append(name, element('td', `${item.address}:${item.port}${item.local ? ' · local only' : ''}`)); - const process = element('td', item.pid ? `PID ${item.pid}` : 'Unavailable'); process.className = 'process'; tr.append(process, element('td', item.evidence)); - return tr; -} -async function refresh() { - try { - const r = await fetch('/_cloud9/catalog.json'); if (!r.ok) throw new Error(`Dashboard: ${r.status}`); - const data = await r.json(); - $('sites').replaceChildren(); - for (const site of data.sites) { - const card = element('article', ''); const h = element('h2', ''); const a = element('a', site.title); a.href = url('', site.port); h.append(a); - const s = site.status; - card.append(h, element('code', site.root), element('p', `${s.phase}${s.watching ? ' · watch on' : ''}${s.queued ? ' · build queued' : ''}${s.exit_code !== null ? ` · exit ${s.exit_code}` : ''}`)); - if (s.finished) card.append(element('small', `Last finished ${new Date(s.finished * 1000).toLocaleString()}`), element('br', '')); - card.append(button('Build', () => control(site.name, 'build'), !site.build), button(s.watching ? 'Stop watching' : 'Watch', () => control(site.name, s.watching ? 'watch off' : 'watch on'), !site.watch), button('Cancel', () => control(site.name, 'cancel'), !s.pid && !s.queued), button('Log', () => { activeLog = site.name; $('log-title').textContent = site.title; $('logs').showModal(); refreshLog(); })); - $('sites').append(card); - } - const known = data.listeners.filter(x => x.protocol !== 'unknown'); - const unknown = data.listeners.filter(x => x.protocol === 'unknown'); - $('services').replaceChildren(...known.map(listenerRow)); - $('unknown').replaceChildren(...unknown.map(listenerRow)); - $('unknown-title').textContent = `Other listeners (${unknown.length})`; - if (data.discovery_error) $('message').textContent = data.discovery_error; - } catch (e) { $('message').textContent = e.message; } -} -async function refreshLog() { - if (!activeLog) return; - try { const r = await fetch(`/fs/sites/${encodeURIComponent(activeLog)}/log`); $('log-text').textContent = await r.text(); } catch (e) { $('log-text').textContent = e.message; } -} -$('close-log').onclick = () => { activeLog = null; $('logs').close(); }; -$('logs').onclose = () => { activeLog = null; }; -refresh(); setInterval(refresh, 5000); setInterval(refreshLog, 1500); |
