From 35b5f321d4798d13ee95eed062548f3c56f2b21e Mon Sep 17 00:00:00 2001 From: Till Tomczak Date: Wed, 14 May 2025 13:48:24 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20=C3=84nderungen=20commited?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/js/update_mindmap.js | 111 ++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/static/js/update_mindmap.js b/static/js/update_mindmap.js index 2541013..ba36af9 100644 --- a/static/js/update_mindmap.js +++ b/static/js/update_mindmap.js @@ -182,6 +182,117 @@ async function loadMindmapData(nodeId = null) { } } +/** + * Implementiert Zoomfunktionalität für die Mindmap + * @param {Object} cy - Cytoscape-Instanz + */ +function implementZoomFunctions(cy) { + if (!cy) { + console.error('Cytoscape-Instanz nicht gefunden!'); + return; + } + + // Vergrößern-Button + const zoomInButton = document.getElementById('zoomIn'); + if (zoomInButton) { + zoomInButton.addEventListener('click', function() { + cy.zoom(cy.zoom() * 1.2); + cy.center(); + showUINotification('Ansicht vergrößert', 'info', 1500); + }); + } + + // Verkleinern-Button + const zoomOutButton = document.getElementById('zoomOut'); + if (zoomOutButton) { + zoomOutButton.addEventListener('click', function() { + cy.zoom(cy.zoom() * 0.8); + cy.center(); + showUINotification('Ansicht verkleinert', 'info', 1500); + }); + } + + // Zurücksetzen-Button + const resetViewButton = document.getElementById('resetView'); + if (resetViewButton) { + resetViewButton.addEventListener('click', function() { + cy.fit(); + cy.center(); + showUINotification('Ansicht zurückgesetzt', 'info', 1500); + }); + } + + // Legende-Button + const toggleLegendButton = document.getElementById('toggleLegend'); + const categoryLegend = document.getElementById('categoryLegend'); + + if (toggleLegendButton && categoryLegend) { + toggleLegendButton.addEventListener('click', function() { + if (categoryLegend.style.display === 'none') { + categoryLegend.style.display = 'flex'; + showUINotification('Legende angezeigt', 'info', 1500); + } else { + categoryLegend.style.display = 'none'; + showUINotification('Legende ausgeblendet', 'info', 1500); + } + }); + } +} + +/** + * Funktion zum Starten der Mindmap-Anwendung + */ +async function startMindmapApp() { + try { + const loader = document.getElementById('loader'); + const statusMessage = document.getElementById('statusMessage'); + const cyContainer = document.getElementById('cy'); + + if (!cyContainer) { + throw new Error('Cytoscape-Container nicht gefunden'); + } + + // Anzeigen der Ladeanzeige + if (loader) loader.style.display = 'block'; + if (statusMessage) { + statusMessage.textContent = 'Lade Mindmap...'; + statusMessage.style.display = 'block'; + } + + // Initialisieren der Mindmap + const cy = await initializeMindmap(); + window.cy = cy; // Speichern für globalen Zugriff + + // Zoom-Funktionen und Legendensteuerung implementieren + implementZoomFunctions(cy); + + // Verstecken der Ladeanzeige + if (loader) loader.style.display = 'none'; + if (statusMessage) statusMessage.style.display = 'none'; + + return cy; + } catch (error) { + console.error('Fehler beim Starten der Mindmap-Anwendung:', error); + const statusMessage = document.getElementById('statusMessage'); + + if (statusMessage) { + statusMessage.textContent = 'Fehler beim Laden der Mindmap: ' + error.message; + statusMessage.style.display = 'block'; + } + + const loader = document.getElementById('loader'); + if (loader) loader.style.display = 'none'; + + showUINotification('Fehler beim Laden der Mindmap: ' + error.message, 'error'); + } +} + +// Eventlistener für DOM-Ready +document.addEventListener('DOMContentLoaded', function() { + console.log('DOM vollständig geladen, starte Mindmap-Anwendung'); + startMindmapApp(); +}); + // Funktion zum Initialisieren der Mindmap async function initializeMindmap() { try {