2024-09-13 05:43:05 -07:00
|
|
|
import { Table } from "@mantine/core";
|
2024-02-21 02:13:48 -08:00
|
|
|
import { useSuspenseAPIQuery } from "../api/api";
|
|
|
|
import { IconRun, IconWall } from "@tabler/icons-react";
|
2024-04-03 05:46:55 -07:00
|
|
|
import { formatTimestamp } from "../lib/formatTime";
|
2024-09-09 02:13:22 -07:00
|
|
|
import { useSettings } from "../state/settingsSlice";
|
2024-09-13 05:43:05 -07:00
|
|
|
import InfoPageCard from "../components/InfoPageCard";
|
|
|
|
import InfoPageStack from "../components/InfoPageStack";
|
2024-02-21 02:13:48 -08:00
|
|
|
|
2024-03-07 04:16:54 -08:00
|
|
|
export default function StatusPage() {
|
2024-03-07 12:00:43 -08:00
|
|
|
const { data: buildinfo } = useSuspenseAPIQuery<Record<string, string>>({
|
|
|
|
path: `/status/buildinfo`,
|
|
|
|
});
|
|
|
|
const { data: runtimeinfo } = useSuspenseAPIQuery<Record<string, string>>({
|
|
|
|
path: `/status/runtimeinfo`,
|
|
|
|
});
|
2024-02-21 02:13:48 -08:00
|
|
|
|
2024-09-09 02:13:22 -07:00
|
|
|
const { useLocalTime } = useSettings();
|
|
|
|
|
|
|
|
const statusConfig: Record<
|
|
|
|
string,
|
|
|
|
{
|
|
|
|
title?: string;
|
|
|
|
formatValue?: (v: string | boolean) => string;
|
|
|
|
}
|
|
|
|
> = {
|
|
|
|
startTime: {
|
|
|
|
title: "Start time",
|
|
|
|
formatValue: (v: string | boolean) =>
|
|
|
|
formatTimestamp(new Date(v as string).valueOf() / 1000, useLocalTime),
|
|
|
|
},
|
|
|
|
CWD: { title: "Working directory" },
|
|
|
|
reloadConfigSuccess: {
|
|
|
|
title: "Configuration reload",
|
|
|
|
formatValue: (v: string | boolean) => (v ? "Successful" : "Unsuccessful"),
|
|
|
|
},
|
|
|
|
lastConfigTime: {
|
|
|
|
title: "Last successful configuration reload",
|
|
|
|
formatValue: (v: string | boolean) =>
|
|
|
|
formatTimestamp(new Date(v as string).valueOf() / 1000, useLocalTime),
|
|
|
|
},
|
|
|
|
corruptionCount: { title: "WAL corruptions" },
|
|
|
|
goroutineCount: { title: "Goroutines" },
|
|
|
|
storageRetention: { title: "Storage retention" },
|
|
|
|
};
|
|
|
|
|
2024-02-21 02:13:48 -08:00
|
|
|
return (
|
2024-09-13 05:43:05 -07:00
|
|
|
<InfoPageStack>
|
|
|
|
<InfoPageCard title="Build information" icon={IconWall}>
|
2024-02-21 02:13:48 -08:00
|
|
|
<Table layout="fixed">
|
|
|
|
<Table.Tbody>
|
|
|
|
{Object.entries(buildinfo.data).map(([k, v]) => (
|
|
|
|
<Table.Tr key={k}>
|
|
|
|
<Table.Th style={{ textTransform: "capitalize" }}>{k}</Table.Th>
|
|
|
|
<Table.Td>{v}</Table.Td>
|
|
|
|
</Table.Tr>
|
|
|
|
))}
|
|
|
|
</Table.Tbody>
|
|
|
|
</Table>
|
2024-09-13 05:43:05 -07:00
|
|
|
</InfoPageCard>
|
|
|
|
<InfoPageCard title="Runtime information" icon={IconRun}>
|
2024-02-21 02:13:48 -08:00
|
|
|
<Table layout="fixed">
|
|
|
|
<Table.Tbody>
|
|
|
|
{Object.entries(runtimeinfo.data).map(([k, v]) => {
|
|
|
|
const { title = k, formatValue = (val: string) => val } =
|
|
|
|
statusConfig[k] || {};
|
|
|
|
return (
|
|
|
|
<Table.Tr key={k}>
|
|
|
|
<Table.Th style={{ textTransform: "capitalize" }}>
|
|
|
|
{title}
|
|
|
|
</Table.Th>
|
|
|
|
<Table.Td>{formatValue(v)}</Table.Td>
|
|
|
|
</Table.Tr>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</Table.Tbody>
|
|
|
|
</Table>
|
2024-09-13 05:43:05 -07:00
|
|
|
</InfoPageCard>
|
|
|
|
</InfoPageStack>
|
2024-02-21 02:13:48 -08:00
|
|
|
);
|
|
|
|
}
|