diff --git a/README.md b/README.md index 840a1a2..859fd3b 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,18 @@ Oben links neben dem Logo ist ein Auswahlmenü: Sind mehrere Ordner sichtbar, steht auf jeder Karte, aus welchem sie stammt. +### Projekte in Unterordnern +Liegen Projekte eine Ebene tiefer (z. B. `Arduino Projekte\KlopfSchloss`, `Arduino Projekte\MusikBox`), findet sie +der Scanner: Ordner-Menü oben → **Projekte in Unterordnern suchen…** oder Einstellungen → Projektordner. +- Gesucht wird in **Sammelordnern** – Ordnern ohne eigene Projekt-Kennzeichen (kein `.git`, README, `package.json`, + `.sln`, `.ino` …), bis drei Ebenen tief. Neue Funde sind vorangekreuzt. +- **Auch in Projekten suchen** zeigt zusätzlich eigenständige Teile echter Projekte (z. B. `Tools\DownloaderTool` + mit eigener `.csproj`) – nicht vorangekreuzt, weil sie meist zum Projekt gehören. +- **Übernehmen:** Angekreuzte Ordner erscheinen als eigene Projekte (die Karte zeigt den Elternordner), ein reiner + Sammelordner wird ausgeblendet. Alles andere – Bearbeiten, Starten, Git, Backup, Aufräumen, Umbenennen – + funktioniert wie bei jedem Projekt. Auf der Platte ändert sich nichts. +- Gibt es neue Funde, die du noch nicht angesehen hast, erscheint einmal pro Sitzung ein Hinweis. + ### Backup Knopf **Backup** oben: 1. **Prüfen, was neu ist** – zeigt neue und geänderte Dateien pro Projekt. @@ -219,6 +231,7 @@ Liegt das Dashboard in `\_Tools\ProjectDashboard`, wird `` a | `lib\storage.js` | Größen-Scan mit Ordner-Aufteilung (Treemap) und Aufräumen über `cleanup.ps1` | | `lib\scheduler.js` | Automatisches Backup nach Zeitplan (Stand in `auto-backup.json` im Datenordner) | | `lib\archive.js` | Release-ZIP nach `\releases` (über `tar.exe` von Windows) | +| `lib\nested.js` | Scanner für Projekte in Unterordnern (Sammelordner, Kennzeichen, Hinweis) | | `lib\itchpack.js` | itch.io-Paket (`docs\itchio`) lesen, Bilder ausliefern, Claude Code mit Skill `itchiocreater` starten | | `lib\create.js` | Neu, Klonen, Umbenennen/Verschieben | | `lib\git.js` · `lib\tech.js` · `lib\icons.js` | Git-Status, Technik-Erkennung + Aktionen, App-Icons | diff --git a/lib/backup.js b/lib/backup.js index e40000c..1461145 100644 --- a/lib/backup.js +++ b/lib/backup.js @@ -305,7 +305,8 @@ function lastFor(root, folder, targetId) { else if (d.last) { if (!Array.isArray(d.last.failed) && d.last.log) d.last.failed = failedFromLog(d.last.log, root, destOf(t, root)) ?? undefined if (Array.isArray(d.last.failed)) { - full = d.last.failed.includes(folder) + // failed lists top-level folders; a project in a subfolder counts by its top folder + full = d.last.failed.includes(folder) || d.last.failed.includes(folder.split(path.sep)[0]) ? { at: d.last.at, ok: false, how: 'Komplett-Backup – Fehler in diesem Projekt' } : { at: d.last.at, ok: true, how: 'Komplett-Backup' } } diff --git a/lib/nested.js b/lib/nested.js new file mode 100644 index 0000000..932ea09 --- /dev/null +++ b/lib/nested.js @@ -0,0 +1,116 @@ +// Projects in subfolders: finds project folders below a projects folder's direct +// children, so they can be shown as projects of their own (chosen in the UI, +// stored per projects folder in settings: roots[].nested / nestedIgnored). +// - "collection" folders (no project markers themselves, e.g. "Arduino Projekte") +// are searched up to MAX_DEPTH; a hit is not searched further +// - deep: also sub-projects inside real projects (mostly parts of them, so the +// UI never preselects these) +const fs = require('fs') +const path = require('path') + +const MAX_DEPTH = 3 +const SKIP = new Set(['node_modules', 'library', 'temp', 'obj', 'bin', 'build', 'builds', 'dist', 'out', '.git', '.venv', 'venv', '__pycache__', 'packages', 'releases', 'docs', 'itchio', 'sprite-generator', 'spritegenerator']) +const STRONG = new Set(['git', 'dashboard', 'Unity', '.NET-sln', 'Unreal', 'Flutter']) +const APPS = new Set(['.NET', 'Node', 'Gradle', 'Flutter', 'Python', 'HTML', 'Arduino']) +const NOT_PROJECTS = new Set(['project-dashboard', '$recycle.bin', 'system volume information', 'recovery', 'config.msi']) + +function ls(dir) { + try { return fs.readdirSync(dir, { withFileTypes: true }) } catch { return [] } +} + +// project markers on the folder's own level (cheap: one readdir) +function markers(dir) { + const entries = ls(dir) + const names = new Set(entries.map((e) => e.name.toLowerCase())) + const files = entries.filter((e) => e.isFile()).map((e) => e.name.toLowerCase()) + const m = [] + if (names.has('.git')) m.push('git') + if (names.has('.dashboard.json')) m.push('dashboard') + if (names.has('assets') && names.has('projectsettings')) m.push('Unity') + if (names.has('package.json')) m.push('Node') + if (files.some((f) => f.endsWith('.sln'))) m.push('.NET-sln') + else if (files.some((f) => f.endsWith('.csproj'))) m.push('.NET') + if (names.has('pubspec.yaml')) m.push('Flutter') + if (names.has('build.gradle') || names.has('build.gradle.kts')) m.push('Gradle') + if (names.has('cmakelists.txt')) m.push('CMake') + if (names.has('platformio.ini') || files.some((f) => f.endsWith('.ino'))) m.push('Arduino') + if (names.has('cargo.toml')) m.push('Rust') + if (names.has('go.mod')) m.push('Go') + if (files.some((f) => f.endsWith('.py'))) m.push('Python') + if (names.has('index.html')) m.push('HTML') + if (files.some((f) => f.endsWith('.uproject'))) m.push('Unreal') + if (names.has('readme.md') || names.has('claude.md')) m.push('README') + return m +} +const isProject = (dir) => markers(dir).length > 0 + +const subdirs = (dir) => ls(dir).filter((e) => e.isDirectory() && !e.name.startsWith('.') && !SKIP.has(e.name.toLowerCase())) + +// projects below `dir` (not `dir` itself), relative to `base` +function findBelow(base, dir, depth, maxDepth, out) { + if (depth > maxDepth) return + for (const e of subdirs(dir)) { + const full = path.join(dir, e.name) + const m = markers(full) + if (m.length) { out.push({ rel: path.relative(base, full), markers: m, depth }); continue } + findBelow(base, full, depth + 1, maxDepth, out) + } +} + +// { containers: [{ rel, projects: [{ rel, markers }] }], inProjects: [{ rel, markers, parent }] } +function scan(rootPath, { deep = false } = {}) { + const containers = [] + const inProjects = [] + for (const e of ls(rootPath)) { + if (!e.isDirectory() || e.name.startsWith('.') || NOT_PROJECTS.has(e.name.toLowerCase()) || e.name === '_Tools') continue + const dir = path.join(rootPath, e.name) + if (!isProject(dir)) { + const found = [] + findBelow(rootPath, dir, 1, MAX_DEPTH, found) + if (found.length) containers.push({ rel: e.name, projects: found.map(({ rel, markers }) => ({ rel, markers })) }) + } else if (deep) { + // inside a real project almost every folder has some marker (Engine\CMakeLists, + // tools\*.py ...): only count what looks like a project of its own + const found = [] + findBelow(rootPath, dir, 1, 2, found) + // (a solution, a repo ...), or an app one folder deeper, e.g. Tools\DownloaderTool + for (const f of found) { + if (f.markers.some((m) => STRONG.has(m)) || (f.depth >= 2 && f.markers.some((m) => APPS.has(m)))) inProjects.push({ rel: f.rel, markers: f.markers, parent: e.name }) + } + } + } + return { containers, inProjects } +} + +// "Arduino Projekte\KlopfSchloss" - normalised, inside the root, 2..MAX_DEPTH+1 levels, or null +function cleanRel(rootPath, rel) { + if (typeof rel !== 'string' || !rel.trim()) return null + const norm = path.normalize(rel.trim()).replace(/^[\\/]+|[\\/]+$/g, '') + const parts = norm.split(path.sep) + if (parts.length < 2 || parts.length > MAX_DEPTH + 1 || parts.some((x) => !x || x === '.' || x === '..')) return null + const full = path.resolve(rootPath, norm) + if (!full.toLowerCase().startsWith(path.resolve(rootPath).toLowerCase() + path.sep)) return null + return norm +} + +// how many collection-folder finds are neither chosen nor dismissed (cached) +const hintCache = new Map() +function hint(roots) { + let n = 0 + for (const r of roots) { + const key = `${r.path}|${(r.nested ?? []).join('|')}|${(r.nestedIgnored ?? []).join('|')}` + let c = hintCache.get(r.path) + if (!c || c.key !== key || Date.now() - c.at > 5 * 60 * 1000) { + const known = new Set([...(r.nested ?? []), ...(r.nestedIgnored ?? [])].map((x) => x.toLowerCase())) + let count = 0 + try { for (const k of scan(r.path).containers) for (const p of k.projects) if (!known.has(p.rel.toLowerCase())) count++ } catch {} + c = { key, at: Date.now(), count } + hintCache.set(r.path, c) + } + n += c.count + } + return n +} +const forgetHint = () => hintCache.clear() + +module.exports = { scan, markers, isProject, cleanRel, hint, forgetHint, MAX_DEPTH } diff --git a/lib/settings.js b/lib/settings.js index ef65e41..3cbeb19 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -87,6 +87,21 @@ function cleanAuto(a, old) { let current = null +// projects in subfolders: { nested: chosen relative paths, nestedIgnored: seen, not chosen } +function nestedOf(r) { + const list = (v) => (Array.isArray(v) ? [...new Set(v.filter((x) => typeof x === 'string' && x && !x.split(/[\\/]/).includes('..')))].slice(0, 200) : []) + return { nested: list(r?.nested), nestedIgnored: list(r?.nestedIgnored) } +} + +// Stores the scanner's choice for one projects folder (paths already checked by lib/nested.js). +function setNested(rootId, chosen, ignored) { + const s = get() + const roots = s.roots.map((r) => (r.id === rootId ? { ...r, ...nestedOf({ nested: chosen, nestedIgnored: ignored }) } : r)) + current = { ...s, roots } + persist(current) + return current +} + function load() { const d = defaults() const saved = process.env.DASHBOARD_ROOT && !process.env.DASHBOARD_DATA ? null : readJson(FILE) @@ -96,10 +111,13 @@ function load() { backup.auto = cleanAuto(saved?.backup?.auto) // older settings had one "projectsRoot" let roots = Array.isArray(saved?.roots) - ? saved.roots.filter((r) => r && typeof r.path === 'string' && r.path).map((r) => ({ id: String(r.id || newId()), name: String(r.name || rootName(r.path)), path: r.path })) + ? saved.roots.filter((r) => r && typeof r.path === 'string' && r.path).map((r) => ({ id: String(r.id || newId()), name: String(r.name || rootName(r.path)), path: r.path, ...nestedOf(r) })) : typeof saved?.projectsRoot === 'string' ? rootsFrom(saved.projectsRoot) : d.roots // an explicit DASHBOARD_ROOT always wins (tests) - if (process.env.DASHBOARD_ROOT) roots = [{ id: 'env', name: rootName(path.resolve(process.env.DASHBOARD_ROOT)), path: path.resolve(process.env.DASHBOARD_ROOT) }] + if (process.env.DASHBOARD_ROOT) { + const envPath = path.resolve(process.env.DASHBOARD_ROOT) + roots = [{ id: 'env', name: rootName(envPath), path: envPath, ...nestedOf(roots.find((r) => samePath(r.path, envPath))) }] + } current = withActive({ roots, activeRoots: Array.isArray(saved?.activeRoots) ? saved.activeRoots : [saved?.activeRoot], @@ -177,6 +195,8 @@ function save(input) { id: old && samePath(old.path, p) ? old.id : newId(), name: String(r.name ?? '').trim().slice(0, 40) || rootName(p), path: p, + // projects in subfolders (chosen in the scanner) stay with the folder + ...nestedOf(old && samePath(old.path, p) ? old : s.roots.find((x) => samePath(x.path, p))), }) // a selected folder stays selected even if its path (and so its id) changed if (r.id) renamed.set(String(r.id), roots.at(-1).id) @@ -302,4 +322,4 @@ function subfolders(dir) { return { path: p, folders: list.slice(0, 200) } } -module.exports = { get, load, save, setActive, addRoots, activeRootList, subfolders, backupSubdir, configured, targetName, DATA_DIR, APP_DIR, DEFAULT_EXCLUDE_DIRS } +module.exports = { setNested, get, load, save, setActive, addRoots, activeRootList, subfolders, backupSubdir, configured, targetName, DATA_DIR, APP_DIR, DEFAULT_EXCLUDE_DIRS } diff --git a/lib/storage.js b/lib/storage.js index 7d41cbb..cdd5bec 100644 --- a/lib/storage.js +++ b/lib/storage.js @@ -57,8 +57,16 @@ function scriptFor(root) { function available() { return true } const cleanupAvailable = () => !!scriptFor(roots[0]) -function psArgs(root, extra) { - return ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', scriptFor(root), '-Root', root, ...extra, '-Json'] +// effRoot: the folder cleanup.ps1 treats as its root - for a project in a subfolder +// ("Sammel\A") its parent folder, because the script only knows direct children +function psArgs(root, extra, effRoot = root) { + return ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', scriptFor(root), '-Root', effRoot, ...extra, '-Json'] +} +// { effRoot, project, prefix } for cleanup.ps1; prefix turns its paths into "\..." +function scriptTarget(root, folder) { + const parent = path.dirname(folder) + if (parent === '.' || !parent) return { effRoot: root, project: folder, prefix: '' } + return { effRoot: path.join(root, parent), project: path.basename(folder), prefix: parent + path.sep } } function parseJson(stdout) { @@ -125,11 +133,12 @@ async function sizeTree(dir) { async function scanProject(root, folder) { const dir = path.join(root, folder) + const st = scriptTarget(root, folder) const [split, cand] = await Promise.all([ sizeTree(dir), - scriptFor(root) ? run('powershell.exe', psArgs(root, ['-Project', folder, '-Tier', ALL_TIERS]), { timeout: 10 * 60 * 1000 }) : null, + scriptFor(root) ? run('powershell.exe', psArgs(root, ['-Project', st.project, '-Tier', ALL_TIERS], st.effRoot), { timeout: 10 * 60 * 1000 }) : null, ]) - const candidates = cand ? parseJson(cand.stdout) : [] + const candidates = (cand ? parseJson(cand.stdout) : []).map((c) => (st.prefix && typeof c.Path === 'string' ? { ...c, Path: st.prefix + c.Path } : c)) const deletable = { Cache: 0, Release: 0, Output: 0 } for (const c of candidates) if (!c.Skip) deletable[c.Tier] += c.MB const d = (all[rootKey(root)] ??= {}) @@ -159,7 +168,9 @@ async function clean(root, folder, paths) { const only = paths.filter((p) => typeof p === 'string' && p.startsWith(prefix) && !p.includes('|')) if (!only.length) throw new Error('nichts ausgewählt') if (!scriptFor(root)) throw new Error('cleanup.ps1 nicht gefunden') - const r = await run('powershell.exe', psArgs(root, ['-Project', folder, '-Tier', ALL_TIERS, '-Only', only.join('|'), '-Apply']), { timeout: 30 * 60 * 1000 }) + const st = scriptTarget(root, folder) + const rel = only.map((p) => p.slice(st.prefix.length)) + const r = await run('powershell.exe', psArgs(root, ['-Project', st.project, '-Tier', ALL_TIERS, '-Only', rel.join('|'), '-Apply'], st.effRoot), { timeout: 30 * 60 * 1000 }) const result = parseJson(r.stdout) await scanProject(root, folder) return result diff --git a/public/app.js b/public/app.js index f51910e..6b4ab1e 100644 --- a/public/app.js +++ b/public/app.js @@ -169,10 +169,14 @@ function prioHtml(prio) { } // Which projects folder a project is from - only shown when several are on screen. +// A project from a subfolder (scanner) also names the folder it lies in. function rootTag(p, short = false) { - if (!multiRoot() || !p.rootName) return '' + const parent = p.parent + ? `${ic('folder-tree', 'sm')}${short ? '' : ' '}${escapeHtml(p.parent.split('\\').pop())}` + : '' + if (!multiRoot() || !p.rootName) return parent const path = roots.find((r) => r.id === p.root)?.path ?? '' - return `${ic('folder', 'sm')}${short ? '' : ' '}${escapeHtml(p.rootName)}` + return `${ic('folder', 'sm')}${short ? '' : ' '}${escapeHtml(p.rootName)}${parent}` } function techChips(types) { @@ -220,6 +224,11 @@ async function load() { clearTimeout(load.again) if (data.activityPending > 0) load.again = setTimeout(load, 2500) if (data.setupNeeded) openSettings(true) // first start: choose the projects folder + // projects found in subfolders that were never looked at: one hint per session + if (data.nestedHint > 0 && !load.nestedHinted && !data.setupNeeded) { + load.nestedHinted = true + setTimeout(() => toast(`${data.nestedHint} ${data.nestedHint === 1 ? 'Projekt' : 'Projekte'} in Unterordnern gefunden – Klick zum Ansehen`, 'folder-tree', openNested), 1500) + } } /* ── new project / clone ──────────────────────────────────────────────── */ @@ -371,6 +380,7 @@ function renderRootPicker() { `${roots.length ? '
' : ''}` + (hasPicker ? `` : '') + ` + ` } @@ -466,6 +476,7 @@ rootMenu.addEventListener('click', (e) => { if (b.hasAttribute('data-root-manage')) { toggleRootMenu(false); openSettings(false); return } if (b.hasAttribute('data-root-add')) { toggleRootMenu(false); addRootByPicker(); return } if (b.hasAttribute('data-root-import')) { toggleRootMenu(false); openRootImport(); return } + if (b.hasAttribute('data-root-nested')) { toggleRootMenu(false); openNested(); return } if (b.hasAttribute('data-root-all')) { showRoots(roots.map((r) => r.id)); return } const t = b.dataset.rootToggle if (t) { @@ -957,12 +968,16 @@ async function patchProject(name, body) { return res.ok } -function toast(text, icon = 'info') { +// onClick: the toast becomes clickable (and stays a bit longer) +function toast(text, icon = 'info', onClick = null) { const el = document.getElementById('toast') el.innerHTML = `${ic(icon)}${escapeHtml(text)}` el.classList.add('show') + el.style.pointerEvents = onClick ? 'auto' : '' + el.style.cursor = onClick ? 'pointer' : '' + el.onclick = onClick ? () => { el.classList.remove('show'); onClick() } : null clearTimeout(toast.t) - toast.t = setTimeout(() => el.classList.remove('show'), 3400) + toast.t = setTimeout(() => el.classList.remove('show'), onClick ? 8000 : 3400) } const runAction = async (name, id) => { @@ -1173,7 +1188,7 @@ function cardHtml(p) { ${p.lastCommit ? `
${ic('git-commit-horizontal', 'sm')}${escapeHtml(p.lastCommit.message)}
` : ''} ${factsHtml(p)}
${gitHtml(p.git)}${cloudChip(p)}${pubChip(p)}
- ${multiRoot() ? `
${rootTag(p)}
` : ''} + ${multiRoot() || p.parent ? `
${rootTag(p)}
` : ''}
${techChips(p.tech?.types)}${warnChips(p)}${tags}
${p.notes ? `
${escapeHtml(p.notes)}
` : ''} ${total ? `
${ic('list-checks', 'sm')}${done}/${total}
` : ''}` @@ -1722,7 +1737,7 @@ function renderHogs() { ${rows.map((r) => ` ${can ? `` : ''} ${escapeHtml(r.p.name)} - ${escapeHtml(inProject(r.path))} + ${escapeHtml(inProject(r.path, r.p.folder))} ${TIER_SHORT[r.tier]} ${fmtMB1(r.mb)}`).join('')}` : 'Nichts zum Aufräumen gefunden (oder noch nicht gemessen).' @@ -1747,7 +1762,7 @@ document.getElementById('stDelete').onclick = async () => { const sel = (renderHogs.rows ?? []).filter((r) => stSelected.has(`${r.p.name}|${r.path}`)) if (!sel.length) return const mb = sel.reduce((s, r) => s + r.mb, 0) - if (!confirm(`${sel.length} Ordner (${fmtMB1(mb)}) endgültig löschen?\n\n${sel.map((r) => `${r.p.name}: ${inProject(r.path)}`).join('\n')}\n\nSie lassen sich neu erzeugen (npm install, Build …).`)) return + if (!confirm(`${sel.length} Ordner (${fmtMB1(mb)}) endgültig löschen?\n\n${sel.map((r) => `${r.p.name}: ${inProject(r.path, r.p.folder)}`).join('\n')}\n\nSie lassen sich neu erzeugen (npm install, Build …).`)) return const btn = document.getElementById('stDelete') btn.disabled = true btn.innerHTML = `${ic('loader')}Lösche…` @@ -1905,7 +1920,11 @@ function addTaskFromInput() { } // cleanup paths are "\rest" (relative to the projects folder) → "rest" -const inProject = (p) => p.slice(p.indexOf('\\') + 1) +// (projects in subfolders: folder is "Sammel\A", so strip the whole folder, not up to the first \) +const inProject = (p, folder) => { + const pre = folder ? `${folder}\\` : '' + return pre && p.toLowerCase().startsWith(pre.toLowerCase()) ? p.slice(pre.length) : p.slice(p.indexOf('\\') + 1) +} // opts: { id } for jump targets, { right } html at the end of the heading function section(icon, title, body, opts = {}) { @@ -2076,7 +2095,7 @@ function gitActionsHtml(name, d) { function archiveHtml(name, d) { const s = d.storage const folder = editing?.folder ?? name - const releaseCands = new Set((s?.candidates ?? []).filter((c) => c.Tier === 'Release' && !c.Skip).map((c) => inProject(c.Path).toLowerCase())) + const releaseCands = new Set((s?.candidates ?? []).filter((c) => c.Tier === 'Release' && !c.Skip).map((c) => inProject(c.Path, folder).toLowerCase())) const rd = d.releaseDirs ?? [] return `
@@ -2116,7 +2135,7 @@ function cleanHtml(d) { body += rows.length ? `${rows.map((c) => ` - + `).join('')}
${escapeHtml(inProject(c.Path))}${escapeHtml(inProject(c.Path, editing?.folder))} ${ic(TIER[c.Tier].icon, 'sm')}${TIER[c.Tier].label}${c.Skip ? ` ${ic('lock', 'sm')}in git` : ''} ${fmtMB(c.MB)}
Cache ist vorausgewählt (immer neu erzeugbar). Fertige Builds und Rohbilder nur bewusst anhaken.
` @@ -2278,7 +2297,7 @@ function bindClean(name, d) { const paths = [...document.querySelectorAll('.candcb:checked')].map((cb) => cb.dataset.path) if (!paths.length) return toast('Nichts ausgewählt') const mb = s.candidates.filter((c) => paths.includes(c.Path)).reduce((a, c) => a + c.MB, 0) - if (!confirm(`${paths.length} Ordner (${fmtMB(mb)}) in „${name}“ endgültig löschen?\n\n${paths.map(inProject).join('\n')}`)) return + if (!confirm(`${paths.length} Ordner (${fmtMB(mb)}) in „${name}“ endgültig löschen?\n\n${paths.map((x) => inProject(x, editing?.folder)).join('\n')}`)) return clean.disabled = true clean.innerHTML = `${ic('loader')}Lösche…` try { @@ -2290,6 +2309,74 @@ function bindClean(name, d) { } } +/* ── projects in subfolders (scanner, lib/nested.js) ──────────────────── */ + +let nestData = null +let nestDeep = false + +async function openNested(deep = false) { + const dlg = document.getElementById('nestDlg') + nestDeep = deep + // keep what was ticked before a re-scan (deep) + const prev = new Map([...document.querySelectorAll('#nestBody input[data-rel]')].map((cb) => [`${cb.dataset.root}|${cb.dataset.rel}`, cb.checked])) + document.getElementById('nestBody').innerHTML = `
${ic('loader', 'sm')} Suche…
` + document.getElementById('nestDeep').hidden = deep + if (!dlg.open) dlg.showModal() + try { + const r = await fetch(`/api/nested/scan${deep ? '?deep=1' : ''}`) + nestData = await r.json() + if (!r.ok) throw new Error(nestData.error) + renderNested(dlg.open && deep ? prev : new Map()) + } catch (e) { + document.getElementById('nestBody').innerHTML = `
Fehler: ${escapeHtml(e.message)}
` + } +} + +function renderNested(prev) { + const item = (root, x, preset) => { + const k = `${root.id}|${x.rel}` + const on = prev.has(k) ? prev.get(k) : preset + const parts = x.rel.split('\\') + return `` + } + const roots = nestData.roots ?? [] + const html = roots.map((r) => { + const groups = r.containers.map((c) => `
+
${ic('folder', 'sm')}${escapeHtml(c.rel)}Sammelordner · wird ausgeblendet, wenn etwas übernommen ist
+ ${c.projects.map((x) => item(r, x, x.chosen || !x.ignored)).join('')} +
`).join('') + const inner = r.inProjects.length ? `
+
${ic('folder-git-2', 'sm')}In Projektenmeist Teil des Projekts – nur bei Bedarf ankreuzen
+ ${r.inProjects.map((x) => item(r, x, x.chosen)).join('')} +
` : '' + const n = r.containers.reduce((a, c) => a + c.projects.length, 0) + r.inProjects.length + return `

${ic('folders')}${escapeHtml(r.name)} ${escapeHtml(r.path)} · ${n} gefunden

+ ${groups + inner || `
Keine Projekte in Unterordnern${nestDeep ? '' : ' (Sammelordner)'}.
`}
` + }).join('') + document.getElementById('nestBody').innerHTML = ` +
Angekreuzte Ordner erscheinen als eigene Projekte. Ein Sammelordner ohne eigenes Projekt (kein git, README, package.json …) wird dann ausgeblendet. Auf der Platte ändert sich nichts.
+ ${html || '
Keine Projektordner eingerichtet.
'}` +} + +async function saveNested() { + const out = {} + for (const r of nestData?.roots ?? []) out[r.id] = { chosen: [], ignored: [] } + for (const cb of document.querySelectorAll('#nestBody input[data-rel]')) out[cb.dataset.root]?.[cb.checked ? 'chosen' : 'ignored'].push(cb.dataset.rel) + const btn = document.getElementById('nestOk') + btn.disabled = true + try { + const r = await postJson('/api/nested', { roots: out }) + document.getElementById('nestDlg').close() + await load() + toast(r.chosen ? `${r.chosen} ${r.chosen === 1 ? 'Projekt' : 'Projekte'} aus Unterordnern übernommen` : 'Keine Projekte aus Unterordnern', 'folder-tree') + } catch (e) { toast(e.message, 'triangle-alert') } finally { btn.disabled = false } +} + /* ── itch.io copy view (docs\itchio of the project, lib/itchpack.js) ───── */ let itchName = null @@ -2868,7 +2955,12 @@ document.getElementById('btnCloseBackup').onclick = closeBackup document.getElementById('search').addEventListener('input', (e) => { searchTerm = e.target.value; render() }) for (const btn of document.querySelectorAll('#tabs button')) btn.onclick = () => { setView(btn.dataset.view); render() } for (const btn of document.querySelectorAll('#ptabs button')) btn.onclick = () => setSection(btn.dataset.sec) -document.getElementById('itchClose').onclick = () => document.getElementById('itchDlg').close() +document.getElementById('nestClose').onclick = () => document.getElementById('nestDlg').close() +document.getElementById('nestCancel').onclick = () => document.getElementById('nestDlg').close() +document.getElementById('nestDeep').onclick = () => openNested(true) +document.getElementById('nestOk').onclick = saveNested +document.getElementById('fNestedOpen').onclick = () => openNested() +document.getElementById('itchClose').onclick =() => document.getElementById('itchDlg').close() document.getElementById('itchReload').onclick = () => itchName && openItch(itchName) document.getElementById('itchOpenDir').onclick = () => itchName && postJson(api(itchName, 'itch/open')).catch((e) => toast(e.message, 'triangle-alert')) document.getElementById('fltStatus').addEventListener('change', render) diff --git a/public/index.html b/public/index.html index b564778..036011d 100644 --- a/public/index.html +++ b/public/index.html @@ -555,6 +555,23 @@ .card-sec h4 .h4r .i, .isec h4 .h4r .i { color: inherit; } a.jump { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--accent-text); text-decoration: none; } a.jump:hover { text-decoration: underline; } + /* projects in subfolders (scanner dialog) */ + #nestBody { padding: 4px 20px 12px; } + .nestfoot { display: flex; gap: 8px; align-items: center; padding: 12px 20px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); } + .nestfoot .sp { flex: 1; } + .nroot { margin-top: 14px; } + .nroot > h4 { margin: 0 0 6px; font-size: 13px; display: flex; gap: 7px; align-items: center; } + .nroot > h4 .hint { margin: 0; font-weight: 400; } + .ngroup { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); margin-top: 8px; overflow: hidden; } + .ngroup .nghead { display: flex; gap: 8px; align-items: center; padding: 8px 12px; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--border); } + .ngroup .nghead .hint { margin: 0 0 0 auto; font-weight: 400; } + .nitem { display: flex; gap: 10px; align-items: center; padding: 7px 12px; font-size: 13px; border-top: 1px solid var(--border); cursor: pointer; } + .nitem:first-of-type { border-top: 0; } + .nitem input { flex: 0 0 auto; } + .nitem .nrel { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } + .nitem .nrel b { font-weight: 600; } + .nitem .chip { font-size: 10px; } + .card .rootline .rtag + .rtag { margin-left: 4px; } .pdesc { font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; } .pdesc.muted { color: var(--muted); font-style: italic; } .pdesc-edit textarea { width: 100%; min-height: 120px; resize: vertical; font: inherit; font-size: 13px; line-height: 1.5; } @@ -971,6 +988,7 @@
+