Changelog: build_time fix im Eintrag gespeichert statt dynamisch

This commit is contained in:
2026-05-29 09:59:12 +02:00
parent bc85460ea3
commit b91b742dd8
3 changed files with 13 additions and 5 deletions

View File

@@ -332,10 +332,15 @@ if (!db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='cha
version TEXT NOT NULL, version TEXT NOT NULL,
title TEXT NOT NULL, title TEXT NOT NULL,
body TEXT NOT NULL DEFAULT '', body TEXT NOT NULL DEFAULT '',
build_time TEXT DEFAULT NULL,
created_at DATETIME DEFAULT NULL created_at DATETIME DEFAULT NULL
) )
`); `);
} }
// Migration: build_time Spalte
const clCols = db.prepare("PRAGMA table_info(changelog)").all().map(r => r.name);
if (clCols.length && !clCols.includes('build_time'))
db.exec("ALTER TABLE changelog ADD COLUMN build_time TEXT DEFAULT NULL");
// ── Push-Zeitplaner ─────────────────────────────────────────────────────────── // ── Push-Zeitplaner ───────────────────────────────────────────────────────────
if (!db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='push_schedules'").get()) { if (!db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='push_schedules'").get()) {

View File

@@ -212,10 +212,10 @@ router.get('/changelog', authenticate, (req, res) => {
}); });
router.post('/changelog', authenticate, requireAdmin, (req, res) => { router.post('/changelog', authenticate, requireAdmin, (req, res) => {
const { version, title, body } = req.body; const { version, title, body, build_time } = req.body;
if (!version?.trim() || !title?.trim()) return res.status(400).json({ error: 'Version und Titel erforderlich' }); if (!version?.trim() || !title?.trim()) return res.status(400).json({ error: 'Version und Titel erforderlich' });
const r = db.prepare(`INSERT INTO changelog (version, title, body, created_at) VALUES (?,?,?,datetime('now','localtime'))`) const r = db.prepare(`INSERT INTO changelog (version, title, body, build_time, created_at) VALUES (?,?,?,?,datetime('now','localtime'))`)
.run(version.trim(), title.trim(), body?.trim() || ''); .run(version.trim(), title.trim(), body?.trim() || '', build_time || null);
res.json(db.prepare('SELECT * FROM changelog WHERE id=?').get(r.lastInsertRowid)); res.json(db.prepare('SELECT * FROM changelog WHERE id=?').get(r.lastInsertRowid));
}); });

View File

@@ -1187,7 +1187,10 @@ function ChangelogModal({ user, toast, onClose }) {
if (!form.version.trim() || !form.title.trim()) { toast('Version und Titel erforderlich','error'); return; } if (!form.version.trim() || !form.title.trim()) { toast('Version und Titel erforderlich','error'); return; }
setBusy(true); setBusy(true);
try { try {
const r = await api('/dashboard/changelog',{body:form}); const r = await api('/dashboard/changelog',{body:{
...form,
build_time: typeof __BUILD_TIME__ !== 'undefined' ? __BUILD_TIME__ : null,
}});
setEntries(p=>[r,...p]); setEntries(p=>[r,...p]);
setForm({version:'',title:'',body:''}); setForm({version:'',title:'',body:''});
toast('Eintrag hinzugefügt ✓'); toast('Eintrag hinzugefügt ✓');
@@ -1259,7 +1262,7 @@ function ChangelogModal({ user, toast, onClose }) {
</div> </div>
<div style={{display:'flex',alignItems:'center',gap:6,flexShrink:0}}> <div style={{display:'flex',alignItems:'center',gap:6,flexShrink:0}}>
<span style={{color:'rgba(255,255,255,0.2)',fontFamily:'monospace',fontSize:9}}> <span style={{color:'rgba(255,255,255,0.2)',fontFamily:'monospace',fontSize:9}}>
{typeof __BUILD_TIME__ !== 'undefined' && __BUILD_TIME__ ? __BUILD_TIME__ : fmtDate(e.created_at)} {e.build_time || fmtDate(e.created_at)}
</span> </span>
{isAdmin && ( {isAdmin && (
<button onClick={()=>del(e.id)} <button onClick={()=>del(e.id)}