diff --git a/src/components/chatAssistance/SpiderMan.jsx b/src/components/chatAssistance/SpiderMan.jsx index 234d858..bda3a9a 100644 --- a/src/components/chatAssistance/SpiderMan.jsx +++ b/src/components/chatAssistance/SpiderMan.jsx @@ -9,6 +9,7 @@ export function SpiderMan({ animationTrigger }) { const { actions } = useAnimations(animations, spidermanRef); const [currentAnimation, setCurrentAnimation] = useState("idle"); const [isAnimating, setIsAnimating] = useState(false); + const [isVisible, setIsVisible] = useState(true); const animationQueue = useRef([]); // Map animation triggers to actual animation names @@ -51,17 +52,41 @@ export function SpiderMan({ animationTrigger }) { const animationList = Object.keys(animationMap); for (const anim of animationList) { + if (!isVisible) break; // Stop if component is set to invisible setCurrentAnimation(anim); await playAnimation(anim); - // Shorter delay between animations await new Promise(resolve => setTimeout(resolve, 300)); } setIsAnimating(false); - // Return to idle animation - playAnimation('idle'); + // Fade out effect before disappearing + if (spidermanRef.current) { + const material = spidermanRef.current.material; + const startOpacity = 1; + const duration = 1000; // 1 second fade + const startTime = Date.now(); + + const fadeOut = () => { + const elapsed = Date.now() - startTime; + const progress = Math.min(elapsed / duration, 1); + + if (progress < 1) { + const newOpacity = startOpacity * (1 - progress); + spidermanRef.current.traverse((child) => { + if (child.isMesh) { + child.material.transparent = true; + child.material.opacity = newOpacity; + } + }); + requestAnimationFrame(fadeOut); + } else { + setIsVisible(false); + } + }; + + fadeOut(); + } }; - // Updated effect to handle animation triggers useEffect(() => { if (!animationTrigger || isAnimating) return; @@ -72,19 +97,18 @@ export function SpiderMan({ animationTrigger }) { setIsAnimating(true); await playAnimation(animationTrigger); setIsAnimating(false); - // Return to idle after single animation playAnimation('idle'); } }; handleAnimation(); }, [animationTrigger]); - // Initial idle animation useEffect(() => { if (actions && Object.keys(actions).length > 0) { playAnimation('idle'); } }, [actions]); + if (!isVisible) return null; return ( { - return ( -
-
-
- -
-
-
-

- AI Analysis -

-

Real-time deployment insights

-
-
+export const AIAnalysis = ({ analysisData = [] }) => { + const [displayedAnalysis, setDisplayedAnalysis] = useState([]); + const [isStreaming, setIsStreaming] = useState(false); + const [currentItem, setCurrentItem] = useState(null); -
-
-

Performance Metrics

- -

Build optimization: 80%

-
-
-

Security Check

- -

Vulnerability scan: 95% safe

+ useEffect(() => { + if (analysisData.length > displayedAnalysis.length) { + setCurrentItem(analysisData[displayedAnalysis.length]); + setIsStreaming(true); + } + }, [analysisData, displayedAnalysis]); + + const handleStreamComplete = () => { + if (currentItem) { + setDisplayedAnalysis(prev => [...prev, currentItem]); + setIsStreaming(false); + setCurrentItem(null); + } + }; + + const getClassificationColor = (classification) => { + switch (classification) { + case "ERROR": + return "text-red-400 bg-red-500/10 border-red-500/30"; + case "WARNING": + return "text-yellow-400 bg-yellow-500/10 border-yellow-500/30"; + case "INFO": + return "text-blue-400 bg-blue-500/10 border-blue-500/30"; + case "SUCCESS": + case "UPLOAD_SUCCESS": + return "text-green-400 bg-green-500/10 border-green-500/30"; + default: + return "text-gray-400 bg-gray-500/10 border-gray-500/30"; + } + }; + + return ( +
+
+

AI Analysis

+
+ INSIGHTS + {isStreaming && ( + +
+
+
+ + )}
+ +
+ {displayedAnalysis.map((item, index) => ( + +
+ {item.classification} + {new Date(item.timestamp).toLocaleString()} +
+

{item.reasoning}

+
+ ))} + + {isStreaming && currentItem && ( + +
+ {currentItem.classification} + + {new Date(currentItem.timestamp).toLocaleString()} + +
+

+ +

+
+ )} -
-
-

AI Insights

- - Live Analysis - -
-
- -
- -
+ {!isStreaming && displayedAnalysis.length === 0 && ( + + + + +

AI is analyzing your deployment logs...

+
+ )}
); diff --git a/src/components/pages/DeploymentProgress.jsx b/src/components/pages/DeploymentProgress.jsx index 6374b83..5e9adfb 100644 --- a/src/components/pages/DeploymentProgress.jsx +++ b/src/components/pages/DeploymentProgress.jsx @@ -6,6 +6,10 @@ import { PieChart, Pie, Cell, ResponsiveContainer, Tooltip } from "recharts"; import axios from "axios"; import { AIAnalysis } from "../deployment/AIAnalysis"; import { LogTerminal } from "../deployment/LogTerminal"; +import { Canvas } from "@react-three/fiber"; +import { SpiderMan } from "../chatAssistance/SpiderMan"; +import { ChatInterface } from "../chatAssistance/ChaatInterface"; +import { Environment } from "@react-three/drei"; const DeploymentProgress = () => { const API_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:5000'; @@ -15,6 +19,8 @@ const DeploymentProgress = () => { const [isDeploying, setIsDeploying] = useState(true); const [progress, setProgress] = useState(0); const [deploymentStats, setDeploymentStats] = useState({ success: 70, failure: 30, total: 100 }); + const [aiAnalysisData, setAiAnalysisData] = useState([]); + const navigate = useNavigate(); const { id } = useParams(); @@ -90,17 +96,67 @@ const DeploymentProgress = () => { } }; - const interval = setInterval(fetchLogs, 2000); - return () => clearInterval(interval); + //fetch llm logs + const fetchAiAnalysis = async () => { + try { + const response = await axios.get(`https://api.dataflarenet.com/api/ai-analysis/${id}`); + if (response.data.success) { + setAiAnalysisData(response.data.data); + } + } catch (error) { + console.error("Error fetching AI analysis:", error.message); + } + }; + + const logsInterval = setInterval(fetchLogs, 2000); + const aiAnalysisInterval = setInterval(fetchAiAnalysis, 3000); // Poll AI analysis every 5 seconds + + return () => { + clearInterval(logsInterval); + clearInterval(aiAnalysisInterval); + }; }, [id]); + const handleCancel = () => { setIsDeploying(false); navigate("/service"); }; return (
+ + {/* Spider-Man 3D Scene */} +
+ + + + + + +
+ + {/* Chat Interface */} + + + {/* Background Effects */}
@@ -148,7 +204,7 @@ const DeploymentProgress = () => { ))}
-
+ {/*
@@ -169,7 +225,7 @@ const DeploymentProgress = () => { ))}
-
+
*/}
@@ -178,12 +234,13 @@ const DeploymentProgress = () => {
- {/* //logs anf ai Analysis */} + {/* logs and ai Analysis */}
- +
+
{isDeploying ? ( <>