chore: Änderungen commited

This commit is contained in:
2025-05-11 00:04:49 +02:00
parent 6f5526b648
commit 59b79b3466
3 changed files with 546 additions and 194 deletions

146
app.py
View File

@@ -2476,10 +2476,148 @@ def get_mindmap_data(node_id):
"""
Stellt Mindmap-Daten für das Frontend bereit.
Liefert für 'root' die Hauptebene und für andere Node-IDs die entsprechenden Unterknoten.
Daten werden aus der Datenbank abgerufen.
"""
app.logger.info(f"Mindmap-Daten werden für Node '{node_id}' angefordert.")
try:
# Fallback-Daten falls Datenbankzugriff fehlschlägt
fallback_data = get_fallback_mindmap_data(node_id)
if node_id == 'root':
# Hauptebene der Mindmap - finde den "Wissen"-Knoten und seine Verbindungen
wissen_node = MindMapNode.query.filter_by(name="Wissen").first()
if not wissen_node:
app.logger.warning("'Wissen'-Knoten nicht in der Datenbank gefunden, Fallback zu Hardcoded-Daten.")
return jsonify(fallback_data)
# Zentrum der Mindmap ist der "Wissen"-Knoten
nodes = [{
"id": str(wissen_node.id),
"name": "Wissenskarte", # Frontend-Name für Root-Knoten
"description": wissen_node.description or "Zentrale Wissenskarte mit allen Hauptthemen",
"is_center": True,
"color_code": "#f5f5f5",
"has_children": True
}]
# Hauptkategorien als Knoten
main_categories = Category.query.filter_by(parent_id=None).all()
category_nodes = []
edges = []
for category in main_categories:
category_node = {
"id": f"cat_{category.id}",
"name": category.name,
"description": category.description or f"Kategorie: {category.name}",
"category": category.name,
"has_children": True,
"color_code": category.color_code or "#9F7AEA"
}
category_nodes.append(category_node)
# Verbindung vom Wissen-Knoten zur Kategorie
edges.append({
"source_id": str(wissen_node.id),
"target_id": f"cat_{category.id}",
"strength": 0.9
})
nodes.extend(category_nodes)
response = {
"nodes": nodes,
"edges": edges
}
app.logger.info(f"Mindmap-Daten für 'root' erfolgreich aus Datenbank geladen. {len(nodes)} Knoten gefunden.")
return jsonify(response)
elif node_id.startswith('cat_'):
# Unterkategorien einer Hauptkategorie anzeigen
category_id = node_id.replace('cat_', '')
try:
category_id = int(category_id)
category = Category.query.get(category_id)
if not category:
app.logger.warning(f"Kategorie mit ID {category_id} nicht gefunden.")
return jsonify(fallback_data)
nodes = []
edges = []
# Unterkategorien dieser Kategorie
subcategories = Category.query.filter_by(parent_id=category_id).all()
for subcat in subcategories:
subcat_node = {
"id": f"subcat_{subcat.id}",
"name": subcat.name,
"description": subcat.description or f"Unterkategorie: {subcat.name}",
"category": category.name,
"has_children": True,
"color_code": subcat.color_code or category.color_code
}
nodes.append(subcat_node)
# Verbindung von der Hauptkategorie zur Unterkategorie
edges.append({
"source_id": node_id,
"target_id": f"subcat_{subcat.id}",
"strength": 0.8
})
# Wenn es keine Unterkategorien gibt, zeige verwandte Knoten
if not subcategories:
# Im Fallback-Modus zurückfallen
app.logger.info(f"Keine Unterkategorien für Kategorie {category.name} gefunden, verwende Fallback-Daten.")
return jsonify(fallback_data)
response = {
"nodes": nodes,
"edges": edges
}
return jsonify(response)
except (ValueError, TypeError):
app.logger.error(f"Ungültige Kategorie-ID: {category_id}")
return jsonify(fallback_data)
else:
# Versuche, einen MindMapNode mit der gegebenen ID zu finden
try:
node_id_int = int(node_id)
node = MindMapNode.query.get(node_id_int)
if node:
# Zeige Gedanken oder verwandte Knoten
# Hier würden wir verwandte Knoten aus der Datenbank laden
# Für den Moment verwenden wir Fallback-Daten
app.logger.info(f"Knoten {node.name} gefunden, aber keine spezifische Verarbeitung implementiert.")
return jsonify(fallback_data)
except (ValueError, TypeError):
# Wenn die ID kein Integer ist, verwende das bisherige Verhalten
app.logger.info(f"Falle auf bisheriges Verhalten für Node ID '{node_id}' zurück.")
return jsonify(fallback_data)
# Wenn wir hier ankommen, gibt es keine spezifische Verarbeitung für diese node_id
return jsonify(fallback_data)
except Exception as e:
app.logger.error(f"Fehler beim Abrufen der Mindmap-Daten: {str(e)}")
app.logger.error(f"Stack Trace: {traceback.format_exc()}")
return jsonify({"error": "Fehler beim Abrufen der Mindmap-Daten"}), 500
def get_fallback_mindmap_data(node_id):
"""
Liefert Fallback-Daten für die Mindmap, wenn die Datenbank nicht verfügbar ist.
"""
if node_id == 'root':
# Hauptebene der Mindmap
nodes = [
@@ -2674,13 +2812,7 @@ def get_mindmap_data(node_id):
edges = []
# Antwort zusammenstellen
response = {
return {
"nodes": nodes,
"edges": edges
}
return jsonify(response)
except Exception as e:
app.logger.error(f"Fehler beim Abrufen der Mindmap-Daten: {str(e)}")
return jsonify({"error": "Fehler beim Abrufen der Mindmap-Daten"}), 500

38
check_db.py Normal file
View File

@@ -0,0 +1,38 @@
import sqlite3
def check_mindmap_nodes():
try:
conn = sqlite3.connect('database/systades.db')
cursor = conn.cursor()
# Check if the table exists
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='mind_map_node';")
table_exists = cursor.fetchone()
if not table_exists:
print("Die Tabelle 'mind_map_node' existiert nicht!")
return
# Check for the "Wissen" node
cursor.execute("SELECT * FROM mind_map_node WHERE name = 'Wissen';")
wissen_node = cursor.fetchone()
if wissen_node:
print(f"'Wissen'-Knoten gefunden: {wissen_node}")
else:
print("'Wissen'-Knoten NICHT gefunden!")
# Get all nodes
cursor.execute("SELECT id, name FROM mind_map_node LIMIT 10;")
nodes = cursor.fetchall()
print(f"\nVorhandene Knoten (max. 10):")
for node in nodes:
print(f" - {node}")
conn.close()
except Exception as e:
print(f"Fehler: {e}")
if __name__ == "__main__":
check_mindmap_nodes()

View File

@@ -817,3 +817,185 @@ Traceback (most recent call last):
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\TTOMCZA.EMEA\Dev\website\app.py:92]
2025-05-10 23:58:51,812 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: /api/mindmap/root, Method: GET, IP: 127.0.0.1
Nicht angemeldet
Traceback (most recent call last):
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1788, in dispatch_request
self.raise_routing_exception(req)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1770, in raise_routing_exception
raise request.routing_exception # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\ctx.py", line 351, in match_request
result = self.url_adapter.match(return_rule=True) # type: ignore
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\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\TTOMCZA.EMEA\Dev\website\app.py:92]
2025-05-10 23:58:51,812 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: /api/mindmap/root, Method: GET, IP: 127.0.0.1
Nicht angemeldet
Traceback (most recent call last):
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1788, in dispatch_request
self.raise_routing_exception(req)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1770, in raise_routing_exception
raise request.routing_exception # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\ctx.py", line 351, in match_request
result = self.url_adapter.match(return_rule=True) # type: ignore
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\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\TTOMCZA.EMEA\Dev\website\app.py:92]
2025-05-11 00:00:37,845 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: /api/mindmap/root, Method: GET, IP: 127.0.0.1
User: 1 (admin)
Traceback (most recent call last):
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1788, in dispatch_request
self.raise_routing_exception(req)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1770, in raise_routing_exception
raise request.routing_exception # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\ctx.py", line 351, in match_request
result = self.url_adapter.match(return_rule=True) # type: ignore
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\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\TTOMCZA.EMEA\Dev\website\app.py:92]
2025-05-11 00:00:37,845 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: /api/mindmap/root, Method: GET, IP: 127.0.0.1
User: 1 (admin)
Traceback (most recent call last):
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1788, in dispatch_request
self.raise_routing_exception(req)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1770, in raise_routing_exception
raise request.routing_exception # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\ctx.py", line 351, in match_request
result = self.url_adapter.match(return_rule=True) # type: ignore
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\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\TTOMCZA.EMEA\Dev\website\app.py:92]
2025-05-11 00:00:39,147 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: /api/mindmap/technology, Method: GET, IP: 127.0.0.1
User: 1 (admin)
Traceback (most recent call last):
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1788, in dispatch_request
self.raise_routing_exception(req)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1770, in raise_routing_exception
raise request.routing_exception # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\ctx.py", line 351, in match_request
result = self.url_adapter.match(return_rule=True) # type: ignore
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\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\TTOMCZA.EMEA\Dev\website\app.py:92]
2025-05-11 00:00:39,147 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: /api/mindmap/technology, Method: GET, IP: 127.0.0.1
User: 1 (admin)
Traceback (most recent call last):
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1788, in dispatch_request
self.raise_routing_exception(req)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1770, in raise_routing_exception
raise request.routing_exception # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\ctx.py", line 351, in match_request
result = self.url_adapter.match(return_rule=True) # type: ignore
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\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\TTOMCZA.EMEA\Dev\website\app.py:92]
2025-05-11 00:01:46,130 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: /api/mindmap/root, Method: GET, IP: 127.0.0.1
Nicht angemeldet
Traceback (most recent call last):
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1788, in dispatch_request
self.raise_routing_exception(req)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1770, in raise_routing_exception
raise request.routing_exception # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\ctx.py", line 351, in match_request
result = self.url_adapter.match(return_rule=True) # type: ignore
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\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\TTOMCZA.EMEA\Dev\website\app.py:92]
2025-05-11 00:01:46,130 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: /api/mindmap/root, Method: GET, IP: 127.0.0.1
Nicht angemeldet
Traceback (most recent call last):
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1788, in dispatch_request
self.raise_routing_exception(req)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1770, in raise_routing_exception
raise request.routing_exception # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\ctx.py", line 351, in match_request
result = self.url_adapter.match(return_rule=True) # type: ignore
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\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\TTOMCZA.EMEA\Dev\website\app.py:92]
2025-05-11 00:01:46,159 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: /favicon.ico, Method: GET, IP: 127.0.0.1
Nicht angemeldet
Traceback (most recent call last):
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1788, in dispatch_request
self.raise_routing_exception(req)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1770, in raise_routing_exception
raise request.routing_exception # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\ctx.py", line 351, in match_request
result = self.url_adapter.match(return_rule=True) # type: ignore
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\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\TTOMCZA.EMEA\Dev\website\app.py:92]
2025-05-11 00:01:46,159 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: /favicon.ico, Method: GET, IP: 127.0.0.1
Nicht angemeldet
Traceback (most recent call last):
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1788, in dispatch_request
self.raise_routing_exception(req)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\app.py", line 1770, in raise_routing_exception
raise request.routing_exception # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\site-packages\flask\ctx.py", line 351, in match_request
result = self.url_adapter.match(return_rule=True) # type: ignore
File "C:\Users\TTOMCZA.EMEA\AppData\Roaming\Python\Python313\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\TTOMCZA.EMEA\Dev\website\app.py:92]
2025-05-11 00:02:53,829 INFO: Anwendung gestartet [in C:\Users\TTOMCZA.EMEA\Dev\website\app.py:76]
2025-05-11 00:02:53,875 INFO: Anwendung gestartet [in C:\Users\TTOMCZA.EMEA\Dev\website\app.py:76]