i18n (en/de), simple-ansicht, settings-politur, projekt-löschen

- Sprachsystem: public/i18n.js + public/lang.js (en Default, de), Sprach-Dropdown
  in Einstellungen → Allgemein; komplette UI zweisprachig (HTML + app.js),
  Datum/Zahlen locale-abhängig. Server-Fehlermeldungen bleiben deutsch.
- Einfache Ansicht: Scroll-Fix, Layout-Umschalter (Kacheln/Kompakt/Liste),
  Sortierung, Backup-fällig-Pille.
- Credits: © Michael Media + Discord (Einstellungen → Über, README).
- Settings poliert: Icon-Chip-Überschriften + dezente Unterabschnitte,
  kompaktere Abstände, General sinnvoll geordnet.
- Projekt löschen: Button in Aktionen (Danger Zone) + Endpoint
  POST /api/projects/:name/delete mit Guards (nur echter Unterordner,
  nie _Tools/Root, blockiert bei Scan/Backup), doppelte Bestätigung.
  Backup bleibt unberührt.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-24 16:06:09 +01:00
parent f2d0cd1df9
commit 1cc49ec8d4
7 changed files with 2453 additions and 624 deletions

View File

@@ -321,10 +321,20 @@ async function describeProject(p, target) {
}
}
// progress of reading the projects (start screen: /api/progress)
const loadState = { running: 0, phase: '', done: 0, total: 0 }
async function listProjects(target) {
if (settings.itchOn()) await itch.ensure() // switched off: no request to itch.io
const list = await pool(projectList(), 8, (p) => describeProject(p, target))
return list.sort((a, b) => new Date(b.mtime) - new Date(a.mtime))
loadState.running++
try {
if (settings.itchOn()) { loadState.phase = 'itch'; await itch.ensure() } // switched off: no request to itch.io
const items = projectList()
Object.assign(loadState, { phase: 'projects', done: 0, total: items.length })
const list = await pool(items, 8, async (p) => { const d = await describeProject(p, target); loadState.done++; return d })
return list.sort((a, b) => new Date(b.mtime) - new Date(a.mtime))
} finally {
loadState.running--
if (!loadState.running) loadState.phase = ''
}
}
// tech.actions matches programs against the folder name; the key names the console windows
@@ -381,6 +391,16 @@ app.get('/icons.svg', (req, res) => {
res.sendFile(ICON_SPRITE, (err) => { if (err && !res.headersSent) res.status(404).end() })
})
// Start screen: how far reading the projects (git, sizes ...) and the
// "last change" of every project (lib/activity.js, in the background) has come.
app.get('/api/progress', (req, res) => {
const total = projMap.size
res.json({
projects: { running: loadState.running > 0, phase: loadState.phase, done: loadState.done, total: loadState.total },
activity: { pending: activity.pending(), total },
})
})
app.get('/api/projects', handle(async (req, res) => {
const list = await listProjects(String(req.query.target ?? '') || null)
const s = settings.get()
@@ -391,7 +411,9 @@ app.get('/api/projects', handle(async (req, res) => {
activeRoot: s.activeRoot,
activeRoots: s.activeRoots,
remindDays: s.backup.remindDays ?? 7,
setupNeeded: !ROOT_DIR,
// first start: no usable projects folder registered at all (an empty selection is fine)
setupNeeded: !settings.get().roots.some((r) => fs.existsSync(r.path)),
noneShown: !ROOTS.length && !!settings.get().noneShown,
projects: list,
totals: { ...storage.totals(list.map((p) => ({ root: ROOTS.find((r) => r.id === p.root)?.path, folder: p.folder }))), noBackup: list.filter((p) => p.git.level === 'red').length },
scan: storage.state,
@@ -444,7 +466,7 @@ const uiFiles = () => filesIn(path.join(__dirname, 'public'), /\.(js|html|css)$/
const CODE_STAMP = newestMtime(codeFiles())
const STARTED_AT = new Date().toISOString()
app.get('/api/version', (req, res) => {
res.json({ startedAt: STARTED_AT, pid: process.pid, stale: newestMtime(codeFiles()) > CODE_STAMP, uiStamp: newestMtime(uiFiles()) })
res.json({ startedAt: STARTED_AT, pid: process.pid, version: require('./package.json').version, stale: newestMtime(codeFiles()) > CODE_STAMP, uiStamp: newestMtime(uiFiles()) })
})
// Restart the server (lib/supervisor.js starts it again).
app.post('/api/restart', (req, res) => {
@@ -883,6 +905,41 @@ app.post('/api/projects/:name/clean', handle(async (req, res) => {
res.json(result)
}))
// Permanently deletes the whole project folder from disk (not from any backup).
// Guarded: only a real subfolder of a shown projects folder, never a root or _Tools.
app.post('/api/projects/:name/delete', handle(async (req, res) => {
if (storage.busy() || backup.busy() || create.busy() || archive.busy()) return res.status(409).json({ error: 'Erst warten, bis Scan/Backup fertig ist.' })
const key = req.params.name
const dir = resolveProject(key)
const ref = dir && projectRef(key)
if (!ref || !dir) return res.status(404).json({ error: 'unknown project' })
if (ref.folder === '_Tools') return res.status(400).json({ error: '_Tools wird nie gelöscht' })
const root = path.resolve(ref.root.path)
const target = path.resolve(dir)
// never the projects folder itself, never a drive root – only a subfolder of a registered root
if (target.toLowerCase() === root.toLowerCase() || !target.toLowerCase().startsWith(root.toLowerCase() + path.sep) || path.dirname(target) === target) {
return res.status(400).json({ error: 'Ordner nicht löschbar.' })
}
try {
fs.rmSync(target, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 })
} catch (e) {
return res.status(400).json({ error: `Löschen fehlgeschlagen (Datei gesperrt? Programm offen?): ${String(e.message ?? e)}` })
}
// drop it from the subfolder-scanner lists if it was listed there
const rSet = settings.get().roots.find((x) => x.id === ref.root.id)
if (rSet) {
const low = ref.folder.toLowerCase()
const nn = (rSet.nested ?? []).filter((x) => x.toLowerCase() !== low)
const ni = (rSet.nestedIgnored ?? []).filter((x) => x.toLowerCase() !== low)
if (nn.length !== (rSet.nested ?? []).length || ni.length !== (rSet.nestedIgnored ?? []).length) {
settings.setNested(rSet.id, nn, ni); nested.forgetHint(); applySettings()
}
}
thumbCache.delete(key); quickCache.delete(key); icons.forget(target)
projectList()
res.json({ ok: true, name: ref.name })
}))
// NAS backup (lib/backup.js): check → copy, never deletes in the backup.
app.get('/api/backup', (req, res) => res.json({ ...backup.getState(), schedule: scheduler.status() }))
// body: { target } = check everything · { target, project, autoCopy: true } = "Sichern" of one project