diff --git a/ui/frontend/build_src/src/api/index.ts b/ui/frontend/build_src/src/api/index.ts index 4da3f7fe..53566f25 100644 --- a/ui/frontend/build_src/src/api/index.ts +++ b/ui/frontend/build_src/src/api/index.ts @@ -31,6 +31,15 @@ export const getSaveDirectory = async () => { return data[0]; }; + +export const getConfig = async () => { + const response = await fetch(`${API_URL}/app_config`); + console.log('getConfig response', response); + const data = await response.json(); + return data; +}; + + /** * post a new request for an image */ diff --git a/ui/frontend/build_src/src/components/organisms/headerDisplay/headerDisplay.css b/ui/frontend/build_src/src/components/organisms/headerDisplay/headerDisplay.css deleted file mode 100644 index 4ca03c3d..00000000 --- a/ui/frontend/build_src/src/components/organisms/headerDisplay/headerDisplay.css +++ /dev/null @@ -1,10 +0,0 @@ -.header-display { - color: #ffffff; - display: flex; - align-items: center; - justify-content: center; -} - -.status-display { - margin-left: 10px; -} diff --git a/ui/frontend/build_src/src/components/organisms/headerDisplay/headerDisplay.css.ts b/ui/frontend/build_src/src/components/organisms/headerDisplay/headerDisplay.css.ts new file mode 100644 index 00000000..61cc6273 --- /dev/null +++ b/ui/frontend/build_src/src/components/organisms/headerDisplay/headerDisplay.css.ts @@ -0,0 +1,15 @@ +import { style, globalStyle } from "@vanilla-extract/css"; + +export const HeaderDisplayMain = style({ + color: "#ffffff", + display: "flex", + alignItems: "center", + justifyContent: "center", +}); + +globalStyle(`${HeaderDisplayMain} > h1`, { + fontSize: "1.5em", + fontWeight: "bold", + marginRight: "10px", +}); + diff --git a/ui/frontend/build_src/src/components/organisms/headerDisplay/index.tsx b/ui/frontend/build_src/src/components/organisms/headerDisplay/index.tsx index 91c5277d..bc6ed6ba 100644 --- a/ui/frontend/build_src/src/components/organisms/headerDisplay/index.tsx +++ b/ui/frontend/build_src/src/components/organisms/headerDisplay/index.tsx @@ -1,13 +1,47 @@ -import React from "react"; +import React, { useEffect, useState } from "react"; + +import { useQuery } from "@tanstack/react-query"; +import { getConfig } from "../../../api"; import StatusDisplay from "./statusDisplay"; -import "./headerDisplay.css"; +import { + HeaderDisplayMain +} from //@ts-ignore + './headerDisplay.css.ts' + export default function HeaderDisplay() { + + // but this will be moved to the status display when it is created + const { status, data } = useQuery(["config"], getConfig) + + const [version, setVersion] = useState("2.1.0"); + const [release, setRelease] = useState(''); + + useEffect(() => { + + if (status === 'success') { + // TODO also pass down the actual version + const { update_branch } = data; + + // just hard coded for now + setVersion('v2.1'); + + if (update_branch === 'main') { + setRelease('(stable)') + } + else { + setRelease('(beta)') + } + } + + }, [status, data, setVersion, setVersion]) + + return ( -