settings export/import/reset + interaktive tutorial-tour
Settings (Einstellungen → Allgemein → Daten): - Exportieren (JSON-Download), Importieren (Datei zurückladen), "Zurücksetzen & als neuer User starten" – sichert settings.json vorher automatisch (timestamped), dann Ersteinrichtung. - Server: GET /api/settings/export, POST /api/settings/import, POST /api/settings/reset; lib/settings.js: exportData/importData/reset. Interaktive Tour (Hilfe-Dialog → "Diesen Bereich zeigen"): - Spotlight wandert animiert über die echten UI-Elemente, Sprechblase mit Text, Auto-Play + Pause/Zurück/Weiter/Schließen, Pfeiltasten/Esc. - Pro Bereich (Ansichten, Finden, Projekt, Backup, Gut zu wissen) eigene Schritte; wechselt bei Bedarf Ansicht/Modus bzw. öffnet ein Projekt und stellt danach den Ausgangszustand wieder her. Fehlende Ziele werden übersprungen. Zweisprachig. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
174
public/app.js
174
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 <dialog>: Esc closes it) */
|
||||
const HELP_PAGES = [
|
||||
{ t: 'help.g.views', rows: [['kanban', 'help.board'], ['layout-grid', 'help.gallery'], ['list', 'help.list'], ['list-checks', 'help.tasks'], ['activity', 'help.activity'], ['hard-drive', 'help.storage']] },
|
||||
{ t: 'help.g.find', rows: [['sliders-horizontal', 'help.mode'], ['search', 'help.search'], ['funnel', 'help.filters']] },
|
||||
{ t: 'help.g.project', rows: [['pencil', 'help.edit'], ['info', 'help.info'], ['play', 'help.actions'], ['folder-open', 'help.quick']] },
|
||||
{ t: 'help.g.backup', rows: [['hard-drive-upload', 'help.backup'], ['clock-alert', 'help.due']] },
|
||||
{ t: 'help.g.misc', rows: [['folders', 'help.folders'], ['languages', 'help.lang'], ['keyboard', 'help.keys']] },
|
||||
{ id: 'views', t: 'help.g.views', rows: [['kanban', 'help.board'], ['layout-grid', 'help.gallery'], ['list', 'help.list'], ['list-checks', 'help.tasks'], ['activity', 'help.activity'], ['hard-drive', 'help.storage']] },
|
||||
{ id: 'find', t: 'help.g.find', rows: [['sliders-horizontal', 'help.mode'], ['search', 'help.search'], ['funnel', 'help.filters']] },
|
||||
{ id: 'project', t: 'help.g.project', rows: [['pencil', 'help.edit'], ['info', 'help.info'], ['play', 'help.actions'], ['folder-open', 'help.quick']] },
|
||||
{ id: 'backup', t: 'help.g.backup', rows: [['hard-drive-upload', 'help.backup'], ['clock-alert', 'help.due']] },
|
||||
{ id: 'misc', t: 'help.g.misc', rows: [['folders', 'help.folders'], ['languages', 'help.lang'], ['keyboard', 'help.keys']] },
|
||||
]
|
||||
let helpPage = 0
|
||||
function renderHelp() {
|
||||
helpPage = Math.max(0, Math.min(HELP_PAGES.length - 1, helpPage))
|
||||
document.getElementById('helpNav').innerHTML = HELP_PAGES.map((p, i) => `<button type="button" class="hnav ${i === helpPage ? 'active' : ''}" data-hp="${i}">${t(p.t)}</button>`).join('')
|
||||
document.getElementById('helpBody').innerHTML = HELP_PAGES[helpPage].rows.map(([icon, k]) => `<div class="helprow"><span class="hc">${ic(icon)}</span><div>${t(k)}</div></div>`).join('')
|
||||
document.getElementById('helpBody').innerHTML =
|
||||
`<button type="button" class="btn primary helpshow" id="helpShow">${ic('play', 'sm')}${t('help.show')}</button>` +
|
||||
HELP_PAGES[helpPage].rows.map(([icon, k]) => `<div class="helprow"><span class="hc">${ic(icon)}</span><div>${t(k)}</div></div>`).join('')
|
||||
document.getElementById('helpShow').onclick = () => startTour(HELP_PAGES[helpPage].id)
|
||||
document.getElementById('helpDots').innerHTML = HELP_PAGES.map((_, i) => `<i class="${i === helpPage ? 'on' : ''}"></i>`).join('')
|
||||
document.getElementById('helpPrev').disabled = helpPage === 0
|
||||
document.getElementById('helpNext').disabled = helpPage === HELP_PAGES.length - 1
|
||||
@@ -994,6 +1032,130 @@ document.getElementById('helpDlg').addEventListener('keydown', (e) => {
|
||||
if (e.key === 'ArrowRight' && helpPage < HELP_PAGES.length - 1) gotoHelp(helpPage + 1)
|
||||
if (e.key === 'ArrowLeft' && helpPage > 0) gotoHelp(helpPage - 1)
|
||||
})
|
||||
|
||||
/* ── interactive tour: spotlight walks over the real UI, section by section ── */
|
||||
// Each step points at a real element (sel). before() may switch view/mode or open
|
||||
// a project so the element exists; steps whose element is missing are skipped.
|
||||
const TOURS = {
|
||||
views: { before: () => applyUiMode('advanced'), steps: [
|
||||
{ sel: '#tabs [data-view="board"]', key: 'help.board' },
|
||||
{ sel: '#tabs [data-view="gallery"]', key: 'help.gallery' },
|
||||
{ sel: '#tabs [data-view="list"]', key: 'help.list' },
|
||||
{ sel: '#tabs [data-view="tasks"]', key: 'help.tasks' },
|
||||
{ sel: '#tabs [data-view="activity"]', key: 'help.activity' },
|
||||
{ sel: '#tabs [data-view="storage"]', key: 'help.storage' },
|
||||
] },
|
||||
find: { before: () => { applyUiMode('advanced'); setView('board') }, steps: [
|
||||
{ sel: '#modeSeg', key: 'help.mode' },
|
||||
{ sel: '.searchbox', key: 'help.search' },
|
||||
{ sel: '#chipfilters', key: 'help.filters' },
|
||||
] },
|
||||
project: { before: () => { applyUiMode('advanced'); setView('board') }, steps: [
|
||||
{ sel: '#board .card .qsg', key: 'help.quick' },
|
||||
{ before: () => { const p = visibleProjects()[0] || projects[0]; if (p) { tour.openedEditor = true; openEditor(p) } }, wait: 480, sel: '#ptabs [data-sec="edit"]', key: 'help.edit' },
|
||||
{ sel: '#ptabs [data-sec="info"]', key: 'help.info' },
|
||||
{ sel: '#ptabs [data-sec="actions"]', key: 'help.actions' },
|
||||
] },
|
||||
backup: { before: () => applyUiMode('advanced'), steps: [
|
||||
{ sel: '#btnBackup', key: 'help.backup' },
|
||||
{ sel: '#chipfilters [data-q="due"]', key: 'help.due' },
|
||||
] },
|
||||
misc: { before: () => applyUiMode('advanced'), steps: [
|
||||
{ sel: '#rootBtn', key: 'help.folders' },
|
||||
{ sel: '#btnSettings', key: 'help.lang' },
|
||||
{ sel: '#btnHelp', key: 'help.keys' },
|
||||
] },
|
||||
}
|
||||
const AUTO_MS = 3400
|
||||
let tour = null
|
||||
function startTour(id) {
|
||||
const def = TOURS[id]
|
||||
if (!def) return
|
||||
document.getElementById('helpDlg').close()
|
||||
tour = { def, steps: def.steps, i: -1, playing: true, timer: null, prevView: activeView, prevMode: uiMode, openedEditor: false }
|
||||
try { def.before?.() } catch {}
|
||||
document.getElementById('tour').hidden = false
|
||||
setTimeout(() => tourGo(1), 320) // let a view/mode switch render first
|
||||
}
|
||||
const tourTarget = (s) => (s.sel ? document.querySelector(s.sel) : null)
|
||||
async function tourGo(dir) {
|
||||
if (!tour) return
|
||||
clearTimeout(tour.timer)
|
||||
let i = tour.i
|
||||
for (;;) {
|
||||
i += dir
|
||||
if (i < 0) { i = 0; break }
|
||||
if (i >= tour.steps.length) { endTour(); return }
|
||||
const s = tour.steps[i]
|
||||
if (s.before) { try { s.before() } catch {} }
|
||||
if (s.wait) await new Promise((r) => setTimeout(r, s.wait))
|
||||
if (!tour) return // closed meanwhile
|
||||
if (!s.sel || tourTarget(s)) break // usable step (has target or is centered)
|
||||
}
|
||||
tour.i = i
|
||||
tourShow()
|
||||
}
|
||||
function tourShow() {
|
||||
if (!tour) return
|
||||
const s = tour.steps[tour.i]
|
||||
positionSpot(tourTarget(s))
|
||||
document.getElementById('tourText').innerHTML = t(s.key)
|
||||
document.getElementById('tourStep').textContent = `${tour.i + 1} / ${tour.steps.length}`
|
||||
document.getElementById('tourPrev').disabled = tour.i === 0
|
||||
document.querySelector('#tourNext span').textContent = tour.i === tour.steps.length - 1 ? t('tour.finish') : t('help.next')
|
||||
document.querySelector('#tourPause use').setAttribute('href', `/icons.svg#${tour.playing ? 'pause' : 'play'}`)
|
||||
clearTimeout(tour.timer)
|
||||
if (tour.playing) tour.timer = setTimeout(() => tourGo(1), AUTO_MS)
|
||||
}
|
||||
function positionSpot(el) {
|
||||
const spot = document.getElementById('tourSpot')
|
||||
const bubble = document.getElementById('tourBubble')
|
||||
if (el) {
|
||||
try { el.scrollIntoView({ block: 'nearest', inline: 'nearest' }) } catch {}
|
||||
const r = el.getBoundingClientRect(), pad = 6
|
||||
spot.style.top = (r.top - pad) + 'px'
|
||||
spot.style.left = (r.left - pad) + 'px'
|
||||
spot.style.width = (r.width + pad * 2) + 'px'
|
||||
spot.style.height = (r.height + pad * 2) + 'px'
|
||||
const bw = Math.min(320, innerWidth - 24), bh = bubble.offsetHeight || 150
|
||||
let top = r.bottom + 12
|
||||
if (top + bh > innerHeight - 10) top = Math.max(10, r.top - bh - 12)
|
||||
let left = Math.max(12, Math.min(innerWidth - bw - 12, r.left + r.width / 2 - bw / 2))
|
||||
bubble.style.top = top + 'px'
|
||||
bubble.style.left = left + 'px'
|
||||
} else {
|
||||
spot.style.width = spot.style.height = '0px'
|
||||
spot.style.top = innerHeight / 2 + 'px'
|
||||
spot.style.left = innerWidth / 2 + 'px'
|
||||
bubble.style.top = Math.max(12, innerHeight / 2 - 90) + 'px'
|
||||
bubble.style.left = (innerWidth / 2 - Math.min(320, innerWidth - 24) / 2) + 'px'
|
||||
}
|
||||
}
|
||||
function endTour() {
|
||||
if (!tour) return
|
||||
clearTimeout(tour.timer)
|
||||
const opened = tour.openedEditor, pv = tour.prevView, pm = tour.prevMode
|
||||
tour = null
|
||||
document.getElementById('tour').hidden = true
|
||||
if (opened) try { closeEditor() } catch {}
|
||||
try { applyUiMode(pm) } catch {}
|
||||
try { setView(pv) } catch {}
|
||||
}
|
||||
document.getElementById('tourClose').onclick = endTour
|
||||
document.getElementById('tourPrev').onclick = () => tourGo(-1)
|
||||
document.getElementById('tourNext').onclick = () => tourGo(1)
|
||||
document.getElementById('tourPause').onclick = () => {
|
||||
if (!tour) return
|
||||
tour.playing = !tour.playing
|
||||
tourShow()
|
||||
}
|
||||
addEventListener('resize', () => { if (tour) tourShow() })
|
||||
addEventListener('keydown', (e) => {
|
||||
if (!tour) return
|
||||
if (e.key === 'Escape') { e.preventDefault(); endTour() }
|
||||
else if (e.key === 'ArrowRight') tourGo(1)
|
||||
else if (e.key === 'ArrowLeft') tourGo(-1)
|
||||
})
|
||||
document.getElementById('spCancel').onclick = closeSettings
|
||||
document.getElementById('spSave').onclick = saveSettings
|
||||
|
||||
|
||||
Reference in New Issue
Block a user