Files
Mind-o-Mat/webapp/src/App.tsx
T
Jannik fb810b1e7b v1.0: Phase 3 abgeschlossen + Spec/Plan v1.0/v0.2
Phase 3.2 Radialer Baum (Webapp Tab 3):
- webapp/src/RadialView.tsx: Cytoscape concentric-Layout
- Anker-Notiz in der Mitte, verlinkte Notizen in Ringen
- Auswahl der Anker-Notiz via Klick im Graph oder Cluster-Tab
- Header-Tabs erweitert: Graph | Cluster-Karte | Radial
- App.tsx: view-Mode-State erweitert um 'radial'

Phase 1+2+3 abgeschlossen (siehe Status-Bloecke).

SPEC v1.0:
- Header: v1.0 mit Stand und Status-Block
- Neue Sektion 'Status-Uebersicht' direkt nach Header
- § 3 erweitert: kein deterministischer Konflikt-Vorab-Check (offen)
- § 13.2: 'Phase 3 fertig' markiert
- § 17 'Offene Punkte' aktualisiert: geloeste Items durchgestrichen, Phase-2.4-d (deterministisch) + 2.5e (Embedding) als Phase-2-erweitert, Phase 4+5 als ausstehend

Plan v0.2:
- Header: v0.2 mit Stand und Status-Block
- Status-Tabelle fuer alle 5 Phasen

Verifiziert:
- 28/28 Unit-Tests gruen
- Webapp-Build (35 Module, 595 KB, 2.35s)
- E2E-Pipeline: Inbox -> Ingest -> Wiki (mit --mock), Indexer deterministisch, Sync zu gitea funktioniert
2026-09-05 12:00:40 +02:00

231 lines
7.7 KiB
TypeScript

import { useEffect, useRef, useState } from 'react';
import cytoscape, { Core, ElementDefinition } from 'cytoscape';
import { loadLandkarte, Landkarte, VaultNode } from './landkarte';
import { loadNoteContent } from './note-loader';
import ClusterMap from './ClusterMap';
import RadialView from './RadialView';
const TYPE_COLORS: Record<string, string> = {
inbox: '#5B8FF9',
daily: '#5AD8A6',
wiki: '#F6BD16',
project: '#E8684A',
unknown: '#999999',
};
type ViewMode = 'graph' | 'cluster' | 'radial';
export default function App() {
const containerRef = useRef<HTMLDivElement>(null);
const cyRef = useRef<Core | null>(null);
const [landkarte, setLandkarte] = useState<Landkarte | null>(null);
const [error, setError] = useState<string | null>(null);
const [selected, setSelected] = useState<VaultNode | null>(null);
const [noteContent, setNoteContent] = useState<string | null>(null);
const [view, setView] = useState<ViewMode>('graph');
useEffect(() => {
loadLandkarte()
.then(setLandkarte)
.catch((e) => setError(e.message));
}, []);
useEffect(() => {
if (view !== 'graph' || !landkarte || !containerRef.current) return;
const elements: ElementDefinition[] = [
...landkarte.nodes.map((n) => ({
data: { id: n.id, label: n.title, type: n.type, node: n },
})),
...landkarte.edges.map((e, i) => ({
data: { id: `e${i}`, source: e.from, target: e.to },
})),
];
if (cyRef.current) {
cyRef.current.destroy();
}
cyRef.current = cytoscape({
container: containerRef.current,
elements,
style: [
{
selector: 'node',
style: {
'background-color': (ele: cytoscape.NodeSingular) => TYPE_COLORS[ele.data('type')] ?? '#999',
'label': 'data(label)',
'font-size': '10px',
'text-valign': 'bottom',
'text-halign': 'center',
'text-margin-y': 4,
'width': 24,
'height': 24,
'border-width': 1,
'border-color': '#333',
},
},
{
selector: 'edge',
style: {
'width': 1,
'line-color': '#ccc',
'curve-style': 'bezier',
'target-arrow-shape': 'none',
},
},
{
selector: 'node:selected',
style: {
'background-color': '#FFD700',
'border-width': 3,
'border-color': '#000',
},
},
],
layout: {
name: 'cose',
animate: false,
randomize: true,
padding: 30,
},
});
cyRef.current.on('tap', 'node', async (evt) => {
const node = evt.target.data('node') as VaultNode;
setSelected(node);
setNoteContent(null);
try {
const content = await loadNoteContent(node.id);
setNoteContent(content);
} catch {
setNoteContent('(Inhalt konnte nicht geladen werden)');
}
});
cyRef.current.on('tap', (evt) => {
if (evt.target === cyRef.current) {
setSelected(null);
setNoteContent(null);
}
});
return () => {
cyRef.current?.destroy();
cyRef.current = null;
};
}, [landkarte, view]);
return (
<div style={{ display: 'flex', flexDirection: 'column', height: '100vh', fontFamily: 'sans-serif' }}>
<header style={{
display: 'flex',
alignItems: 'center',
gap: 16,
padding: '8px 16px',
background: '#222',
color: '#fff',
}}>
<h2 style={{ margin: 0, fontSize: 16 }}>Mind-o-Mat</h2>
<nav style={{ display: 'flex', gap: 4 }}>
<button onClick={() => setView('graph')} style={tabStyle(view === 'graph')}>Graph</button>
<button onClick={() => setView('cluster')} style={tabStyle(view === 'cluster')}>Cluster-Karte</button>
<button onClick={() => setView('radial')} style={tabStyle(view === 'radial')}>Radial</button>
</nav>
{landkarte && (
<span style={{ marginLeft: 'auto', fontSize: 12, color: '#aaa' }}>
{landkarte.nodes.length} Notizen, {landkarte.edges.length} Wikilinks
</span>
)}
</header>
<div style={{ display: 'flex', flex: 1, overflow: 'hidden' }}>
<div style={{ flex: 1, overflow: 'hidden' }}>
{view === 'graph' ? (
<div ref={containerRef} style={{ width: '100%', height: '100%', background: '#fafafa' }} />
) : view === 'cluster' && landkarte ? (
<ClusterMap landkarte={landkarte} onSelect={setSelected} />
) : view === 'radial' && landkarte ? (
<RadialView landkarte={landkarte} anchor={selected} onSelect={setSelected} />
) : (
<div style={{ padding: 16 }}>Lade...</div>
)}
</div>
<aside style={{ width: 360, padding: 16, borderLeft: '1px solid #ccc', overflowY: 'auto', background: '#fafafa' }}>
{error && <p style={{ color: 'red' }}>Fehler: {error}</p>}
{selected && (
<div style={{ marginTop: 16, padding: 12, background: '#f5f5f5', borderRadius: 4 }}>
<h3 style={{ margin: '0 0 8px 0' }}>{selected.title}</h3>
<dl style={{ fontSize: 12, margin: 0 }}>
<dt><b>ID:</b></dt><dd style={{ fontFamily: 'monospace', fontSize: 11 }}>{selected.id}</dd>
<dt><b>Typ:</b></dt><dd>{selected.type}</dd>
{selected.cluster && (<><dt><b>Cluster:</b></dt><dd>{selected.cluster}</dd></>)}
{selected.status && (<><dt><b>Status:</b></dt><dd>{selected.status}</dd></>)}
{selected.created && (<><dt><b>Created:</b></dt><dd>{selected.created}</dd></>)}
{selected.aktualisiert && (<><dt><b>Aktualisiert:</b></dt><dd>{selected.aktualisiert}</dd></>)}
{selected.tags.length > 0 && (
<><dt><b>Tags:</b></dt><dd>{selected.tags.join(', ')}</dd></>
)}
{selected.veraltet && <><dt><b>Status:</b></dt><dd style={{ color: '#c80' }}>⚠️ veraltet</dd></>}
</dl>
{noteContent && (
<details style={{ marginTop: 12 }}>
<summary style={{ cursor: 'pointer', fontSize: 12 }}>Vorschau (erste 500 Zeichen)</summary>
<pre style={{
fontSize: 11,
whiteSpace: 'pre-wrap',
background: '#fff',
padding: 8,
marginTop: 6,
borderRadius: 3,
maxHeight: 200,
overflow: 'auto',
}}>
{noteContent.slice(0, 500)}
{noteContent.length > 500 ? '...' : ''}
</pre>
</details>
)}
</div>
)}
<Legend />
</aside>
</div>
</div>
);
}
function tabStyle(active: boolean): React.CSSProperties {
return {
padding: '4px 12px',
background: active ? '#fff' : 'transparent',
color: active ? '#222' : '#aaa',
border: 'none',
borderRadius: 3,
cursor: 'pointer',
fontSize: 13,
fontFamily: 'inherit',
};
}
function Legend() {
return (
<div style={{ marginTop: 24, fontSize: 12 }}>
<h4 style={{ margin: '0 0 4px 0' }}>Legende</h4>
{Object.entries(TYPE_COLORS).map(([type, color]) => (
<div key={type} style={{ display: 'flex', alignItems: 'center', marginBottom: 2 }}>
<span style={{
display: 'inline-block',
width: 12,
height: 12,
background: color,
borderRadius: '50%',
marginRight: 6,
border: '1px solid #333',
}} />
{type}
</div>
))}
</div>
);
}