// [TSM.ID].[11031972] -- All Rights Reserved. Proprietary & Confidential. import { useEffect, useRef, useState } from 'react'; import { useAuth } from '../context/AuthContext'; import { useIam } from '../context/IamContext'; import { useWasm } from '../context/WasmContext'; import { useI18n } from '../context/I18nContext'; function useNeuralTelemetry() { const [data, setData] = useState({ cpu_usage: 0, ram_usage: 0, active_connections: 0, threats_blocked: 0, status: 'SECURE' }); useEffect(() => { let sse; const connect = () => { // Menghubungkan ke Rust Backend yang sebenarnya sse = new EventSource('/api/v1/telemetry/stream'); sse.onmessage = (event) => { try { const payload = JSON.parse(event.data); setData(payload); } catch (err) { console.error("Neural Link Parse Error:", err); } }; sse.onerror = () => { sse.close(); setTimeout(connect, 5000); }; }; connect(); return () => { if (sse) sse.close(); }; }, []); return data; } export default function DashboardOverview() { const canvasRef = useRef(null); const { cryptographicKey } = useAuth(); const { identity } = useIam(); const { isWasmReady, wasmLogs, triggerPostQuantumShield, triggerAegisMatrix } = useWasm(); const { t } = useI18n(); const telemetry = useNeuralTelemetry(); // Quantum Particle Engine (Zero React Overhead Canvas) useEffect(() => { const canvas = canvasRef.current; if (!canvas) return; const ctx = canvas.getContext('2d'); let animationFrameId; let particles = []; const numParticles = 150; for(let i=0; i < numParticles; i++) { particles.push({ x: Math.random() * canvas.width, y: Math.random() * canvas.height, vx: (Math.random() - 0.5) * 3, vy: (Math.random() - 0.5) * 3, baseSize: Math.random() * 2 + 1 }); } const render = () => { ctx.fillStyle = 'rgba(0, 0, 0, 0.2)'; ctx.fillRect(0, 0, canvas.width, canvas.height); const speedMultiplier = 1.0 + (telemetry.cpu_usage / 5.0); particles.forEach(p => { p.x += p.vx * speedMultiplier; p.y += p.vy * speedMultiplier; if (p.x < 0 || p.x > canvas.width) p.vx *= -1; if (p.y < 0 || p.y > canvas.height) p.vy *= -1; ctx.beginPath(); ctx.arc(p.x, p.y, p.baseSize, 0, Math.PI * 2); ctx.fillStyle = identity.role === 'supreme_admin' ? '#00f3ff' : '#a855f7'; ctx.fill(); particles.forEach(p2 => { const dx = p.x - p2.x; const dy = p.y - p2.y; const dist = Math.sqrt(dx*dx + dy*dy); if(dist < 60) { ctx.beginPath(); ctx.moveTo(p.x, p.y); ctx.lineTo(p2.x, p2.y); if (identity.role === 'supreme_admin') { ctx.strokeStyle = `rgba(0, 243, 255, ${1 - dist/60})`; } else { ctx.strokeStyle = `rgba(168, 85, 247, ${1 - dist/60})`; } ctx.lineWidth = 1; ctx.stroke(); } }); }); animationFrameId = requestAnimationFrame(render); }; render(); return () => cancelAnimationFrame(animationFrameId); }, [telemetry.cpu_usage, identity.role]); return (
{t('active_vvip')}
{telemetry.active_connections.toLocaleString()}
{t('cpu_load').replace('{val}', telemetry.cpu_usage.toFixed(1))}
{t('threats_annihilated')}
{telemetry.threats_blocked.toLocaleString()}
{t('ram_active').replace('{val}', telemetry.ram_usage.toFixed(1))}
{t('session_auth')}
{cryptographicKey ? cryptographicKey.substring(0, 16) + '...' : t('unauthorized')}
{t('access_level')} {identity.role === 'supreme_admin' ? 'SUPREME ADMIN' : 'TENANT GATEWAY'}
{/* QUANTUM ARSENAL PANEL (Only for Supreme Admin) */} {identity.role === 'supreme_admin' && (

{t('quantum_arsenal')}

{isWasmReady ? t('wasm_online') : t('wasm_compiling')}
{t('wasm_logs')}
{wasmLogs.length === 0 &&
{t('awaiting_command')}
} {wasmLogs.map((log, i) => (
{log}
))}
)}

{t('global_routing')}

); }