diff --git a/lib/settings.js b/lib/settings.js
index a2a3180..7ce3ecb 100644
--- a/lib/settings.js
+++ b/lib/settings.js
@@ -343,4 +343,35 @@ function subfolders(dir) {
return { path: p, folders: list.slice(0, 200) }
}
-module.exports = { setNested, itchOn, get, load, save, setActive, addRoots, activeRootList, subfolders, backupSubdir, configured, targetName, DATA_DIR, APP_DIR, DEFAULT_EXCLUDE_DIRS }
+// The persisted shape (what settings.json holds; derived fields stripped) – for "Export settings".
+function exportData() {
+ const { projectsRoot, activeRoot, ...stored } = get()
+ return stored
+}
+
+// Overwrites settings.json with an imported object and reloads. load() is tolerant and fills gaps.
+function importData(obj) {
+ if (!obj || typeof obj !== 'object' || Array.isArray(obj)) throw new Error('Ungültige Einstellungsdatei.')
+ fs.mkdirSync(DATA_DIR, { recursive: true })
+ fs.writeFileSync(FILE, JSON.stringify(obj, null, 2))
+ current = null
+ return load()
+}
+
+// Backs up settings.json (timestamped) and removes it, so the next load starts as a new user.
+function reset() {
+ let backupFile = ''
+ try {
+ if (fs.existsSync(FILE)) {
+ const ts = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19)
+ backupFile = path.join(DATA_DIR, `settings-backup-${ts}.json`)
+ fs.copyFileSync(FILE, backupFile)
+ fs.rmSync(FILE, { force: true })
+ }
+ } catch (e) { throw new Error(`Zurücksetzen fehlgeschlagen: ${e.message ?? e}`) }
+ current = null
+ load()
+ return { backupFile }
+}
+
+module.exports = { setNested, itchOn, get, load, save, setActive, addRoots, activeRootList, subfolders, backupSubdir, configured, targetName, DATA_DIR, APP_DIR, DEFAULT_EXCLUDE_DIRS, exportData, importData, reset }
diff --git a/public/app.js b/public/app.js
index 5c93820..6d9e9c4 100644
--- a/public/app.js
+++ b/public/app.js
@@ -762,6 +762,41 @@ document.getElementById('spOpenData').onclick = async () => {
try { await postJson('/api/datadir/open') } catch (e) { toast(e.message, 'triangle-alert') }
}
+/* settings backup / restore / reset (Einstellungen → Allgemein → Daten) */
+document.getElementById('spExport').onclick = async () => {
+ try {
+ const data = await (await fetch('/api/settings/export')).json()
+ const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' })
+ const a = document.createElement('a')
+ a.href = URL.createObjectURL(blob)
+ a.download = `project-dashboard-settings-${new Date().toISOString().slice(0, 10)}.json`
+ a.click()
+ setTimeout(() => URL.revokeObjectURL(a.href), 2000)
+ toast(t('set.exported'), 'download')
+ } catch (e) { toast(e.message, 'triangle-alert') }
+}
+document.getElementById('spImport').onclick = () => document.getElementById('spImportFile').click()
+document.getElementById('spImportFile').onchange = async (e) => {
+ const file = e.target.files?.[0]
+ e.target.value = ''
+ if (!file) return
+ try {
+ const data = JSON.parse(await file.text())
+ if (!confirm(t('set.importConfirm'))) return
+ await postJson('/api/settings/import', { data })
+ toast(t('set.imported'), 'upload')
+ setTimeout(() => location.reload(), 600)
+ } catch (ex) { toast(t('set.importBad') + ' ' + (ex.message ?? ''), 'triangle-alert') }
+}
+document.getElementById('spReset').onclick = async () => {
+ if (!confirm(t('set.resetConfirm'))) return
+ try {
+ const r = await postJson('/api/settings/reset')
+ toast(r.backupFile ? t('set.resetDone', { file: r.backupFile }) : t('set.resetDoneNoBackup'), 'refresh-cw')
+ setTimeout(() => location.reload(), 900)
+ } catch (e) { toast(e.message, 'triangle-alert') }
+}
+
// "Durchsuchen…": data-for = input id, or (in a target/folder row) the row's path input
document.getElementById('spanel').addEventListener('click', async (e) => {
const b = e.target.closest('.pickbtn')
@@ -968,17 +1003,20 @@ document.getElementById('btnSettings').onclick = () => openSettings(false)
document.getElementById('btnCloseSettings').onclick = closeSettings
/* help / overview dialog – paged, one topic group per page (native
-
+
+
+
+
+
+
+
+
+ Your current settings are backed up first; then the dashboard starts fresh with the first-run setup.
+
+
+
+
diff --git a/public/lang.js b/public/lang.js
index f6d1a32..d1f35cf 100644
--- a/public/lang.js
+++ b/public/lang.js
@@ -185,6 +185,17 @@ window.LANG = {
'set.data.h': 'Data',
'set.language': 'Language',
'set.openData': 'Open data folder',
+ 'set.export': 'Export settings',
+ 'set.import': 'Import settings',
+ 'set.reset': 'Reset & start as a new user…',
+ 'set.resetHint': 'Your current settings are backed up first; then the dashboard starts fresh with the first-run setup.',
+ 'set.exported': 'Settings exported',
+ 'set.importConfirm': 'Replace the current settings with the imported file? The page reloads afterwards.',
+ 'set.imported': 'Settings imported',
+ 'set.importBad': 'Could not read the settings file.',
+ 'set.resetConfirm': 'Reset the dashboard to a fresh “new user” state? Your current settings are backed up first, then the page reloads into the first-run setup.',
+ 'set.resetDone': 'Reset done – backup saved: {file}',
+ 'set.resetDoneNoBackup': 'Reset done',
'set.window.h': 'Window',
'set.window.p': 'Applies immediately, without saving.',
'set.tray': 'Keep running in the background when closed',
@@ -746,6 +757,9 @@ window.LANG = {
'help.keys': 'Shortcuts – Esc closes panels and dialogs; Ctrl+S saves the settings.',
'help.prev': 'Back',
'help.next': 'Next',
+ 'help.show': 'Show me this section',
+ 'tour.finish': 'Done',
+ 'tour.pause': 'Pause / play',
},
de: {
@@ -929,6 +943,17 @@ window.LANG = {
'set.data.h': 'Daten',
'set.language': 'Sprache',
'set.openData': 'Datenordner öffnen',
+ 'set.export': 'Einstellungen exportieren',
+ 'set.import': 'Einstellungen importieren',
+ 'set.reset': 'Zurücksetzen & als neuer User starten…',
+ 'set.resetHint': 'Deine aktuellen Einstellungen werden vorher gesichert; danach startet das Dashboard neu mit der Ersteinrichtung.',
+ 'set.exported': 'Einstellungen exportiert',
+ 'set.importConfirm': 'Aktuelle Einstellungen durch die importierte Datei ersetzen? Die Seite lädt danach neu.',
+ 'set.imported': 'Einstellungen importiert',
+ 'set.importBad': 'Einstellungsdatei konnte nicht gelesen werden.',
+ 'set.resetConfirm': 'Dashboard auf einen frischen „neuer User“-Zustand zurücksetzen? Deine aktuellen Einstellungen werden vorher gesichert, danach lädt die Seite in die Ersteinrichtung.',
+ 'set.resetDone': 'Zurückgesetzt – Sicherung gespeichert: {file}',
+ 'set.resetDoneNoBackup': 'Zurückgesetzt',
'set.window.h': 'Fenster',
'set.window.p': 'Gilt sofort, ohne Speichern.',
'set.tray': 'Beim Schließen im Hintergrund weiterlaufen',
@@ -1490,5 +1515,8 @@ window.LANG = {
'help.keys': 'Tastenkürzel – Esc schließt Panels und Dialoge; Strg+S speichert die Einstellungen.',
'help.prev': 'Zurück',
'help.next': 'Weiter',
+ 'help.show': 'Diesen Bereich zeigen',
+ 'tour.finish': 'Fertig',
+ 'tour.pause': 'Pause / Abspielen',
},
};
diff --git a/server.js b/server.js
index 5cec9b4..dd22ef7 100644
--- a/server.js
+++ b/server.js
@@ -452,6 +452,32 @@ app.post('/api/settings', (req, res) => {
res.status(400).json({ error: String(e.message ?? e) })
}
})
+// Export the settings as JSON (client offers it as a download).
+app.get('/api/settings/export', (req, res) => {
+ res.json(settings.exportData())
+})
+// Import a settings object (from a previously exported file) and apply it.
+app.post('/api/settings/import', (req, res) => {
+ if (storage.busy() || backup.busy() || create.busy()) return res.status(409).json({ error: 'Erst warten, bis Scan/Backup fertig ist.' })
+ try {
+ settings.importData(req.body?.data ?? req.body)
+ applySettings()
+ res.json({ ...settings.get(), configured: !!ROOT_DIR, dataDir: settings.DATA_DIR })
+ } catch (e) {
+ res.status(400).json({ error: String(e.message ?? e) })
+ }
+})
+// Reset to a fresh "new user" state. Backs up settings.json first, then starts over.
+app.post('/api/settings/reset', (req, res) => {
+ if (storage.busy() || backup.busy() || create.busy() || archive.busy()) return res.status(409).json({ error: 'Erst warten, bis Scan/Backup fertig ist.' })
+ try {
+ const r = settings.reset()
+ applySettings()
+ res.json({ ok: true, backupFile: r.backupFile })
+ } catch (e) {
+ res.status(400).json({ error: String(e.message ?? e) })
+ }
+})
// Update detection: newest change of the server code (server.js, lib\*.js) and
// of the page (public\*). The server code is only read at start, so a newer
// file means "restart needed"; the page only needs a reload.