From ea7eb4566519b0af6e568fa7b76b659fe8779dec Mon Sep 17 00:00:00 2001 From: James Pace Date: Wed, 16 Sep 2026 19:49:38 -0400 Subject: [PATCH] Get identity and version number. --- src/Home.tsx | 36 +++++++++---------- src/Version.tsx | 56 +++++++++++++++++++++--------- src/components/AppNav.tsx | 2 +- src/components/DiagnosticsCard.tsx | 1 - 4 files changed, 57 insertions(+), 38 deletions(-) diff --git a/src/Home.tsx b/src/Home.tsx index 8059380..1023df0 100644 --- a/src/Home.tsx +++ b/src/Home.tsx @@ -14,12 +14,12 @@ import { atom, useAtomValue } from "jotai"; import { createQueryAtom } from "./utils/query.ts"; import { DiagnosticsCard } from "./components/DiagnosticsCard.tsx"; -const statusStringQueryAtom = createQueryAtom("status_string", "api/status", { +const identityStringQueryAtom = createQueryAtom("api/identity", { refetchInterval: 500, }); -const statusStringAtom = atom((get) => { - const response = get(statusStringQueryAtom); - if (response.isPending || response.isError || !response.data.status) { +const identityStringAtom = atom((get) => { + const response = get(identityStringQueryAtom); + if (response.isPending || response.isError) { return "N/A"; } return response.data.message; @@ -36,16 +36,14 @@ const uptimeAtom = atom((get) => { return response.data.uptime.toFixed(1); }); -function StatusCard() { - const statusString = useAtomValue(statusStringAtom); +function IdentityCard() { + const identityString = useAtomValue(identityStringAtom); return ( - - -

Status:

-
- -

{statusString}

-
+ + Identity + +
{identityString}
+
); } @@ -53,13 +51,11 @@ function StatusCard() { function UptimeCard() { const uptime = useAtomValue(uptimeAtom); return ( - - -

Uptime:

-
- + + Uptime +

{uptime}s

-
+
); } @@ -74,7 +70,7 @@ export function Home() { - + diff --git a/src/Version.tsx b/src/Version.tsx index 21ec85e..a6004b6 100644 --- a/src/Version.tsx +++ b/src/Version.tsx @@ -14,35 +14,59 @@ import { atom, useAtomValue } from "jotai"; import { createQueryAtom } from "./utils/query.ts"; import YAML from "yaml"; -const versionQueryAtom = createQueryAtom("api/build_info"); - -const versionAtom = atom((get) => { - const version = get(versionQueryAtom); - if (version.isPending) { +const buildInfoQueryAtom = createQueryAtom("api/build_info"); +const buildInfoAtom = atom((get) => { + const buildInfo = get(buildInfoQueryAtom); + if (buildInfo.isPending) { return "Loading..."; } - if (version.isError) { + if (buildInfo.isError) { return "Error loading!"; } - if (!version.data.status) { - return "Can not find version"; + if (!buildInfo.data.status) { + return "Can not find buildInfo"; } - return YAML.stringify(version.data.message); + return YAML.stringify(buildInfo.data.message); +}); + +const versionNumberQueryAtom = createQueryAtom("api/version_number"); +const versionNumberAtom = atom((get) => { + const versionNumber = get(versionNumberQueryAtom); + if (versionNumber.isPending || versionNumber.isError) { + return "..."; + } + if (!versionNumber.data.status) { + return "Can not find version number."; + } + return versionNumber.data.version; }); export function Version() { - let versionText = useAtomValue(versionAtom); + let buildInfoText = useAtomValue(buildInfoAtom); + let versionText = useAtomValue(versionNumberAtom); return (
- - project.yaml - -
{versionText}
-
-
+ + + + Version Number + {versionText} + + + + + + + project.yaml + +
{buildInfoText}
+
+
+ +
diff --git a/src/components/AppNav.tsx b/src/components/AppNav.tsx index 20686b5..694c71c 100644 --- a/src/components/AppNav.tsx +++ b/src/components/AppNav.tsx @@ -16,7 +16,7 @@ export function AppNav() { - J7s-Bridge + am_i_up diff --git a/src/components/DiagnosticsCard.tsx b/src/components/DiagnosticsCard.tsx index 9e847ed..e34c960 100644 --- a/src/components/DiagnosticsCard.tsx +++ b/src/components/DiagnosticsCard.tsx @@ -107,7 +107,6 @@ function ValuesTable(props: Any) { function StatusContent(props: Any) { const status = props.status; - console.log(status); return (