Compare commits

...

2 Commits

Author SHA1 Message Date
fc8861c73c wir haben unterkategorien 2025-05-16 20:14:51 +01:00
8c49e7396e feat: enhance mindmap update functionality in update_mindmap.js 2025-05-16 20:04:36 +01:00
4 changed files with 354 additions and 4 deletions

Binary file not shown.

61
app.py
View File

@@ -2134,14 +2134,14 @@ def get_root_mindmap_data():
print(f"Gefundene Hauptkategorien: {[cat.name for cat in categories]}")
# Basis-Knoten erstellen
# Basis-Knoten erstellen (ohne has_children gesetzt, da Wissen selbst keine Unterkategorien haben soll)
nodes = [{
'id': 'root',
'name': 'Wissen',
'description': 'Zentrale Wissensbasis',
'color_code': '#4299E1',
'is_center': True,
'has_children': bool(categories),
'has_children': False, # Geändert, damit "Wissen" selbst keine Unterkategorien hat
'icon': 'fa-solid fa-circle'
}]
@@ -2153,7 +2153,7 @@ def get_root_mindmap_data():
'description': category.description or '',
'color_code': category.color_code or '#9F7AEA',
'category': category.name,
'has_children': bool(len(category.children) > 0),
'has_children': bool(len(category.children) > 0), # Diese Kategorien haben Unterkategorien
'icon': category.icon or 'fa-solid fa-circle'
})
@@ -2207,7 +2207,62 @@ def get_mindmap_data(node_id):
'error': 'Ungültige Knoten-ID',
'details': 'Diese ID ist für spezielle Routen reserviert'
}), 400
# Prüfen, ob es sich um eine Kategorie-ID handelt (Format: cat_X)
if node_id.startswith('cat_'):
category_id = None
try:
category_id = int(node_id.split('_')[1])
except (IndexError, ValueError) as e:
print(f"Fehler beim Parsen der Kategorie-ID '{node_id}': {str(e)}")
return jsonify({
'success': False,
'error': 'Ungültige Kategorie-ID',
'details': f"Die ID '{node_id}' konnte nicht als Kategorie identifiziert werden"
}), 400
# Kategorie mit Unterkategorien laden
category = Category.query.options(
joinedload(Category.children)
).get_or_404(category_id)
# Basis-Knoten erstellen
nodes = [{
'id': f'cat_{category.id}',
'name': category.name,
'description': category.description or '',
'color_code': category.color_code or '#9F7AEA',
'is_center': True,
'has_children': bool(category.children),
'icon': category.icon or 'fa-solid fa-circle'
}]
# Unterkategorien hinzufügen
for subcat in category.children:
nodes.append({
'id': f'cat_{subcat.id}',
'name': subcat.name,
'description': subcat.description or '',
'color_code': subcat.color_code or '#9F7AEA',
'category': category.name,
'has_children': bool(subcat.children),
'icon': subcat.icon or 'fa-solid fa-circle'
})
# Kanten erstellen (vereinheitlichte Schlüssel)
edges = [{
'source': f'cat_{category.id}',
'target': f'cat_{subcat.id}',
'strength': 0.8
} for subcat in category.children]
return jsonify({
'success': True,
'nodes': nodes,
'edges': edges
})
# Sonst: Normale Knoten-ID
# Knoten mit Unterknoten in einer Abfrage laden
node = MindMapNode.query.options(
joinedload(MindMapNode.children)

View File

@@ -461,3 +461,69 @@ werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on
2025-05-16 14:04:28,258 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 14:04:29,923 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 14:04:29,923 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:05:10,551 ERROR: Fehler 404: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
Endpoint: /.well-known/appspecific/com.chrome.devtools.json, Method: GET, IP: 127.0.0.1
Nicht angemeldet
Traceback (most recent call last):
File "C:\Users\firem\Desktop\111\Systades\website\.venv\Lib\site-packages\flask\app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\firem\Desktop\111\Systades\website\.venv\Lib\site-packages\flask\app.py", line 1788, in dispatch_request
self.raise_routing_exception(req)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "C:\Users\firem\Desktop\111\Systades\website\.venv\Lib\site-packages\flask\app.py", line 1770, in raise_routing_exception
raise request.routing_exception # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\firem\Desktop\111\Systades\website\.venv\Lib\site-packages\flask\ctx.py", line 351, in match_request
result = self.url_adapter.match(return_rule=True) # type: ignore
File "C:\Users\firem\Desktop\111\Systades\website\.venv\Lib\site-packages\werkzeug\routing\map.py", line 624, in match
raise NotFound() from None
werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
[in C:\Users\firem\Desktop\111\Systades\website\app.py:93]
2025-05-16 20:05:10,551 ERROR: Fehler 404: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
Endpoint: /.well-known/appspecific/com.chrome.devtools.json, Method: GET, IP: 127.0.0.1
Nicht angemeldet
Traceback (most recent call last):
File "C:\Users\firem\Desktop\111\Systades\website\.venv\Lib\site-packages\flask\app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\firem\Desktop\111\Systades\website\.venv\Lib\site-packages\flask\app.py", line 1788, in dispatch_request
self.raise_routing_exception(req)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "C:\Users\firem\Desktop\111\Systades\website\.venv\Lib\site-packages\flask\app.py", line 1770, in raise_routing_exception
raise request.routing_exception # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\firem\Desktop\111\Systades\website\.venv\Lib\site-packages\flask\ctx.py", line 351, in match_request
result = self.url_adapter.match(return_rule=True) # type: ignore
File "C:\Users\firem\Desktop\111\Systades\website\.venv\Lib\site-packages\werkzeug\routing\map.py", line 624, in match
raise NotFound() from None
werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
[in C:\Users\firem\Desktop\111\Systades\website\app.py:93]
2025-05-16 20:05:50,467 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:05:53,368 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:05:53,368 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:06:06,574 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:06:08,460 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:06:08,460 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:12:23,356 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:12:23,363 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:12:26,797 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:12:26,797 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:12:27,029 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:12:27,029 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:12:57,838 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:12:59,652 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:13:02,105 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:13:02,105 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:13:03,187 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:13:03,187 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:13:43,823 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:13:44,945 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:13:46,112 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:13:46,112 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:13:47,360 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:13:47,360 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:14:18,044 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:14:20,092 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:14:20,092 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:14:28,029 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:14:30,609 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]
2025-05-16 20:14:30,609 INFO: Anwendung gestartet [in C:\Users\firem\Desktop\111\Systades\website\app.py:77]

View File

@@ -1755,4 +1755,233 @@ editingStyles.textContent = `
opacity: 0.8;
}
`;
document.head.appendChild(editingStyles);
document.head.appendChild(editingStyles);
// CSS-Styles für die Unterkategorien-Seite
(function() {
const style = document.createElement('style');
style.textContent = `
.mindmap-page {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(135deg, #1a1f2e 0%, #0f172a 100%);
z-index: 1000;
display: flex;
flex-direction: column;
}
.mindmap-page .mindmap-header {
position: relative;
display: flex;
align-items: center;
padding: 1rem;
background: rgba(15, 23, 42, 0.8);
backdrop-filter: blur(10px);
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
z-index: 10;
height: 64px;
}
.mindmap-page .back-button {
background: none;
border: none;
color: #fff;
cursor: pointer;
padding: 0.5rem;
margin-right: 1rem;
border-radius: 50%;
transition: background-color 0.3s;
display: flex;
align-items: center;
justify-content: center;
width: 36px;
height: 36px;
}
.mindmap-page .back-button:hover {
background: rgba(255, 255, 255, 0.1);
}
.mindmap-page .back-button svg {
width: 20px;
height: 20px;
}
.mindmap-page .mindmap-title {
color: #fff;
font-size: 1.5rem;
font-weight: 600;
margin: 0;
background: linear-gradient(90deg, #60a5fa, #8b5cf6);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.mindmap-view {
width: 100%;
height: calc(100% - 64px);
position: relative;
}
/* Fix für den Cytoscape Container */
.mindmap-view > div {
width: 100%;
height: 100%;
background: transparent;
position: absolute;
top: 0;
left: 0;
}
`;
document.head.appendChild(style);
})();
// Funktion zum Laden der Subthemen
async function loadSubthemes(node) {
try {
const mindmapData = await loadMindmapData(node.id());
if (!mindmapData) return;
showUINotification('Lade Subthemen...', 'info');
// Finde den Container
const mindmapContainer = document.querySelector('.mindmap-container');
if (!mindmapContainer) {
console.error('Mindmap-Container nicht gefunden');
showUINotification('Fehler: Mindmap-Container nicht gefunden', 'error');
return;
}
// Erstelle eine neue Seite für die Unterkategorien
const newPage = document.createElement('div');
newPage.className = 'mindmap-page';
newPage.style.display = 'none';
const header = document.createElement('div');
header.className = 'mindmap-header';
header.innerHTML = `
<button class="back-button" onclick="window.goBack()">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M19 12H5M12 19l-7-7 7-7"/>
</svg>
</button>
<h2 class="mindmap-title">${node.data('label')}</h2>
`;
const newContainer = document.createElement('div');
newContainer.id = `cy-${node.id()}`;
newContainer.className = 'mindmap-view';
// Füge die Elemente zur DOM-Struktur hinzu
newPage.appendChild(header);
newPage.appendChild(newContainer);
mindmapContainer.appendChild(newPage);
// Warte, bis der DOM aktualisiert ist
await new Promise(resolve => setTimeout(resolve, 50));
// Speichere die Cytoscape-Instanz für eventuelle Referenzen
if (!window.subthemeCyInstances) {
window.subthemeCyInstances = {};
}
// Überprüfe, ob der Container jetzt im DOM existiert
const containerElement = document.getElementById(`cy-${node.id()}`);
if (!containerElement) {
console.error(`Container #cy-${node.id()} nicht gefunden`);
showUINotification(`Fehler: Container #cy-${node.id()} nicht gefunden`, 'error');
return;
}
// Erstelle die Cytoscape-Instanz
const newCy = cytoscape({
container: containerElement,
elements: [
...mindmapData.nodes.map(node => ({
data: {
id: node.id,
label: node.name,
category: node.category,
description: node.description,
hasChildren: node.has_children,
expanded: false,
color: node.color_code,
fontColor: '#ffffff',
fontSize: 16
}
})),
...mindmapData.edges.map(edge => ({
data: {
source: edge.source,
target: edge.target,
strength: edge.strength || 0.5
}
}))
],
style: cy.style(),
layout: mindmapStyles.layout.base
});
// Speichere die Cytoscape-Instanz
window.subthemeCyInstances[node.id()] = newCy;
// Event-Listener für die neue Mindmap
newCy.on('tap', 'node', async function(evt) {
const clickedNode = evt.target;
if (clickedNode.data('hasChildren') && !clickedNode.data('expanded')) {
await loadSubthemes(clickedNode);
}
});
// Alte Seite ausblenden und neue anzeigen
cy.container().style.display = 'none';
newPage.style.display = 'block';
// Wende neuronales Design auf die neue Mindmap an
applyNeuralNetworkStyle(newCy);
showUINotification('Subthemen erfolgreich geladen', 'success');
} catch (error) {
console.error('Fehler beim Laden der Subthemen:', error);
showUINotification('Fehler beim Laden der Subthemen: ' + error.message, 'error');
}
}
// Funktion zum Zurücknavigieren
function goBack() {
try {
console.log('goBack Funktion aufgerufen');
const currentPage = document.querySelector('.mindmap-page:not([style*="display: none"])');
if (currentPage) {
console.log('Aktuelle Seite gefunden:', currentPage);
currentPage.style.display = 'none';
// Stelle sicher, dass die Haupt-Cytoscape-Instanz existiert
if (window.cy && window.cy.container()) {
console.log('Zeige Haupt-Cytoscape-Container an');
window.cy.container().style.display = 'block';
// Aktualisiere das Layout
setTimeout(() => {
window.cy.resize();
window.cy.fit();
}, 100);
} else {
console.error('Haupt-Cytoscape-Instanz oder Container nicht gefunden');
showUINotification('Fehler: Hauptmindmap konnte nicht angezeigt werden', 'error');
}
} else {
console.warn('Keine aktuelle Unterseite gefunden');
}
} catch (error) {
console.error('Fehler in goBack Funktion:', error);
showUINotification('Fehler beim Zurücknavigieren: ' + error.message, 'error');
}
}
// Funktion global verfügbar machen
window.goBack = goBack;