feat: settings modal with database export and import
Adds a gear button to the nav that opens a settings modal with: - Export: GET /api/export returns all instances as a JSON backup file with a Content-Disposition attachment header - Import: POST /api/import validates and bulk-replaces all instances; client uses FileReader to POST the parsed JSON, with a confirm dialog before destructive replace Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
15
server/db.js
15
server/db.js
@@ -125,6 +125,21 @@ export function deleteInstance(vmid) {
|
||||
return db.prepare('DELETE FROM instances WHERE vmid = ?').run(vmid);
|
||||
}
|
||||
|
||||
export function importInstances(rows) {
|
||||
db.exec('BEGIN');
|
||||
db.exec('DELETE FROM instances');
|
||||
const insert = db.prepare(`
|
||||
INSERT INTO instances
|
||||
(name, state, stack, vmid, atlas, argus, semaphore, patchmon,
|
||||
tailscale, andromeda, tailscale_ip, hardware_acceleration)
|
||||
VALUES
|
||||
(@name, @state, @stack, @vmid, @atlas, @argus, @semaphore, @patchmon,
|
||||
@tailscale, @andromeda, @tailscale_ip, @hardware_acceleration)
|
||||
`);
|
||||
for (const row of rows) insert.run(row);
|
||||
db.exec('COMMIT');
|
||||
}
|
||||
|
||||
// ── Test helpers ──────────────────────────────────────────────────────────────
|
||||
|
||||
export function _resetForTest() {
|
||||
|
||||
Reference in New Issue
Block a user