import React, { useState } from "react"; import { Button, ListGroup, Collapse } from "react-bootstrap"; import { Dash, ChevronDown, ChevronRight, CircleFill, } from "react-bootstrap-icons"; import { Container, Row, Col, Table, Card } from "react-bootstrap"; import { atom, useAtomValue } from "jotai"; import { atomWithQuery } from "jotai-tanstack-query"; const diagQueryFn = async () => { const resp = await fetch("api/diagnostics"); if (!resp.ok) { throw new Error("Network response was not ok"); } return resp.json(); }; const diagQueryAtom = atomWithQuery(() => ({ queryKey: ["diagnostics"], queryFn: diagQueryFn, })); const diagAtom = atom((get) => { const diag = get(diagQueryAtom); if (diag.isPending) { return "Loading..."; } if (diag.isError) { return "Error loading!"; } if (!diag.data.status) { return "Failed to get diagnostic information."; } return diag.data.message; }); export function DiagnosticsCard() { const diagnostics = useAtomValue(diagAtom); const diagContent = () => { if (typeof diagnostics === "string" || diagnostics instanceof String) { return
 {diagnostics} 
; } return ; }; return ( Diagnostics {diagContent()} ); } function TreeView(props: Any) { const data = props.data; return ( {data.children.map((node) => ( ))} ); } function LevelIndicator(props: Any) { const level = props.level; if (level == "ERROR") { return ; } if (level == "WARN") { return ; } if (level == "OK") { return ; } return ; } function MessageText(props: Any) { if (props.message === "") { return
; } return
Message: {props.message}
; } function ValuesTable(props: Any) { const values = props.values; if (Object.keys(values).length === 0) { return
; } return ( {Object.entries(values).map(([key, value]) => ( ))}
Key Value
{key} {value}
); } function StatusContent(props: Any) { const status = props.status; console.log(status); return (

{status.name}

); } function DirectionIcon(props: Any) { let icon = ; if (props.isOpen) { icon = ; } if (!props.hasChildren) { icon = ; } return ( ); } function ChildStatuses(props: Any) { const isOpen = props.isOpen; const node = props.node; return (
{node.children.map((child) => ( ))}
); } function SingleNode(props: Any) { const node = props.node; const [isOpen, setIsOpen] = useState(false); const hasChildren = node.children && node.children.length > 0; const openFunction = () => { if (hasChildren) { setIsOpen(!isOpen); } }; return ( ); }