Release / release (push) Successful in 4m33s
- Dot-matrix "Creation of Adam" page banners behind a floating menu, glass cards and tables, library header with live stats, table toolbar with pagination, Cmd/Ctrl+K search across models, endpoints, runs, tags, settings and actions. - Remove single files from a model (selection + disk, via a worker job). - Containers start as root to prepare folders and drop to PUID:PGID; AUTH_SECRET is generated when unset; sandbox runs as nobody; KANAME_IMAGE and image docs in the README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
137 lines
4.0 KiB
TypeScript
137 lines
4.0 KiB
TypeScript
"use client";
|
|
|
|
import { Loader2Icon, PencilIcon, PlugZapIcon, Trash2Icon } from "lucide-react";
|
|
import Link from "next/link";
|
|
import { useRouter } from "next/navigation";
|
|
import { useState } from "react";
|
|
import { toast } from "sonner";
|
|
import {
|
|
AlertDialog,
|
|
AlertDialogAction,
|
|
AlertDialogCancel,
|
|
AlertDialogContent,
|
|
AlertDialogDescription,
|
|
AlertDialogFooter,
|
|
AlertDialogHeader,
|
|
AlertDialogTitle,
|
|
AlertDialogTrigger,
|
|
} from "@/components/ui/alert-dialog";
|
|
import { Button, buttonVariants } from "@/components/ui/button";
|
|
import { PageHero } from "@/components/hero/page-hero";
|
|
import type { EndpointView } from "@/lib/endpoints";
|
|
import { ProbeResult } from "../endpoint-form";
|
|
import { EndpointStatus } from "../endpoint-status";
|
|
|
|
/** The page banner: name, URL, connection test, edit and delete; the page's content below it. */
|
|
export function EndpointHeader({
|
|
endpoint,
|
|
runCount,
|
|
children,
|
|
}: {
|
|
endpoint: EndpointView;
|
|
runCount: number;
|
|
children: React.ReactNode;
|
|
}) {
|
|
const router = useRouter();
|
|
const [probe, setProbe] = useState(endpoint.probe);
|
|
const [testing, setTesting] = useState(false);
|
|
|
|
async function test() {
|
|
setTesting(true);
|
|
try {
|
|
const res = await fetch(`/api/endpoints/${endpoint.id}/test`, {
|
|
method: "POST",
|
|
});
|
|
const json = await res.json().catch(() => ({}));
|
|
if (!res.ok)
|
|
return toast.error(
|
|
json.error?.message ?? `Test failed (${res.status})`,
|
|
);
|
|
setProbe(json);
|
|
router.refresh();
|
|
} finally {
|
|
setTesting(false);
|
|
}
|
|
}
|
|
|
|
async function remove() {
|
|
const res = await fetch(`/api/endpoints/${endpoint.id}`, {
|
|
method: "DELETE",
|
|
});
|
|
if (!res.ok) {
|
|
const json = await res.json().catch(() => ({}));
|
|
return toast.error(
|
|
json.error?.message ?? `Could not delete (${res.status})`,
|
|
);
|
|
}
|
|
router.push("/endpoints");
|
|
router.refresh();
|
|
}
|
|
|
|
return (
|
|
<PageHero
|
|
title={endpoint.name}
|
|
description={
|
|
<span className="break-all">
|
|
{endpoint.baseUrl}
|
|
{endpoint.hasApiKey ? " · API key set" : ""}
|
|
</span>
|
|
}
|
|
painting={{ view: 0.55, focus: [0.75, 0.35], anchor: [0.65, 0.35] }}
|
|
actions={
|
|
<>
|
|
<EndpointStatus probe={probe} />
|
|
<Button variant="outline" onClick={test} disabled={testing}>
|
|
{testing ? (
|
|
<Loader2Icon className="animate-spin" />
|
|
) : (
|
|
<PlugZapIcon />
|
|
)}
|
|
Test connection
|
|
</Button>
|
|
<Link
|
|
href={`/endpoints/${endpoint.id}/edit`}
|
|
className={buttonVariants({ variant: "outline" })}
|
|
>
|
|
<PencilIcon />
|
|
Edit
|
|
</Link>
|
|
<AlertDialog>
|
|
<AlertDialogTrigger
|
|
render={
|
|
<Button
|
|
variant="outline"
|
|
className="text-destructive hover:bg-destructive/10 hover:text-destructive"
|
|
/>
|
|
}
|
|
>
|
|
<Trash2Icon />
|
|
Delete
|
|
</AlertDialogTrigger>
|
|
<AlertDialogContent>
|
|
<AlertDialogHeader>
|
|
<AlertDialogTitle>Delete {endpoint.name}?</AlertDialogTitle>
|
|
<AlertDialogDescription>
|
|
The endpoint and its stored API key are removed.
|
|
{runCount > 0
|
|
? ` Its ${runCount} run${runCount === 1 ? "" : "s"} stay, with what they recorded.`
|
|
: ""}
|
|
</AlertDialogDescription>
|
|
</AlertDialogHeader>
|
|
<AlertDialogFooter>
|
|
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
<AlertDialogAction variant="destructive" onClick={remove}>
|
|
Delete
|
|
</AlertDialogAction>
|
|
</AlertDialogFooter>
|
|
</AlertDialogContent>
|
|
</AlertDialog>
|
|
</>
|
|
}
|
|
>
|
|
{probe && <ProbeResult probe={probe} />}
|
|
{children}
|
|
</PageHero>
|
|
);
|
|
}
|