Workflow Monitor Component Library π
Real-time workflow execution monitoring with WebSocket streaming and animated status indicators.
Installationβ
npm install @stomp/stompjs
Quick Startβ
import { WorkflowMonitor } from '@/components/WorkflowMonitor';
import { ToastProvider } from '@/providers/ToastProvider';
import { useGetWorkflowQuery } from '@thorapi/redux/services/WorkflowService';
function MyWorkflowPage({ workflowId }: { workflowId: string }) {
const { data: workflow } = useGetWorkflowQuery(workflowId);
if (!workflow) return <div>Loading...</div>;
return (
<ToastProvider>
<WorkflowMonitor
workflow={workflow}
onStart={() => fetch(`/api/workflows/${workflowId}/start`, { method: 'POST' })}
onPause={() => fetch(`/api/workflows/${workflowId}/pause`, { method: 'POST' })}
onStop={() => fetch(`/api/workflows/${workflowId}/stop`, { method: 'POST' })}
/>
</ToastProvider>
);
}
Componentsβ
WorkflowMonitorβ
Main container component that orchestrates all workflow monitoring features.
Propsβ
| Prop | Type | Required | Description |
|---|---|---|---|
workflow | Workflow | β | ThorAPI Workflow model |
onStart | () => Promise<void> | β | Start workflow handler |
onPause | () => Promise<void> | β | Pause workflow handler |
onStop | () => Promise<void> | β | Stop workflow handler |
onServerChange | (url: string) => void | β | Server URL change handler |
Exampleβ
<WorkflowMonitor
workflow={workflow}
onStart={async () => {
const response = await startWorkflowMutation(workflowId);
console.log('Started:', response);
}}
onPause={async () => {
await pauseWorkflowMutation(workflowId);
}}
onStop={async () => {
await stopWorkflowMutation(workflowId);
}}
onServerChange={(url) => {
console.log('Server changed to:', url);
}}
/>
ExecModuleCardβ
Animated card displaying individual module execution status.
Propsβ
| Prop | Type | Required | Description |
|---|---|---|---|
module | ExecModule | β | ThorAPI ExecModule model |
status | ModuleStatus | β | Current status (default: 'PENDING') |
eventLogs | EventLog[] | β | Recent event logs |
duration | number | β | Execution duration in ms |
onExpand | (id: string) => void | β | Expand handler |
Status Valuesβ
PENDING- π΅ Blue, no animationRUNNING- π‘ Yellow, pulsing animationSUCCESS- π’ Green, glow animationERROR- π΄ Red, shake animationPAUSED- βΈοΈ Gray, staticSKIPPED- βοΈ Light gray
Exampleβ
<ExecModuleCard
module={execModule}
status="RUNNING"
eventLogs={recentLogs}
duration={1500}
onExpand={(id) => console.log('Expanded:', id)}
/>
WorkflowControlsβ
Play/Pause/Stop buttons with smart enable/disable logic.
Propsβ
| Prop | Type | Required | Description |
|---|---|---|---|
workflow | Workflow | β | ThorAPI Workflow model |
onStart | () => Promise<void> | β | Start handler |
onPause | () => Promise<void> | β | Pause handler |
onStop | () => Promise<void> | β | Stop handler |
onRefresh | () => void | β | Refresh handler |
disabled | boolean | β | Disable all buttons |
Button Statesβ
| Workflow Status | Play | Pause | Stop |
|---|---|---|---|
| READY | β | β | β |
| RUNNING | β | β | β |
| STOPPED | β | β |