feat: add datapoint delete, show emoji icons in preview

- DELETE /api/datapoints/:id endpoint + frontend button
- Preview shows emoji symbols instead of [icon] text

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 03:55:35 +02:00
co-authored by Claude Opus 4.6
parent 4964a2e8ab
commit 8a5031649a
4 changed files with 49 additions and 2 deletions
@@ -3,6 +3,7 @@ import {
getAllDatapoints,
getDatapointById,
updateDatapoint,
deleteDatapoint,
} from '../../modules/datapoints/datapoint-manager';
const router = Router();
@@ -38,4 +39,15 @@ router.put('/:id', (req, res): void => {
}
});
// DELETE /api/datapoints/:id
router.delete('/:id', (req, res): void => {
try {
const deleted = deleteDatapoint(parseInt(req.params.id));
if (!deleted) { res.status(404).json({ error: 'Datapoint not found' }); return; }
res.status(204).send();
} catch (err) {
res.status(500).json({ error: (err as Error).message });
}
});
export default router;
@@ -118,6 +118,12 @@ export function createDatapointFromPg(
return db.prepare('SELECT * FROM datapoints WHERE id = ?').get(id) as Datapoint;
}
export function deleteDatapoint(id: number): boolean {
const db = getDb();
const result = db.prepare('DELETE FROM datapoints WHERE id = ?').run(id);
return (result.changes as number) > 0;
}
export function getDatapointByTopicId(topicId: number): Datapoint | undefined {
const db = getDb();
return db