unterordner scanner
This commit is contained in:
116
public/app.js
116
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
|
||||
? `<span class="rtag ptag" title="Liegt im Unterordner: ${escapeHtml(p.parent)}">${ic('folder-tree', 'sm')}${short ? '' : ' '}${escapeHtml(p.parent.split('\\').pop())}</span>`
|
||||
: ''
|
||||
if (!multiRoot() || !p.rootName) return parent
|
||||
const path = roots.find((r) => r.id === p.root)?.path ?? ''
|
||||
return `<span class="rtag" title="Projektordner: ${escapeHtml(p.rootName)}${path ? ` (${escapeHtml(path)})` : ''}">${ic('folder', 'sm')}${short ? '' : ' '}${escapeHtml(p.rootName)}</span>`
|
||||
return `<span class="rtag" title="Projektordner: ${escapeHtml(p.rootName)}${path ? ` (${escapeHtml(path)})` : ''}">${ic('folder', 'sm')}${short ? '' : ' '}${escapeHtml(p.rootName)}</span>${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 ? '<div class="sep"></div>' : ''}` +
|
||||
(hasPicker ? `<button type="button" data-root-add><span class="chk">${ic('folder-plus', 'sm')}</span>Ordner hinzufügen…</button>` : '') +
|
||||
`<button type="button" data-root-import><span class="chk">${ic('folders', 'sm')}</span>Mehrere Ordner einlesen…</button>
|
||||
<button type="button" data-root-nested><span class="chk">${ic('folder-tree', 'sm')}</span>Projekte in Unterordnern suchen…</button>
|
||||
<button type="button" data-root-manage><span class="chk">${ic('settings', 'sm')}</span>Projektordner verwalten…</button>`
|
||||
}
|
||||
|
||||
@@ -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)}<span>${escapeHtml(text)}</span>`
|
||||
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 ? `<div class="commit" title="${escapeHtml(p.lastCommit.message)}">${ic('git-commit-horizontal', 'sm')}<span>${escapeHtml(p.lastCommit.message)}</span></div>` : ''}
|
||||
${factsHtml(p)}
|
||||
<div class="row2">${gitHtml(p.git)}${cloudChip(p)}${pubChip(p)}</div>
|
||||
${multiRoot() ? `<div class="rootline">${rootTag(p)}</div>` : ''}
|
||||
${multiRoot() || p.parent ? `<div class="rootline">${rootTag(p)}</div>` : ''}
|
||||
<div class="chips">${techChips(p.tech?.types)}${warnChips(p)}${tags}</div>
|
||||
${p.notes ? `<div class="notes">${escapeHtml(p.notes)}</div>` : ''}
|
||||
${total ? `<div class="taskbar">${ic('list-checks', 'sm')}<span>${done}/${total}</span><div class="bar"><div style="width:${Math.round((done / total) * 100)}%"></div></div></div>` : ''}`
|
||||
@@ -1722,7 +1737,7 @@ function renderHogs() {
|
||||
<tbody>${rows.map((r) => `<tr data-k="${escapeHtml(keyOf(r))}">
|
||||
${can ? `<td><input type="checkbox" ${stSelected.has(keyOf(r)) ? 'checked' : ''} aria-label="Auswählen"></td>` : ''}
|
||||
<td>${escapeHtml(r.p.name)}</td>
|
||||
<td class="path">${escapeHtml(inProject(r.path))}</td>
|
||||
<td class="path">${escapeHtml(inProject(r.path, r.p.folder))}</td>
|
||||
<td><span class="sttier" title="${TIER[r.tier]?.hint ?? ''}"><i style="background:${tierVar(r.tier)}"></i>${TIER_SHORT[r.tier]}</span></td>
|
||||
<td class="num">${fmtMB1(r.mb)}</td></tr>`).join('')}</tbody>`
|
||||
: '<tbody><tr><td class="hint">Nichts zum Aufräumen gefunden (oder noch nicht gemessen).</td></tr></tbody>'
|
||||
@@ -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 "<folder>\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 `
|
||||
<div class="pickrow">
|
||||
@@ -2116,7 +2135,7 @@ function cleanHtml(d) {
|
||||
body += rows.length
|
||||
? `<table class="cand">${rows.map((c) => `<tr>
|
||||
<td><input type="checkbox" class="candcb" data-path="${escapeHtml(c.Path)}" ${c.Skip ? 'disabled' : c.Tier === 'Cache' ? 'checked' : ''}></td>
|
||||
<td>${escapeHtml(inProject(c.Path))}</td>
|
||||
<td>${escapeHtml(inProject(c.Path, editing?.folder))}</td>
|
||||
<td><span class="chip ${TIER[c.Tier].cls}" title="${TIER[c.Tier].hint}">${ic(TIER[c.Tier].icon, 'sm')}${TIER[c.Tier].label}</span>${c.Skip ? ` <span class="chip bad">${ic('lock', 'sm')}in git</span>` : ''}</td>
|
||||
<td class="mb">${fmtMB(c.MB)}</td></tr>`).join('')}</table>
|
||||
<div class="hint">Cache ist vorausgewählt (immer neu erzeugbar). Fertige Builds und Rohbilder nur bewusst anhaken.</div>`
|
||||
@@ -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 = `<div class="hint">${ic('loader', 'sm')} Suche…</div>`
|
||||
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 = `<div class="hint">Fehler: ${escapeHtml(e.message)}</div>`
|
||||
}
|
||||
}
|
||||
|
||||
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 `<label class="nitem">
|
||||
<input type="checkbox" data-root="${escapeHtml(root.id)}" data-rel="${escapeHtml(x.rel)}" ${on ? 'checked' : ''}>
|
||||
<span class="nrel" title="${escapeHtml(root.path)}\\${escapeHtml(x.rel)}"><span class="hint" style="margin:0">${escapeHtml(parts.slice(0, -1).join('\\'))}\\</span><b>${escapeHtml(parts.at(-1))}</b></span>
|
||||
${x.markers.slice(0, 4).map((m) => `<span class="chip tech">${escapeHtml(m === '.NET-sln' ? '.NET' : m === 'dashboard' ? 'Dashboard' : m)}</span>`).join('')}
|
||||
${x.chosen ? '<span class="chip ok">übernommen</span>' : x.ignored ? '<span class="chip neutral">ausgelassen</span>' : '<span class="chip warn">neu</span>'}
|
||||
</label>`
|
||||
}
|
||||
const roots = nestData.roots ?? []
|
||||
const html = roots.map((r) => {
|
||||
const groups = r.containers.map((c) => `<div class="ngroup">
|
||||
<div class="nghead">${ic('folder', 'sm')}${escapeHtml(c.rel)}<span class="hint">Sammelordner · wird ausgeblendet, wenn etwas übernommen ist</span></div>
|
||||
${c.projects.map((x) => item(r, x, x.chosen || !x.ignored)).join('')}
|
||||
</div>`).join('')
|
||||
const inner = r.inProjects.length ? `<div class="ngroup">
|
||||
<div class="nghead">${ic('folder-git-2', 'sm')}In Projekten<span class="hint">meist Teil des Projekts – nur bei Bedarf ankreuzen</span></div>
|
||||
${r.inProjects.map((x) => item(r, x, x.chosen)).join('')}
|
||||
</div>` : ''
|
||||
const n = r.containers.reduce((a, c) => a + c.projects.length, 0) + r.inProjects.length
|
||||
return `<div class="nroot"><h4>${ic('folders')}${escapeHtml(r.name)} <span class="hint">${escapeHtml(r.path)} · ${n} gefunden</span></h4>
|
||||
${groups + inner || `<div class="hint">Keine Projekte in Unterordnern${nestDeep ? '' : ' (Sammelordner)'}.</div>`}</div>`
|
||||
}).join('')
|
||||
document.getElementById('nestBody').innerHTML = `
|
||||
<div class="hint" style="margin-top:12px">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.</div>
|
||||
${html || '<div class="hint">Keine Projektordner eingerichtet.</div>'}`
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
@@ -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 @@
|
||||
<div class="rowbtns">
|
||||
<button class="btn" id="fAddRoot" type="button"><svg class="i"><use href="/icons.svg#plus"/></svg>Ordner hinzufügen</button>
|
||||
<button class="btn" id="fImportOpen" type="button"><svg class="i"><use href="/icons.svg#folder-plus"/></svg>Mehrere einlesen…</button>
|
||||
<button class="btn" id="fNestedOpen" type="button" title="Projekte suchen, die eine Ebene tiefer liegen (z. B. in einem Sammelordner)"><svg class="i"><use href="/icons.svg#folder-tree"/></svg>Projekte in Unterordnern…</button>
|
||||
</div>
|
||||
<div class="importbox" id="fImport" hidden>
|
||||
<div class="hint" style="margin:0 0 6px">Übergeordneten Ordner wählen – seine Unterordner werden als Projektordner angeboten.</div>
|
||||
@@ -1121,6 +1139,21 @@
|
||||
<div id="itchBody"></div>
|
||||
</dialog>
|
||||
|
||||
<dialog id="nestDlg" class="dlg wide">
|
||||
<div class="ihead">
|
||||
<h3><svg class="i lg"><use href="/icons.svg#folder-tree"/></svg>Projekte in Unterordnern</h3>
|
||||
<span class="sp"></span>
|
||||
<button class="iconbtn" type="button" id="nestClose" title="Schließen (Esc)"><svg class="i"><use href="/icons.svg#x"/></svg></button>
|
||||
</div>
|
||||
<div id="nestBody"></div>
|
||||
<div class="nestfoot">
|
||||
<button class="btn" type="button" id="nestDeep" title="Auch in echten Projekten suchen, z. B. PowerBackupPro_CleanTools…"><svg class="i"><use href="/icons.svg#scan-search"/></svg>Auch in Projekten suchen</button>
|
||||
<span class="sp"></span>
|
||||
<button class="btn" type="button" id="nestCancel">Abbrechen</button>
|
||||
<button class="btn primary" type="button" id="nestOk"><svg class="i"><use href="/icons.svg#check"/></svg>Übernehmen</button>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<div id="toast"></div>
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user