import { useStore } from "ra-core"; import { Box, Stack, Typography, Paper, Link, Chip, Divider, Tooltip, ChipProps } from "@mui/material"; import CheckIcon from '@mui/icons-material/Check'; import CloseIcon from "@mui/icons-material/Close"; import EngineeringIcon from '@mui/icons-material/Engineering'; import { ServerProcessResponse, ServerStatusComponent, ServerStatusResponse } from "../../synapse/dataProvider"; import ServerCommandsPanel from "./ServerCommandsPanel"; import { getTimeSince } from "../../utils/date"; const StatusChip = ({ isOkay, size = "medium", command }: { isOkay: boolean, size?: "small" | "medium", command?: string }) => { let label = "OK"; let icon = ; let color: ChipProps["color"] = "success"; if (!isOkay) { label = "Error"; icon = ; color = "error"; } if (command) { label = command; color = "warning"; icon = ; } return ( ); }; const ServerComponentText = ({ text }: { text: string }) => { return ; }; const ServerStatusPage = () => { const [serverStatus, setServerStatus] = useStore("serverStatus", { ok: false, success: false, host: "", results: [], }); const [ serverProcess, setServerProcess ] = useStore("serverProcess", { command: "", locked_at: "" }); const { command, locked_at } = serverProcess; const successCheck = serverStatus.success; const isOkay = serverStatus.ok; const host = serverStatus.host; const results = serverStatus.results; let groupedResults: Record = {}; for (const result of results) { if (!groupedResults[result.category]) { groupedResults[result.category] = []; } groupedResults[result.category].push(result); } if (!successCheck) { return ( Unable to fetch server status. Please try again later. ); } return ( Status: {host} {command && locked_at && ( Currently running: {command} (started {getTimeSince(locked_at)} ago) )} {Object.keys(groupedResults).map((category, idx) => ( {category} }> {groupedResults[category].map((result, idx) => ( {result.label.url ? ( ) : ( )} {result.reason && } {(!result.ok && result.help) && ( Learn more )} ))} ))} ); }; export default ServerStatusPage;