Skip to content

Commit 4bdae1e

Browse files
author
Ed Safford
committed
Placate Copilot, add config.title to menu header.
1 parent 842e25a commit 4bdae1e

File tree

5 files changed

+92
-56
lines changed

5 files changed

+92
-56
lines changed

UIdev/ObsMon/src/App.jsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function App() {
2424
const [qTypes, setQTypes] = useState([]);
2525
const [tTypes, setTTypes] = useState([]);
2626
const [uvTypes, setUvTypes] = useState([]);
27+
const [config, setConfig] = useState(null);
2728

2829
useEffect(() => {
2930
fetch(withBase('data/gpstypes.json'), { cache: 'no-store' })
@@ -88,6 +89,17 @@ function App() {
8889
.catch(err => console.error("Failed to load geostationarySatellites:", err));
8990
}, []);
9091

92+
// Fetch config on mount
93+
useEffect(() => {
94+
fetch(withBase("data/configIndex.json"))
95+
.then(res => {
96+
if (!res.ok) throw new Error(`HTTP error! Status: ${res.status}`);
97+
return res.json();
98+
})
99+
.then(data => setConfig(data))
100+
.catch(err => console.error("Failed to load configIndex.json:", err));
101+
}, []);
102+
91103
const toggleSection = (name) => {
92104
setOpenSection(openSection === name ? null : name);
93105
};
@@ -136,7 +148,17 @@ function App() {
136148

137149
<div className="flex min-h-screen">
138150
<aside className="w-64 shrink-0 bg-blue-100 p-4 border-r">
139-
<h1 className="text-lg font-bold mb-4 underline">Monitoring Dashboard</h1>
151+
<h1 className="text-lg font-bold mb-4">
152+
<span className="underline" style={{ display: 'block', textAlign: 'center', marginBottom: '0.1rem' }} >
153+
Monitoring Dashboard</span>
154+
155+
{/* Render config.name here if loaded */}
156+
{config?.name && (
157+
<span style={{ display: 'block', fontWeight: 'normal', textAlign: 'center', marginTop: '0.1rem', fontSize: '1rem' }}>
158+
{config.name}
159+
</span>
160+
)}
161+
</h1>
140162

141163
{/* Add current cycle below header */}
142164
<p className="text-base text-black mb-4">

UIdev/ObsMon/src/components/Home.jsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export default function Home() {
66
const [config, setConfig] = useState(null);
77

88
useEffect(() => {
9+
let isMounted = true; // Track if component is mounted
10+
911
fetch(withBase("data/configIndex.json"))
1012
.then((res) => {
1113
if (!res.ok) {
@@ -14,15 +16,27 @@ export default function Home() {
1416
return res.json();
1517
})
1618
.then((data) => {
17-
setConfig(data);
19+
if (isMounted) {
20+
setConfig(data);
21+
}
1822
})
1923
.catch((err) => {
20-
console.error("Failed to load config.json:", err);
24+
if (isMounted) {
25+
console.error("Failed to load configIndex.json:", err);
26+
}
2127
});
28+
29+
return () => {
30+
isMounted = false; // Cleanup flag on unmount
31+
};
2232
}, []);
2333

2434
if (!config) {
25-
return <div style={{ padding: "2rem" }}>Loading...</div>;
35+
return (
36+
<div style={{ padding: "2rem" }} role="status" aria-live="polite">
37+
Loading...
38+
</div>
39+
);
2640
}
2741

2842
return (

0 commit comments

Comments
 (0)