blob: 62eccf6f27c15fbd6ef8984b20ce7b326cb82826 [file] [log] [blame]
gio5f2f1002025-03-20 18:38:48 +04001import { useNodes } from "@xyflow/react";
2import { AppNode, nodeLabel, ServiceNode } from "./lib/state";
3import { useMemo } from "react";
4import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from "./components/ui/table";
5
6function ingress(nodes: AppNode[]) {
giod0026612025-05-08 13:00:36 +00007 const nm = new Map(nodes.map((n) => [n.id, n]));
8 return nodes
9 .filter((n) => n.type === "gateway-https")
10 .map((i) => {
11 console.log(i.data);
12 if (!i.data || !i.data.network || !i.data.subdomain) {
13 return null;
14 }
15 if (!i.data.https || !i.data.https.serviceId || !i.data.https.portId) {
16 return null;
17 }
18 console.log("1231");
19 const svc = nm.get(i.data.https.serviceId)! as ServiceNode;
20 const port = svc.data.ports.find((p) => p.id === i.data.https!.portId)!;
21 console.log({ svc, port });
22 return {
23 id: `${i.id} - ${port.id}`,
24 service: svc,
25 port: port,
26 endpoint: `https://${i.data.subdomain}.${i.data.network}`,
27 };
28 })
29 .filter((i) => i != null);
gio5f2f1002025-03-20 18:38:48 +040030}
31
32export function Deployment() {
giod0026612025-05-08 13:00:36 +000033 const nodes = useNodes<AppNode>();
34 const ing = useMemo(() => ingress(nodes), [nodes]);
35 return (
36 <>
37 <Table>
38 <TableCaption>HTTPS Gateways</TableCaption>
39 <TableHeader>
40 <TableRow>
41 <TableHead>Service</TableHead>
42 <TableHead>Port</TableHead>
43 <TableHead>Endpoint</TableHead>
44 </TableRow>
45 </TableHeader>
46 <TableBody>
47 {ing.map((i) => (
48 <TableRow>
49 <TableCell>{nodeLabel(i.service)}</TableCell>
50 <TableCell>{i.port.name}</TableCell>
51 <TableCell>
52 <a href={i.endpoint} target="_blank">
53 {i.endpoint}
54 </a>
55 </TableCell>
56 </TableRow>
57 ))}
58 </TableBody>
59 </Table>
60 </>
61 );
62}