Compare commits
26 Commits
9177578aaf
...
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 | |||
| cd16b7ea28 | |||
| afbdefa549 | |||
| f1e192c5d4 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,4 @@
|
||||
node_modules/
|
||||
js/version.js
|
||||
data/*.db
|
||||
data/*.db-shm
|
||||
data/*.db-wal
|
||||
|
||||
47
css/app.css
47
css/app.css
@@ -25,6 +25,10 @@
|
||||
--mono: 'JetBrains Mono', 'IBM Plex Mono', monospace;
|
||||
}
|
||||
|
||||
html {
|
||||
zoom: 1.1;
|
||||
}
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
background: var(--bg);
|
||||
@@ -374,16 +378,25 @@ select:focus { border-color: var(--accent); }
|
||||
}
|
||||
|
||||
.detail-sub {
|
||||
font-size: 12px;
|
||||
color: var(--text3);
|
||||
margin-top: 6px;
|
||||
font-size: 13px;
|
||||
margin-top: 8px;
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
align-items: center;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.detail-sub span { display: flex; gap: 4px; }
|
||||
.detail-sub .lbl { color: var(--text3); }
|
||||
.detail-sub .val { color: var(--text2); }
|
||||
.detail-sub > span {
|
||||
display: flex;
|
||||
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; }
|
||||
|
||||
@@ -630,21 +643,25 @@ select:focus { border-color: var(--accent); }
|
||||
|
||||
/* ── HISTORY TIMELINE ── */
|
||||
.tl-item {
|
||||
padding: 12px 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 24px;
|
||||
padding: 9px 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.tl-item:last-child { border-bottom: none; }
|
||||
.tl-time { display: block; color: var(--text3); font-size: 11px; margin-bottom: 5px; }
|
||||
.tl-desc { display: flex; align-items: baseline; gap: 16px; font-size: 13px; }
|
||||
.tl-label { color: var(--text2); min-width: 130px; }
|
||||
.tl-change { display: flex; align-items: baseline; gap: 8px; }
|
||||
.tl-old { color: var(--text3); text-decoration: line-through; }
|
||||
.tl-arrow { color: var(--text3); }
|
||||
.tl-event { display: flex; align-items: center; gap: 7px; font-size: 13px; min-width: 0; }
|
||||
.tl-label { color: var(--text2); }
|
||||
.tl-sep { color: var(--text3); user-select: none; }
|
||||
.tl-old { color: var(--text3); text-decoration: line-through; font-size: 12px; }
|
||||
.tl-arrow { color: var(--text3); font-size: 11px; }
|
||||
.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-testing { color: var(--amber); }
|
||||
.tl-degraded { color: var(--red); }
|
||||
.tl-created .tl-label { color: var(--accent); font-weight: 500; }
|
||||
.tl-created .tl-event { color: var(--accent); font-weight: 500; }
|
||||
.tl-empty { color: var(--text3); font-size: 12px; padding: 8px 0; }
|
||||
|
||||
/* ── SETTINGS MODAL ── */
|
||||
|
||||
35
js/ui.js
35
js/ui.js
@@ -39,17 +39,25 @@ function esc(str) {
|
||||
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) {
|
||||
if (!d) return '—';
|
||||
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; }
|
||||
}
|
||||
|
||||
function fmtDateFull(d) {
|
||||
if (!d) return '—';
|
||||
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; }
|
||||
}
|
||||
|
||||
@@ -156,9 +164,10 @@ function fmtHistVal(field, val) {
|
||||
}
|
||||
|
||||
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; }
|
||||
currentVmid = vmid;
|
||||
document.getElementById('nav-count').textContent = `${all.length} instance${all.length !== 1 ? 's' : ''}`;
|
||||
|
||||
document.getElementById('detail-vmid-crumb').textContent = vmid;
|
||||
document.getElementById('detail-name').textContent = inst.name;
|
||||
@@ -169,7 +178,7 @@ async function renderDetailPage(vmid) {
|
||||
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">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">internal id</span><span class="kv-val">${inst.id}</span></div>
|
||||
`;
|
||||
@@ -193,21 +202,23 @@ async function renderDetailPage(vmid) {
|
||||
? history.map(e => {
|
||||
if (e.field === 'created') return `
|
||||
<div class="tl-item tl-created">
|
||||
<span class="tl-event">instance created</span>
|
||||
<span class="tl-time">${fmtDateFull(e.changed_at)}</span>
|
||||
<div class="tl-desc"><span class="tl-label">instance created</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 `
|
||||
<div class="tl-item">
|
||||
<span class="tl-time">${fmtDateFull(e.changed_at)}</span>
|
||||
<div class="tl-desc">
|
||||
<div class="tl-event">
|
||||
<span class="tl-label">${label}</span>
|
||||
<span class="tl-change">
|
||||
<span class="tl-old">${fmtHistVal(e.field, e.old_value)}</span>
|
||||
<span class="tl-arrow">→</span>
|
||||
<span class="tl-new ${stateClass(e.field, e.new_value)}">${fmtHistVal(e.field, e.new_value)}</span>
|
||||
</span>
|
||||
<span class="tl-sep">·</span>
|
||||
<span class="tl-old">${fmtHistVal(e.field, e.old_value)}</span>
|
||||
<span class="tl-arrow">→</span>
|
||||
<span class="${newCls}">${fmtHistVal(e.field, e.new_value)}</span>
|
||||
</div>
|
||||
<span class="tl-time">${fmtDateFull(e.changed_at)}</span>
|
||||
</div>`;
|
||||
}).join('')
|
||||
: '<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",
|
||||
"version": "1.2.2",
|
||||
"version": "1.3.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "node server/server.js",
|
||||
|
||||
@@ -58,16 +58,22 @@ describe('esc', () => {
|
||||
|
||||
// ── 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 '—'
|
||||
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 }
|
||||
}
|
||||
|
||||
describe('fmtDate', () => {
|
||||
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(/15/)
|
||||
expect(result).toMatch(/2024/)
|
||||
@@ -91,7 +97,7 @@ describe('fmtDate', () => {
|
||||
function fmtDateFull(d, tz = 'UTC') {
|
||||
if (!d) return '—'
|
||||
try {
|
||||
return new Date(d).toLocaleString('en-US', {
|
||||
return parseUtc(d).toLocaleString('en-US', {
|
||||
year: 'numeric', month: 'short', day: 'numeric',
|
||||
hour: '2-digit', minute: '2-digit',
|
||||
timeZone: tz, timeZoneName: 'short',
|
||||
@@ -118,6 +124,12 @@ describe('fmtDateFull', () => {
|
||||
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', () => {
|
||||
expect(fmtDateFull(null)).toBe('—')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user