/** * Activity Log Component * Real-time log viewer for automation runs */ import React, { useState, useEffect } from 'react'; import { automationService } from '../../services/automationService'; import ComponentCard from '../common/ComponentCard'; interface ActivityLogProps { runId: string; } const ActivityLog: React.FC = ({ runId }) => { const [logs, setLogs] = useState(''); const [lines, setLines] = useState(100); useEffect(() => { loadLogs(); // Poll every 3 seconds const interval = setInterval(loadLogs, 3000); return () => clearInterval(interval); }, [runId, lines]); const loadLogs = async () => { try { const logText = await automationService.getLogs(runId, lines); setLogs(logText); } catch (error) { console.error('Failed to load logs', error); } }; return (
{logs || 'No logs available'}
); }; export default ActivityLog;