mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-07-29 01:18:28 -06:00
Added API Server Health Check to Status Bar
This commit is contained in:
@ -1,9 +1,17 @@
|
|||||||
////////// PROJECT FILE SEPARATION LINE ////////// CODE AFTER THIS LINE ARE FROM: <ProjectRoot>/Data/WebUI/src/Status_Bar.jsx
|
////////// PROJECT FILE SEPARATION LINE ////////// CODE AFTER THIS LINE ARE FROM: <ProjectRoot>/Data/WebUI/src/Status_Bar.jsx
|
||||||
|
|
||||||
import React from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Box, Button, Divider } from "@mui/material";
|
import { Box, Button, Divider } from "@mui/material";
|
||||||
|
|
||||||
export default function StatusBar() {
|
export default function StatusBar() {
|
||||||
|
const [apiStatus, setApiStatus] = useState("checking");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetch("/health")
|
||||||
|
.then((res) => (res.ok ? setApiStatus("online") : setApiStatus("offline")))
|
||||||
|
.catch(() => setApiStatus("offline"));
|
||||||
|
}, []);
|
||||||
|
|
||||||
const applyRate = () => {
|
const applyRate = () => {
|
||||||
const val = parseInt(
|
const val = parseInt(
|
||||||
document.getElementById("updateRateInput")?.value
|
document.getElementById("updateRateInput")?.value
|
||||||
@ -26,15 +34,12 @@ export default function StatusBar() {
|
|||||||
py: 1,
|
py: 1,
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
gap: 2
|
justifyContent: "space-between"
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<Box sx={{ display: "flex", alignItems: "center", gap: 2 }}>
|
||||||
<b>Nodes</b>: <span id="nodeCount">0</span>
|
<b>Nodes</b>: <span id="nodeCount">0</span>
|
||||||
<Divider
|
<Divider orientation="vertical" flexItem sx={{ borderColor: "#444" }} />
|
||||||
orientation="vertical"
|
|
||||||
flexItem
|
|
||||||
sx={{ borderColor: "#444" }}
|
|
||||||
/>
|
|
||||||
<b>Update Rate (ms):</b>
|
<b>Update Rate (ms):</b>
|
||||||
<input
|
<input
|
||||||
id="updateRateInput"
|
id="updateRateInput"
|
||||||
@ -67,5 +72,22 @@ export default function StatusBar() {
|
|||||||
Apply Rate
|
Apply Rate
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
<Box sx={{ fontSize: "1.0rem", display: "flex", alignItems: "center", gap: 1 }}>
|
||||||
|
<strong style={{ color: "#58a6ff" }}>API Server</strong>:
|
||||||
|
<a
|
||||||
|
href="http://localhost:5000/health"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
style={{
|
||||||
|
color: apiStatus === "online" ? "#00d18c" : "#ff4f4f",
|
||||||
|
textDecoration: "none",
|
||||||
|
fontWeight: "bold"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{apiStatus === "checking" ? "..." : apiStatus.charAt(0).toUpperCase() + apiStatus.slice(1)}
|
||||||
|
</a>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user