From eaacfd35ae003d802d45a11f8f60ac6b61c4b6c1 Mon Sep 17 00:00:00 2001 From: Cannon Lock Date: Mon, 27 Nov 2023 13:27:17 -0600 Subject: [PATCH] Federation Overview #221 - Implements Federation overview which provides a series of links to all Federation components - Quiet Failure Closes #221 --- origin_ui/src/app/(dashboard)/config/page.tsx | 2 +- origin_ui/src/app/(dashboard)/page.tsx | 4 + .../src/components/FederationOverview.tsx | 85 +++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 origin_ui/src/components/FederationOverview.tsx diff --git a/origin_ui/src/app/(dashboard)/config/page.tsx b/origin_ui/src/app/(dashboard)/config/page.tsx index 240b13b04..8043035b5 100644 --- a/origin_ui/src/app/(dashboard)/config/page.tsx +++ b/origin_ui/src/app/(dashboard)/config/page.tsx @@ -35,7 +35,7 @@ import {isLoggedIn} from "@/helpers/login"; type duration = number | `${number}${"ns" | "us" | "µs" | "ms" |"s" | "m" | "h"}`; -type Config = { +export type Config = { [key: string]: ConfigValue } diff --git a/origin_ui/src/app/(dashboard)/page.tsx b/origin_ui/src/app/(dashboard)/page.tsx index a777ce34d..ed1823c14 100644 --- a/origin_ui/src/app/(dashboard)/page.tsx +++ b/origin_ui/src/app/(dashboard)/page.tsx @@ -24,6 +24,7 @@ import StatusBox from "@/components/StatusBox"; import {TimeDuration} from "@/components/graphs/prometheus"; import {Box, Grid} from "@mui/material"; +import FederationOverview from "@/components/FederationOverview"; export default function Home() { @@ -77,6 +78,9 @@ export default function Home() { + + + diff --git a/origin_ui/src/components/FederationOverview.tsx b/origin_ui/src/components/FederationOverview.tsx new file mode 100644 index 000000000..3201f3023 --- /dev/null +++ b/origin_ui/src/components/FederationOverview.tsx @@ -0,0 +1,85 @@ +'use client' + +import LaunchIcon from '@mui/icons-material/Launch'; +import {useEffect, useState} from "react"; +import {Config} from "@/app/(dashboard)/config/page"; +import {Box, Typography} from "@mui/material"; +import {isLoggedIn} from "@/helpers/login"; +import Link from "next/link"; + + +const LinkBox = ({href, text} : {href: string, text: string}) => { + return ( + + + + {text} + + + + + + + ) +} + +const FederationOverview = () => { + + const [config, setConfig] = useState<{ [key: string] : string | undefined} | undefined>(undefined) + + let getConfig = async () => { + + //Check if the user is logged in + if(!(await isLoggedIn())){ + window.location.replace("/view/login/") + } + + let response = await fetch("/api/v1.0/config") + if(response.ok) { + const responseData = await response.json() as Config + + setConfig({ + JwkUrl: (responseData?.Federation as Config)?.NamespaceUrl as undefined | string, + NamespaceUrl: (responseData?.Federation as Config)?.NamespaceUrl as undefined | string, + DirectorUrl: (responseData?.Federation as Config)?.DirectorUrl as undefined | string, + TopologyNamespaceUrl: (responseData?.Federation as Config)?.TopologyNamespaceUrl as undefined | string, + DiscoveryUrl: (responseData?.Federation as Config)?.DiscoveryUrl as undefined | string, + }) + } else { + console.error("Failed to fetch config for Federation Overview, response status: " + response.status) + } + } + + useEffect(() => { + getConfig() + }, []) + + if(config === undefined) { + return + } + + return ( + + + {!Object.values(config).every(x => x == undefined) ? Federation Overview : null} + {config?.NamespaceUrl ? + : null + } + {config?.DirectorUrl ? + : null + } + {config?.TopologyNamespaceUrl ? + : null + } + {config?.DiscoveryUrl ? + : null + } + {config?.JwkUrl ? + : null + } + + + ) +} + +export default FederationOverview; \ No newline at end of file