feat: add preview image builder

This commit is contained in:
BennyKok
2024-01-04 22:29:22 +08:00
parent 314eb9fd16
commit 9937252777
18 changed files with 1085 additions and 56 deletions
@@ -0,0 +1,9 @@
"use client";
import { LoadingPageWrapper } from "@/components/LoadingWrapper";
import { usePathname } from "next/navigation";
export default function Loading() {
const pathName = usePathname();
return <LoadingPageWrapper className="h-full" tag={pathName.toLowerCase()} />;
}
@@ -0,0 +1,43 @@
import { MachineBuildLog } from "../../../../components/MachineBuildLog";
import { LogsViewer } from "@/components/LogsViewer";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { getRelativeTime } from "@/lib/getRelativeTime";
import { getMachineById } from "@/server/curdMachine";
export default async function Page({
params,
}: {
params: { machine_id: string };
}) {
const machine = await getMachineById(params.machine_id);
return (
<div>
<Card className="w-full h-fit mt-4">
<CardHeader>
<CardTitle>{machine.name}</CardTitle>
<CardDescription suppressHydrationWarning={true}>
{getRelativeTime(machine?.updated_at)}
</CardDescription>
</CardHeader>
<CardContent>
{machine.status == "building" && (
<MachineBuildLog
machine_id={params.machine_id}
endpoint={process.env.MODAL_BUILDER_URL!}
/>
)}
{machine.build_log && (
<LogsViewer logs={JSON.parse(machine.build_log)} />
)}
</CardContent>
</Card>
</div>
);
}