Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/routes/app.$tenant/automations.$id.executions.$executionId.tsx
T
2026-07-08 16:15:37 +02:00

87 lines
4.4 KiB
TypeScript

import { useLoaderData } from "react-router";
import { useTranslation } from "react-i18next";
import type { LoaderFunctionArgs } from "react-router";
import { loadAutomationExecutionDetailVM, type AutomationExecutionDetailVM } from "~/services/automation/automation.server";
export async function loader({ request, params }: LoaderFunctionArgs) {
return Response.json(await loadAutomationExecutionDetailVM({ request, params }));
}
export default function AutomationExecutionDetailRoute() {
const data = useLoaderData() as AutomationExecutionDetailVM;
const { t } = useTranslation();
return (
<main className="mx-auto flex w-full max-w-6xl flex-col gap-6 p-6">
<header className="flex flex-col gap-2">
<h1 className="text-foreground text-2xl font-semibold">{data.rule.name}</h1>
<p className="text-muted-foreground text-sm">{data.execution.summaryText}</p>
</header>
<section className="grid gap-3 md:grid-cols-4">
<DetailCard label={t("automation.detail.status")} value={t(`automation.status.${data.execution.status}`, { defaultValue: data.execution.status })} />
<DetailCard label={t("automation.detail.trigger")} value={data.execution.triggerKey} />
<DetailCard label={t("automation.detail.mode")} value={data.execution.dryRun ? t("automation.values.dryRun") : t("automation.values.liveRun")} />
<DetailCard label={t("automation.detail.reverseWindow")} value={data.execution.reverseWindowExpiresAt ?? t("automation.values.notAvailable")} />
</section>
<section className="overflow-hidden rounded-lg border">
<div className="border-b px-4 py-3">
<h2 className="text-foreground text-sm font-semibold">{t("automation.sections.steps")}</h2>
</div>
<div className="divide-y">
{data.steps.map((step) => (
<div className="grid gap-2 px-4 py-3 md:grid-cols-[1fr_140px_120px]" key={step.id}>
<span>
<span className="text-foreground block text-sm font-medium">{step.summaryText}</span>
<span className="text-muted-foreground block text-xs">{step.nodeType}</span>
</span>
<span className="text-muted-foreground text-sm">{t(`automation.status.${step.status}`, { defaultValue: step.status })}</span>
<span className="text-muted-foreground text-sm">{step.durationMs == null ? t("automation.values.notAvailable") : `${step.durationMs} ms`}</span>
</div>
))}
</div>
</section>
<section className="overflow-hidden rounded-lg border">
<div className="border-b px-4 py-3">
<h2 className="text-foreground text-sm font-semibold">{t("automation.editor.reverse.title")}</h2>
</div>
<div className="grid gap-3 px-4 py-3 md:grid-cols-[1fr_220px]">
<div>
<p className="text-muted-foreground text-sm">
{data.reversePlan.canReverse ? t("automation.editor.reverse.available") : t("automation.editor.reverse.expired")}
</p>
<div className="mt-3 divide-y rounded-md border">
{data.reversePlan.items.map((item) => (
<div className="grid gap-2 px-3 py-2 text-sm md:grid-cols-[1fr_140px]" key={`${item.stepKey}-${item.actionKey}`}>
<span>
<span className="text-foreground block font-medium">{t(item.actionKey)}</span>
<span className="text-muted-foreground block text-xs">{item.nodeType}</span>
</span>
<span className={item.reversible ? "text-emerald-700" : "text-muted-foreground"}>
{item.reversible ? t("automation.editor.reverse.reversible") : t("automation.editor.reverse.notReversible")}
</span>
</div>
))}
</div>
</div>
<div className="rounded-md bg-muted/40 p-3">
<div className="text-muted-foreground text-xs">{t("automation.editor.reverse.confirmation")}</div>
<div className="text-foreground mt-1 text-sm font-semibold">{data.reversePlan.confirmationPhrase}</div>
</div>
</div>
</section>
</main>
);
}
function DetailCard({ label, value }: { label: string; value: string }) {
return (
<div className="rounded-lg border px-4 py-3">
<div className="text-muted-foreground text-xs">{label}</div>
<div className="text-foreground mt-1 text-sm font-medium">{value}</div>
</div>
);
}