my-homelab-configs/apps/opsproof/overlay/resources/js/pages/Execution.tsx

55 lines
2.5 KiB
TypeScript

import { router } from '@inertiajs/react';
import { useEffect } from 'react';
interface ExecutionView {
execution: {
id: number;
jeannie_execution_id: string;
status: string;
output: string;
error: string;
report_id: number;
};
proposal: {
id: number;
scope: string;
target: string;
evidence_hash: string;
};
}
export default function ExecutionPage({ view }: { view: ExecutionView }) {
const active = view.execution.status === 'queued' || view.execution.status === 'running';
useEffect(() => {
if (!active) return;
const timer = window.setInterval(() => router.reload({ only: ['view'] }), 2000);
return () => window.clearInterval(timer);
}, [active]);
return (
<main className="min-h-screen bg-[#071019] px-5 py-8 text-slate-100">
<div className="mx-auto max-w-5xl">
<p className="text-xs uppercase tracking-[0.2em] text-cyan-300">Approval-gated execution</p>
<h1 className="mt-3 text-3xl font-semibold">{view.proposal.scope} / {view.proposal.target}</h1>
<div className="mt-6 rounded-2xl border border-white/10 bg-[#0a141e] p-6">
<div className="flex items-center justify-between">
<span className="font-mono text-xs text-slate-500">{view.execution.jeannie_execution_id}</span>
<span className="rounded-md border border-cyan-300/20 bg-cyan-300/10 px-2 py-1 text-xs uppercase text-cyan-200">
{view.execution.status}
</span>
</div>
<pre className="mt-5 max-h-[32rem] overflow-auto whitespace-pre-wrap rounded-xl bg-black/20 p-4 text-xs leading-5 text-slate-400">
{view.execution.output || (active ? 'Waiting for Jeannie output…' : view.execution.error || 'No output returned.')}
</pre>
{active && <p className="mt-3 text-xs text-slate-500">Refreshing every two seconds.</p>}
{!active && view.execution.report_id > 0 && (
<a href={`/reports/${view.execution.report_id}`} className="mt-5 inline-flex rounded-lg bg-cyan-300 px-4 py-2 text-sm font-semibold text-slate-950">
Open incident report
</a>
)}
</div>
</div>
</main>
);
}