Compare commits
22 Commits
520fb98d96
...
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 | |||
| 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
|
||||
|
||||
27
css/app.css
27
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; }
|
||||
|
||||
|
||||
19
js/ui.js
19
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>
|
||||
`;
|
||||
@@ -197,7 +206,7 @@ async function renderDetailPage(vmid) {
|
||||
<span class="tl-time">${fmtDateFull(e.changed_at)}</span>
|
||||
</div>`;
|
||||
const label = FIELD_LABELS[e.field] ?? esc(e.field);
|
||||
const newCls = e.field === 'state'
|
||||
const newCls = (e.field === 'state' || e.field === 'stack')
|
||||
? `badge ${esc(e.new_value)}`
|
||||
: `tl-new ${stateClass(e.field, e.new_value)}`;
|
||||
return `
|
||||
|
||||
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