Compare commits
3 Commits
49ccf3908a
...
d307763007
| Author | SHA1 | Date | |
|---|---|---|---|
| d307763007 | |||
| d7e6912e08 | |||
| ffe96074f4 |
15
.env
15
.env
@@ -1,13 +1,2 @@
|
|||||||
# MindMap Umgebungsvariablen
|
SECRET_KEY=eed9298856dc9363cd32778265780d6904ba24e6a6b815a2cc382bcdd767ea7b
|
||||||
# Kopiere diese Datei zu .env und passe die Werte an
|
OPENAI_API_KEY=sk-dein-openai-api-schluessel-hier
|
||||||
|
|
||||||
# Flask
|
|
||||||
SECRET_KEY=dein-geheimer-schluessel-hier
|
|
||||||
|
|
||||||
# OpenAI API
|
|
||||||
OPENAI_API_KEY=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
|
|
||||||
|
|
||||||
# Datenbank
|
|
||||||
# Bei Bedarf kann hier eine andere Datenbank-URL angegeben werden
|
|
||||||
# Der Pfad wird relativ zum Projektverzeichnis angegeben
|
|
||||||
# SQLALCHEMY_DATABASE_URI=sqlite:////absoluter/pfad/zu/database/systades.db OPENAI_API_KEY=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
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -67,15 +67,51 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* 2. Hilfs-Funktionen für API-Zugriffe */
|
/* 2. Hilfs-Funktionen für API-Zugriffe */
|
||||||
const get = endpoint => fetch(endpoint).then(r => r.json());
|
const get = async endpoint => {
|
||||||
const post = (endpoint, body) =>
|
try {
|
||||||
fetch(endpoint, {
|
const response = await fetch(endpoint);
|
||||||
method: 'POST',
|
if (!response.ok) {
|
||||||
headers: { 'Content-Type': 'application/json' },
|
console.error(`API-Fehler: ${endpoint} antwortet mit Status ${response.status}`);
|
||||||
body: JSON.stringify(body)
|
return []; // Leeres Array zurückgeben bei Fehlern
|
||||||
}).then(r => r.json());
|
}
|
||||||
const del = endpoint =>
|
return await response.json();
|
||||||
fetch(endpoint, { method: 'DELETE' }).then(r => r.json());
|
} catch (error) {
|
||||||
|
console.error(`Fehler beim Abrufen von ${endpoint}:`, error);
|
||||||
|
return []; // Leeres Array zurückgeben bei Netzwerkfehlern
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const post = async (endpoint, body) => {
|
||||||
|
try {
|
||||||
|
const response = await fetch(endpoint, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(body)
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
console.error(`API-Fehler: ${endpoint} antwortet mit Status ${response.status}`);
|
||||||
|
return {}; // Leeres Objekt zurückgeben bei Fehlern
|
||||||
|
}
|
||||||
|
return await response.json();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Fehler beim POST zu ${endpoint}:`, error);
|
||||||
|
return {}; // Leeres Objekt zurückgeben bei Netzwerkfehlern
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const del = async endpoint => {
|
||||||
|
try {
|
||||||
|
const response = await fetch(endpoint, { method: 'DELETE' });
|
||||||
|
if (!response.ok) {
|
||||||
|
console.error(`API-Fehler: ${endpoint} antwortet mit Status ${response.status}`);
|
||||||
|
return {}; // Leeres Objekt zurückgeben bei Fehlern
|
||||||
|
}
|
||||||
|
return await response.json();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Fehler beim DELETE zu ${endpoint}:`, error);
|
||||||
|
return {}; // Leeres Objekt zurückgeben bei Netzwerkfehlern
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* 3. Kategorien laden für Style-Informationen */
|
/* 3. Kategorien laden für Style-Informationen */
|
||||||
let categories = await get('/api/categories');
|
let categories = await get('/api/categories');
|
||||||
@@ -92,9 +128,12 @@
|
|||||||
// Graph leeren (für Reload-Fälle)
|
// Graph leeren (für Reload-Fälle)
|
||||||
cy.elements().remove();
|
cy.elements().remove();
|
||||||
|
|
||||||
|
// Überprüfen, ob nodes ein Array ist, wenn nicht, setze es auf ein leeres Array
|
||||||
|
const nodesArray = Array.isArray(nodes) ? nodes : [];
|
||||||
|
|
||||||
// Knoten zum Graph hinzufügen
|
// Knoten zum Graph hinzufügen
|
||||||
cy.add(
|
cy.add(
|
||||||
nodes.map(node => {
|
nodesArray.map(node => {
|
||||||
// Kategorie-Informationen für Styling abrufen
|
// Kategorie-Informationen für Styling abrufen
|
||||||
const category = categories.find(c => c.id === node.category_id) || {};
|
const category = categories.find(c => c.id === node.category_id) || {};
|
||||||
|
|
||||||
@@ -112,9 +151,12 @@
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Überprüfen, ob relationships ein Array ist, wenn nicht, setze es auf ein leeres Array
|
||||||
|
const relationshipsArray = Array.isArray(relationships) ? relationships : [];
|
||||||
|
|
||||||
// Kanten zum Graph hinzufügen
|
// Kanten zum Graph hinzufügen
|
||||||
cy.add(
|
cy.add(
|
||||||
relationships.map(rel => ({
|
relationshipsArray.map(rel => ({
|
||||||
data: {
|
data: {
|
||||||
id: `${rel.parent_id}_${rel.child_id}`,
|
id: `${rel.parent_id}_${rel.child_id}`,
|
||||||
source: rel.parent_id.toString(),
|
source: rel.parent_id.toString(),
|
||||||
@@ -123,6 +165,54 @@
|
|||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Wenn keine Knoten geladen wurden, Fallback-Knoten erstellen
|
||||||
|
if (nodesArray.length === 0) {
|
||||||
|
// Mindestens einen Standardknoten hinzufügen
|
||||||
|
cy.add({
|
||||||
|
data: {
|
||||||
|
id: 'fallback-1',
|
||||||
|
name: 'Mindmap',
|
||||||
|
description: 'Erstellen Sie hier Ihre eigene Mindmap',
|
||||||
|
color: '#3b82f6',
|
||||||
|
icon: 'help-circle'
|
||||||
|
},
|
||||||
|
position: { x: 300, y: 200 }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Erfolgsmeldung anzeigen
|
||||||
|
console.log('Mindmap erfolgreich initialisiert mit Fallback-Knoten');
|
||||||
|
|
||||||
|
// Info-Meldung für Benutzer anzeigen
|
||||||
|
const infoBox = document.createElement('div');
|
||||||
|
infoBox.classList.add('info-message');
|
||||||
|
infoBox.style.position = 'absolute';
|
||||||
|
infoBox.style.top = '50%';
|
||||||
|
infoBox.style.left = '50%';
|
||||||
|
infoBox.style.transform = 'translate(-50%, -50%)';
|
||||||
|
infoBox.style.padding = '15px 20px';
|
||||||
|
infoBox.style.backgroundColor = 'rgba(59, 130, 246, 0.9)';
|
||||||
|
infoBox.style.color = 'white';
|
||||||
|
infoBox.style.borderRadius = '8px';
|
||||||
|
infoBox.style.zIndex = '5';
|
||||||
|
infoBox.style.maxWidth = '80%';
|
||||||
|
infoBox.style.textAlign = 'center';
|
||||||
|
infoBox.style.boxShadow = '0 4px 12px rgba(0,0,0,0.15)';
|
||||||
|
infoBox.innerHTML = 'Mindmap erfolgreich initialisiert.<br>Verwenden Sie die Werkzeugleiste, um Knoten hinzuzufügen.';
|
||||||
|
|
||||||
|
document.getElementById('cy').appendChild(infoBox);
|
||||||
|
|
||||||
|
// Meldung nach 5 Sekunden ausblenden
|
||||||
|
setTimeout(() => {
|
||||||
|
infoBox.style.opacity = '0';
|
||||||
|
infoBox.style.transition = 'opacity 0.5s ease';
|
||||||
|
setTimeout(() => {
|
||||||
|
if (infoBox.parentNode) {
|
||||||
|
infoBox.parentNode.removeChild(infoBox);
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
// Layout anwenden wenn keine Positionsdaten vorhanden
|
// Layout anwenden wenn keine Positionsdaten vorhanden
|
||||||
const nodesWithoutPosition = cy.nodes().filter(node =>
|
const nodesWithoutPosition = cy.nodes().filter(node =>
|
||||||
!node.position() || (node.position().x === 0 && node.position().y === 0)
|
!node.position() || (node.position().x === 0 && node.position().y === 0)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user