From dfd357ee91c3086462ed7a9bceb1881edce1450b Mon Sep 17 00:00:00 2001 From: duffyduck Date: Mon, 6 Jul 2026 21:28:18 +0200 Subject: [PATCH] feat(diagnostic): Datei einem Projekt zuordnen im Datei-Manager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Der /api/files-set-project-Endpoint existierte, aber es fehlte die UI. Jede Datei-Zeile hat jetzt ein Projekt-Dropdown (Hauptchat + alle Projekte, aktueller Wert vorausgewaehlt, gruen wenn getaggt). Aenderung schreibt via /api/files-set-project ins Manifest, aktualisiert den lokalen Cache und rendert neu (respektiert den aktiven Projekt-Filter). Damit lassen sich auch alt-hochgeladene (untagged) Dateien nachtraeglich einem Projekt zuordnen — die projectId-Zuordnung beim Upload passiert automatisch (596d0bb), das hier ist die manuelle Korrektur/Nachpflege. Co-Authored-By: Claude Opus 4.8 (1M context) --- diagnostic/index.html | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/diagnostic/index.html b/diagnostic/index.html index 7ddf498..15ea631 100644 --- a/diagnostic/index.html +++ b/diagnostic/index.html @@ -4328,6 +4328,7 @@ // ── Datei-Manager ────────────────────────────────────── let filesCache = []; + let diagFileProjectsList = []; // [{id, name}] fuer das Zuordnungs-Dropdown pro Datei const filesSelected = new Set(); // Set of paths async function loadFiles() { @@ -4345,6 +4346,8 @@ const pr = await fetch('/api/brain/projects/list?include_archived=true'); const pdata = await pr.json(); const projects = pdata?.projects || []; + // Fuer das Pro-Datei-Zuordnungs-Dropdown merken. + diagFileProjectsList = projects.map(p => ({ id: p.id, name: p.name })); const sel = document.getElementById('files-filter-project'); if (sel) { const current = sel.value; @@ -4439,12 +4442,25 @@ : 'User'; const checked = filesSelected.has(f.path) ? 'checked' : ''; const pathEsc = escapeHtml(f.path); + const curPid = f.projectId || ''; + // Pro-Datei Projekt-Zuordnung: Hauptchat ('') + alle Projekte. Auch + // eine unbekannte (geloeschtes Projekt) ID als Option behalten, damit + // der aktuelle Wert nicht still verlorengeht. + const projOpts = [{ id: '', name: '💬 Hauptchat' }, ...diagFileProjectsList]; + if (curPid && !projOpts.some(p => p.id === curPid)) { + projOpts.push({ id: curPid, name: `📁 ${curPid} (gelöscht?)` }); + } + const projSelect = ``; return `
${badge}${escapeHtml(f.name)}
${fmtSize(f.size)} · ${fmtDate(f.mtime)}
+ ${projSelect} @@ -4453,6 +4469,27 @@ }).join(''); } + // Datei einem Projekt zuordnen (oder leer = Hauptchat). Schreibt ins + // Manifest via /api/files-set-project, aktualisiert den lokalen Cache und + // rendert neu (respektiert den aktiven Projekt-Filter). + async function assignFileProject(path, projectId) { + try { + const r = await fetch('/api/files-set-project', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ path, projectId: projectId || '' }), + }); + const d = await r.json(); + if (!d.ok) throw new Error(d.error || 'Fehler'); + const f = filesCache.find(x => x.path === path); + if (f) f.projectId = projectId || ''; + renderFilesList(); + } catch (e) { + alert('Zuordnung fehlgeschlagen: ' + e.message); + renderFilesList(); // Dropdown auf alten Wert zuruecksetzen + } + } + // ── Versions-Modal ────────────────────────────────────── async function showVersions(fileName) { // path-relative-to-/shared/uploads ist hier == fileName, weil unser