Compare commits
28 Commits
ec60d53767
...
v1.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 120b61a423 | |||
| 074f0600af | |||
| e4f9407827 | |||
| fde5ce7dc1 | |||
| 20df10b333 | |||
| c906511bfc | |||
| 745e5920ad | |||
| 90e0a98914 | |||
| cba4b73798 | |||
| 0d567472a9 | |||
| 9f6b2ece52 | |||
| e3911157e9 | |||
| 0589288dfe | |||
| 8ead7687e5 | |||
| 0e1e9b6699 | |||
| 3c008c5bce | |||
| 1582c28b28 | |||
| bcd934f5b1 | |||
| 4c9acd20c7 | |||
| 520fb98d96 | |||
| 800184d2be | |||
| 82c314f85c | |||
| 2fba532ec7 | |||
| 9177578aaf | |||
| 94c4a0af51 | |||
| cd16b7ea28 | |||
| afbdefa549 | |||
| f1e192c5d4 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,4 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
js/version.js
|
|
||||||
data/*.db
|
data/*.db
|
||||||
data/*.db-shm
|
data/*.db-shm
|
||||||
data/*.db-wal
|
data/*.db-wal
|
||||||
|
|||||||
54
css/app.css
54
css/app.css
@@ -25,6 +25,10 @@
|
|||||||
--mono: 'JetBrains Mono', 'IBM Plex Mono', monospace;
|
--mono: 'JetBrains Mono', 'IBM Plex Mono', monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
zoom: 1.1;
|
||||||
|
}
|
||||||
|
|
||||||
html, body {
|
html, body {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: var(--bg);
|
background: var(--bg);
|
||||||
@@ -374,16 +378,25 @@ select:focus { border-color: var(--accent); }
|
|||||||
}
|
}
|
||||||
|
|
||||||
.detail-sub {
|
.detail-sub {
|
||||||
font-size: 12px;
|
font-size: 13px;
|
||||||
color: var(--text3);
|
margin-top: 8px;
|
||||||
margin-top: 6px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 16px;
|
align-items: center;
|
||||||
|
gap: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail-sub span { display: flex; gap: 4px; }
|
.detail-sub > span {
|
||||||
.detail-sub .lbl { color: var(--text3); }
|
display: flex;
|
||||||
.detail-sub .val { color: var(--text2); }
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
.detail-sub > span + span {
|
||||||
|
margin-left: 12px;
|
||||||
|
padding-left: 12px;
|
||||||
|
border-left: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
.detail-sub .lbl { color: var(--text3); font-size: 11px; }
|
||||||
|
.detail-sub .val { color: var(--text); }
|
||||||
|
|
||||||
.detail-actions { display: flex; gap: 8px; }
|
.detail-actions { display: flex; gap: 8px; }
|
||||||
|
|
||||||
@@ -630,26 +643,25 @@ select:focus { border-color: var(--accent); }
|
|||||||
|
|
||||||
/* ── HISTORY TIMELINE ── */
|
/* ── HISTORY TIMELINE ── */
|
||||||
.tl-item {
|
.tl-item {
|
||||||
display: grid;
|
display: flex;
|
||||||
grid-template-columns: 160px 140px 1fr;
|
align-items: center;
|
||||||
gap: 0 12px;
|
justify-content: space-between;
|
||||||
padding: 7px 0;
|
gap: 24px;
|
||||||
|
padding: 9px 0;
|
||||||
border-bottom: 1px solid var(--border);
|
border-bottom: 1px solid var(--border);
|
||||||
font-size: 12px;
|
|
||||||
align-items: baseline;
|
|
||||||
}
|
}
|
||||||
.tl-item:last-child { border-bottom: none; }
|
.tl-item:last-child { border-bottom: none; }
|
||||||
.tl-time { color: var(--text3); font-size: 11px; white-space: nowrap; }
|
.tl-event { display: flex; align-items: center; gap: 7px; font-size: 13px; min-width: 0; }
|
||||||
.tl-field { color: var(--text2); }
|
.tl-label { color: var(--text2); }
|
||||||
.tl-change { display: flex; align-items: baseline; gap: 6px; }
|
.tl-sep { color: var(--text3); user-select: none; }
|
||||||
.tl-old { color: var(--text3); text-decoration: line-through; }
|
.tl-old { color: var(--text3); text-decoration: line-through; font-size: 12px; }
|
||||||
.tl-arrow { color: var(--text3); }
|
.tl-arrow { color: var(--text3); font-size: 11px; }
|
||||||
.tl-new { color: var(--text); }
|
.tl-new { color: var(--text); font-weight: 500; }
|
||||||
|
.tl-time { color: var(--text3); font-size: 11px; white-space: nowrap; flex-shrink: 0; }
|
||||||
.tl-deployed { color: var(--accent); }
|
.tl-deployed { color: var(--accent); }
|
||||||
.tl-testing { color: var(--amber); }
|
.tl-testing { color: var(--amber); }
|
||||||
.tl-degraded { color: var(--red); }
|
.tl-degraded { color: var(--red); }
|
||||||
.tl-created .tl-field { color: var(--accent); }
|
.tl-created .tl-event { color: var(--accent); font-weight: 500; }
|
||||||
.tl-created .tl-change { color: var(--text3); }
|
|
||||||
.tl-empty { color: var(--text3); font-size: 12px; padding: 8px 0; }
|
.tl-empty { color: var(--text3); font-size: 12px; padding: 8px 0; }
|
||||||
|
|
||||||
/* ── SETTINGS MODAL ── */
|
/* ── SETTINGS MODAL ── */
|
||||||
|
|||||||
50
js/ui.js
50
js/ui.js
@@ -39,17 +39,25 @@ function esc(str) {
|
|||||||
return d.innerHTML;
|
return d.innerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SQLite datetime('now') → 'YYYY-MM-DD HH:MM:SS' (UTC, no timezone marker).
|
||||||
|
// Appending 'Z' tells JS to parse it as UTC rather than local time.
|
||||||
|
function parseUtc(d) {
|
||||||
|
if (typeof d !== 'string') return new Date(d);
|
||||||
|
const hasZone = d.endsWith('Z') || /[+-]\d{2}:\d{2}$/.test(d);
|
||||||
|
return new Date(hasZone ? d : d.replace(' ', 'T') + 'Z');
|
||||||
|
}
|
||||||
|
|
||||||
function fmtDate(d) {
|
function fmtDate(d) {
|
||||||
if (!d) return '—';
|
if (!d) return '—';
|
||||||
try {
|
try {
|
||||||
return new Date(d).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', timeZone: getTimezone() });
|
return parseUtc(d).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', timeZone: getTimezone() });
|
||||||
} catch (e) { return d; }
|
} catch (e) { return d; }
|
||||||
}
|
}
|
||||||
|
|
||||||
function fmtDateFull(d) {
|
function fmtDateFull(d) {
|
||||||
if (!d) return '—';
|
if (!d) return '—';
|
||||||
try {
|
try {
|
||||||
return new Date(d).toLocaleString('en-US', { year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', timeZone: getTimezone(), timeZoneName: 'short' });
|
return parseUtc(d).toLocaleString('en-US', { year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', timeZone: getTimezone(), timeZoneName: 'short' });
|
||||||
} catch (e) { return d; }
|
} catch (e) { return d; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,6 +137,21 @@ async function filterInstances() {
|
|||||||
|
|
||||||
const BOOL_FIELDS = ['atlas','argus','semaphore','patchmon','tailscale','andromeda','hardware_acceleration'];
|
const BOOL_FIELDS = ['atlas','argus','semaphore','patchmon','tailscale','andromeda','hardware_acceleration'];
|
||||||
|
|
||||||
|
const FIELD_LABELS = {
|
||||||
|
name: 'name',
|
||||||
|
state: 'state',
|
||||||
|
stack: 'stack',
|
||||||
|
vmid: 'vmid',
|
||||||
|
tailscale_ip: 'tailscale ip',
|
||||||
|
atlas: 'atlas',
|
||||||
|
argus: 'argus',
|
||||||
|
semaphore: 'semaphore',
|
||||||
|
patchmon: 'patchmon',
|
||||||
|
tailscale: 'tailscale',
|
||||||
|
andromeda: 'andromeda',
|
||||||
|
hardware_acceleration: 'hw acceleration',
|
||||||
|
};
|
||||||
|
|
||||||
function stateClass(field, val) {
|
function stateClass(field, val) {
|
||||||
if (field !== 'state') return '';
|
if (field !== 'state') return '';
|
||||||
return { deployed: 'tl-deployed', testing: 'tl-testing', degraded: 'tl-degraded' }[val] ?? '';
|
return { deployed: 'tl-deployed', testing: 'tl-testing', degraded: 'tl-degraded' }[val] ?? '';
|
||||||
@@ -141,9 +164,10 @@ function fmtHistVal(field, val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function renderDetailPage(vmid) {
|
async function renderDetailPage(vmid) {
|
||||||
const [inst, history] = await Promise.all([getInstance(vmid), getInstanceHistory(vmid)]);
|
const [inst, history, all] = await Promise.all([getInstance(vmid), getInstanceHistory(vmid), getInstances()]);
|
||||||
if (!inst) { navigate('dashboard'); return; }
|
if (!inst) { navigate('dashboard'); return; }
|
||||||
currentVmid = vmid;
|
currentVmid = vmid;
|
||||||
|
document.getElementById('nav-count').textContent = `${all.length} instance${all.length !== 1 ? 's' : ''}`;
|
||||||
|
|
||||||
document.getElementById('detail-vmid-crumb').textContent = vmid;
|
document.getElementById('detail-vmid-crumb').textContent = vmid;
|
||||||
document.getElementById('detail-name').textContent = inst.name;
|
document.getElementById('detail-name').textContent = inst.name;
|
||||||
@@ -154,7 +178,7 @@ async function renderDetailPage(vmid) {
|
|||||||
document.getElementById('detail-identity').innerHTML = `
|
document.getElementById('detail-identity').innerHTML = `
|
||||||
<div class="kv-row"><span class="kv-key">name</span><span class="kv-val highlight">${esc(inst.name)}</span></div>
|
<div class="kv-row"><span class="kv-key">name</span><span class="kv-val highlight">${esc(inst.name)}</span></div>
|
||||||
<div class="kv-row"><span class="kv-key">state</span><span class="kv-val"><span class="badge ${esc(inst.state)}">${esc(inst.state)}</span></span></div>
|
<div class="kv-row"><span class="kv-key">state</span><span class="kv-val"><span class="badge ${esc(inst.state)}">${esc(inst.state)}</span></span></div>
|
||||||
<div class="kv-row"><span class="kv-key">stack</span><span class="kv-val highlight">${esc(inst.stack) || '—'}</span></div>
|
<div class="kv-row"><span class="kv-key">stack</span><span class="kv-val"><span class="badge ${esc(inst.stack)}">${esc(inst.stack) || '—'}</span></span></div>
|
||||||
<div class="kv-row"><span class="kv-key">vmid</span><span class="kv-val highlight">${inst.vmid}</span></div>
|
<div class="kv-row"><span class="kv-key">vmid</span><span class="kv-val highlight">${inst.vmid}</span></div>
|
||||||
<div class="kv-row"><span class="kv-key">internal id</span><span class="kv-val">${inst.id}</span></div>
|
<div class="kv-row"><span class="kv-key">internal id</span><span class="kv-val">${inst.id}</span></div>
|
||||||
`;
|
`;
|
||||||
@@ -178,19 +202,23 @@ async function renderDetailPage(vmid) {
|
|||||||
? history.map(e => {
|
? history.map(e => {
|
||||||
if (e.field === 'created') return `
|
if (e.field === 'created') return `
|
||||||
<div class="tl-item tl-created">
|
<div class="tl-item tl-created">
|
||||||
|
<span class="tl-event">instance created</span>
|
||||||
<span class="tl-time">${fmtDateFull(e.changed_at)}</span>
|
<span class="tl-time">${fmtDateFull(e.changed_at)}</span>
|
||||||
<span class="tl-field">created</span>
|
|
||||||
<span class="tl-change">—</span>
|
|
||||||
</div>`;
|
</div>`;
|
||||||
|
const label = FIELD_LABELS[e.field] ?? esc(e.field);
|
||||||
|
const newCls = (e.field === 'state' || e.field === 'stack')
|
||||||
|
? `badge ${esc(e.new_value)}`
|
||||||
|
: `tl-new ${stateClass(e.field, e.new_value)}`;
|
||||||
return `
|
return `
|
||||||
<div class="tl-item">
|
<div class="tl-item">
|
||||||
<span class="tl-time">${fmtDateFull(e.changed_at)}</span>
|
<div class="tl-event">
|
||||||
<span class="tl-field">${esc(e.field)}</span>
|
<span class="tl-label">${label}</span>
|
||||||
<span class="tl-change">
|
<span class="tl-sep">·</span>
|
||||||
<span class="tl-old">${fmtHistVal(e.field, e.old_value)}</span>
|
<span class="tl-old">${fmtHistVal(e.field, e.old_value)}</span>
|
||||||
<span class="tl-arrow">→</span>
|
<span class="tl-arrow">→</span>
|
||||||
<span class="tl-new ${stateClass(e.field, e.new_value)}">${fmtHistVal(e.field, e.new_value)}</span>
|
<span class="${newCls}">${fmtHistVal(e.field, e.new_value)}</span>
|
||||||
</span>
|
</div>
|
||||||
|
<span class="tl-time">${fmtDateFull(e.changed_at)}</span>
|
||||||
</div>`;
|
</div>`;
|
||||||
}).join('')
|
}).join('')
|
||||||
: '<div class="tl-empty">no history yet</div>';
|
: '<div class="tl-empty">no history yet</div>';
|
||||||
|
|||||||
1
js/version.js
Normal file
1
js/version.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
const VERSION = "1.3.0";
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "catalyst",
|
"name": "catalyst",
|
||||||
"version": "1.2.2",
|
"version": "1.3.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node server/server.js",
|
"start": "node server/server.js",
|
||||||
|
|||||||
@@ -58,16 +58,22 @@ describe('esc', () => {
|
|||||||
|
|
||||||
// ── fmtDate() ─────────────────────────────────────────────────────────────────
|
// ── fmtDate() ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function fmtDate(d) {
|
function parseUtc(d) {
|
||||||
|
if (typeof d !== 'string') return new Date(d)
|
||||||
|
const hasZone = d.endsWith('Z') || /[+-]\d{2}:\d{2}$/.test(d)
|
||||||
|
return new Date(hasZone ? d : d.replace(' ', 'T') + 'Z')
|
||||||
|
}
|
||||||
|
|
||||||
|
function fmtDate(d, tz = 'UTC') {
|
||||||
if (!d) return '—'
|
if (!d) return '—'
|
||||||
try {
|
try {
|
||||||
return new Date(d).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' })
|
return parseUtc(d).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', timeZone: tz })
|
||||||
} catch (e) { return d }
|
} catch (e) { return d }
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('fmtDate', () => {
|
describe('fmtDate', () => {
|
||||||
it('formats a valid ISO date string', () => {
|
it('formats a valid ISO date string', () => {
|
||||||
const result = fmtDate('2024-03-15T00:00:00')
|
const result = fmtDate('2024-03-15T12:00:00Z')
|
||||||
expect(result).toMatch(/Mar/)
|
expect(result).toMatch(/Mar/)
|
||||||
expect(result).toMatch(/15/)
|
expect(result).toMatch(/15/)
|
||||||
expect(result).toMatch(/2024/)
|
expect(result).toMatch(/2024/)
|
||||||
@@ -91,7 +97,7 @@ describe('fmtDate', () => {
|
|||||||
function fmtDateFull(d, tz = 'UTC') {
|
function fmtDateFull(d, tz = 'UTC') {
|
||||||
if (!d) return '—'
|
if (!d) return '—'
|
||||||
try {
|
try {
|
||||||
return new Date(d).toLocaleString('en-US', {
|
return parseUtc(d).toLocaleString('en-US', {
|
||||||
year: 'numeric', month: 'short', day: 'numeric',
|
year: 'numeric', month: 'short', day: 'numeric',
|
||||||
hour: '2-digit', minute: '2-digit',
|
hour: '2-digit', minute: '2-digit',
|
||||||
timeZone: tz, timeZoneName: 'short',
|
timeZone: tz, timeZoneName: 'short',
|
||||||
@@ -118,6 +124,12 @@ describe('fmtDateFull', () => {
|
|||||||
expect(result).toMatch(/EDT/)
|
expect(result).toMatch(/EDT/)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('treats SQLite-format timestamps (space, no Z) as UTC', () => {
|
||||||
|
// SQLite datetime('now') → 'YYYY-MM-DD HH:MM:SS', no timezone marker.
|
||||||
|
// Must parse identically to the same moment expressed as ISO UTC.
|
||||||
|
expect(fmtDateFull('2024-03-15 18:30:00', 'UTC')).toBe(fmtDateFull('2024-03-15T18:30:00Z', 'UTC'))
|
||||||
|
})
|
||||||
|
|
||||||
it('returns — for null', () => {
|
it('returns — for null', () => {
|
||||||
expect(fmtDateFull(null)).toBe('—')
|
expect(fmtDateFull(null)).toBe('—')
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user