- Frontend v4 accessible sur réseau local (192.168.1.40) - Ports ouverts: 3002 (frontend), 5001 (backend), 5004 (dashboard) - Ollama GPU fonctionnel - Self-healing interactif - Dashboard confiance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
130 lines
3.5 KiB
Python
130 lines
3.5 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Script de Correction de l'API React Flow
|
|
Auteur : Dom, Alice, Kiro - 8 janvier 2026
|
|
|
|
Corrige l'utilisation de l'API React Flow pour @xyflow/react
|
|
"""
|
|
|
|
import os
|
|
import re
|
|
from pathlib import Path
|
|
|
|
def fix_react_flow_api():
|
|
"""
|
|
Corrige l'API React Flow dans tous les fichiers
|
|
"""
|
|
frontend_path = Path("visual_workflow_builder/frontend/src")
|
|
|
|
# Corrections principales
|
|
corrections = [
|
|
# Import par défaut vers import nommé
|
|
(r"import ReactFlow,\s*{([^}]+)}\s*from '@xyflow/react'", r"import { ReactFlow, \1 } from '@xyflow/react'"),
|
|
(r"import ReactFlow from '@xyflow/react'", "import { ReactFlow } from '@xyflow/react'"),
|
|
|
|
# Corrections des exports par défaut
|
|
(r"export default ReactFlow", "export { ReactFlow }"),
|
|
|
|
# Corrections des imports CSS
|
|
(r"import '@xyflow/react/dist/style.css'", "import '@xyflow/react/dist/base.css'"),
|
|
]
|
|
|
|
files_processed = 0
|
|
|
|
# Parcourir tous les fichiers TypeScript/JavaScript
|
|
for file_path in frontend_path.rglob("*.ts"):
|
|
if process_file_api(file_path, corrections):
|
|
files_processed += 1
|
|
|
|
for file_path in frontend_path.rglob("*.tsx"):
|
|
if process_file_api(file_path, corrections):
|
|
files_processed += 1
|
|
|
|
print(f"✅ {files_processed} fichiers traités")
|
|
|
|
def process_file_api(file_path, corrections):
|
|
"""
|
|
Traite un fichier individuel pour l'API
|
|
"""
|
|
try:
|
|
with open(file_path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
original_content = content
|
|
|
|
# Appliquer toutes les corrections
|
|
for pattern, replacement in corrections:
|
|
content = re.sub(pattern, replacement, content)
|
|
|
|
# Sauvegarder si modifié
|
|
if content != original_content:
|
|
with open(file_path, 'w', encoding='utf-8') as f:
|
|
f.write(content)
|
|
print(f"📝 API corrigée: {file_path}")
|
|
return True
|
|
|
|
except Exception as e:
|
|
print(f"❌ Erreur avec {file_path}: {e}")
|
|
|
|
return False
|
|
|
|
def create_minimal_canvas():
|
|
"""
|
|
Crée un composant Canvas minimal qui fonctionne
|
|
"""
|
|
canvas_content = '''import React from 'react';
|
|
import { ReactFlow, Background, Controls, MiniMap } from '@xyflow/react';
|
|
import '@xyflow/react/dist/base.css';
|
|
|
|
interface CanvasProps {
|
|
nodes: any[];
|
|
edges: any[];
|
|
onNodesChange: (changes: any[]) => void;
|
|
onEdgesChange: (changes: any[]) => void;
|
|
onConnect: (connection: any) => void;
|
|
}
|
|
|
|
/**
|
|
* Composant Canvas Minimal
|
|
* Auteur : Dom, Alice, Kiro - 8 janvier 2026
|
|
*/
|
|
const Canvas: React.FC<CanvasProps> = ({
|
|
nodes,
|
|
edges,
|
|
onNodesChange,
|
|
onEdgesChange,
|
|
onConnect
|
|
}) => {
|
|
return (
|
|
<div style={{ width: '100%', height: '600px' }}>
|
|
<ReactFlow
|
|
nodes={nodes}
|
|
edges={edges}
|
|
onNodesChange={onNodesChange}
|
|
onEdgesChange={onEdgesChange}
|
|
onConnect={onConnect}
|
|
fitView
|
|
>
|
|
<Background />
|
|
<Controls />
|
|
<MiniMap />
|
|
</ReactFlow>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Canvas;
|
|
'''
|
|
|
|
canvas_path = Path("visual_workflow_builder/frontend/src/components/Canvas/CanvasMinimal.tsx")
|
|
with open(canvas_path, 'w', encoding='utf-8') as f:
|
|
f.write(canvas_content)
|
|
|
|
print(f"✅ Canvas minimal créé: {canvas_path}")
|
|
|
|
if __name__ == "__main__":
|
|
print("🔧 Correction de l'API React Flow...")
|
|
fix_react_flow_api()
|
|
create_minimal_canvas()
|
|
print("✅ Correction terminée") |