diff --git a/src/app/api/syshealth/route.ts b/src/app/api/syshealth/route.ts index 868a2f10..3721f772 100644 --- a/src/app/api/syshealth/route.ts +++ b/src/app/api/syshealth/route.ts @@ -4,41 +4,34 @@ import { connected } from '../../../api/mongoClient/dbClient'; import { isAuthenticated } from '../../../api/manager/auth'; import { LIVE_BASE_API_PATH } from '../../../constants'; +let liveApiUrl: string; +if (!process.env.LIVE_URL) { + liveApiUrl = 'LIVE_URL is not set in environment variables'; +} else { + liveApiUrl = new URL(LIVE_BASE_API_PATH, process.env.LIVE_URL).toString(); +} + export async function GET(): Promise { if (!(await isAuthenticated())) { return new NextResponse(`Not Authorized!`, { status: 403 }); } + const isConnectedToLive = await getIngests() .then(() => true) .catch(() => false); const isConnectedToDatabase = await connected().catch(() => false); - if (isConnectedToLive && isConnectedToDatabase) { - return new NextResponse( - JSON.stringify({ - message: 'Connected!', - database: { - connected: isConnectedToDatabase - }, - liveApi: { connected: isConnectedToLive } - }), - { - status: 200 - } - ); - } - const databaseUrl = new URL('', process.env.MONGODB_URI); return new NextResponse( JSON.stringify({ - message: 'Something went wrong with the connection!', + message: '', liveApi: { connected: isConnectedToLive, - url: new URL(LIVE_BASE_API_PATH, process.env.LIVE_URL) + url: liveApiUrl }, database: { connected: isConnectedToDatabase, @@ -46,7 +39,7 @@ export async function GET(): Promise { } }), { - status: 500 + status: 200 } ); } diff --git a/src/components/sideNav/SideNavConnections.tsx b/src/components/sideNav/SideNavConnections.tsx index a5e0fd27..7c6f0a28 100644 --- a/src/components/sideNav/SideNavConnections.tsx +++ b/src/components/sideNav/SideNavConnections.tsx @@ -28,17 +28,17 @@ const SideNavConnections = () => { const [appHealth, setAppHealth] = useState({}); const [allConnected, setAllConnected] = useState(false); const t = useTranslate(); + const [isAppHovered, setIsAppHovered] = useState(false); // TODO Maybe there is a better way to compare the objects. const checkConnections = useCallback(() => { checkApiConnections() .then((data) => { - if (JSON.stringify(data) !== JSON.stringify(connection)) - setConnection(data); - if (loading) setLoading(() => false); + setConnection(data); + setLoading(false); }) .catch(() => { - if (loading) setLoading(false); + setLoading(false); setConnection({}); }); }, []); @@ -46,8 +46,7 @@ const SideNavConnections = () => { const checkApp = useCallback(() => { checkAppHealth() .then((data) => { - if (JSON.stringify(data) !== JSON.stringify(appHealth)) - setAppHealth(data); + setAppHealth(data); }) .catch(() => { setAppHealth({}); @@ -89,14 +88,24 @@ const SideNavConnections = () => { ) : ( <>
setIsAppHovered(true)} + onMouseLeave={() => setIsAppHovered(false)} > {t('application')} + {isAppHovered && ( +
+ Application version: {appHealth?.version} +
+ )}
{ {t('system_controller')}