From f6fb273845162646a7e8ed011eeb35a9be1881c5 Mon Sep 17 00:00:00 2001 From: Oscar Thomson Date: Wed, 8 Jul 2026 15:17:29 +0000 Subject: [PATCH 1/2] Updated cluster settings page to show what pool they're in --- frontend/app/components/ClusterSettings.jsx | 387 ++++++++++---------- 1 file changed, 202 insertions(+), 185 deletions(-) diff --git a/frontend/app/components/ClusterSettings.jsx b/frontend/app/components/ClusterSettings.jsx index 87e0d43..a31bdea 100644 --- a/frontend/app/components/ClusterSettings.jsx +++ b/frontend/app/components/ClusterSettings.jsx @@ -8,7 +8,7 @@ import { useRouter, useSearchParams } from 'next/navigation'; import { FaDatabase, FaUser } from 'react-icons/fa'; import { IoIosArrowForward } from 'react-icons/io'; -export default function ClusterSettingsPage() { +export default function ClusterSettingsPage () { const searchParams = useSearchParams(); const clusterId = searchParams.get('id'); @@ -19,8 +19,23 @@ export default function ClusterSettingsPage() { try { const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/hpc`); const data = await res.json(); + const clusterResponse = data.body ?? []; + const enrichedClusters = await Promise.all( + clusterResponse.map(async cluster => { + const poolRes = await fetch( + `${process.env.NEXT_PUBLIC_API_URL}/pool/id/${cluster.poolId}` + ); + const poolData = await poolRes.json(); + return { + ...cluster, + pool: poolData.body ?? [] + }; + }) + ); + + console.log(enrichedClusters); - setClusters(data.body ?? []); + setClusters(enrichedClusters); } catch (err) { console.error('Failed to fetch clusters:', err); setClusters([]); @@ -33,7 +48,7 @@ export default function ClusterSettingsPage() { loadClusters(); }, [loadClusters]); - const cluster = clusters.find((cluster) => cluster.id === clusterId); + const cluster = clusters.find(cluster => cluster.id === clusterId); const [activeTab, setActiveTab] = useState('instructions'); const [steps, setSteps] = useState([]); const [loadingSteps, setLoadingSteps] = useState(false); @@ -72,7 +87,7 @@ export default function ClusterSettingsPage() { const recentReports = useMemo(() => { const oneWeekAgo = Date.now() - 7 * 24 * 60 * 60 * 1000; - return (reports ?? []).filter((report) => { + return (reports ?? []).filter(report => { return report.startDate >= oneWeekAgo; }); }, [reports]); @@ -123,7 +138,7 @@ export default function ClusterSettingsPage() { }, [clusterId, getSteps]); useEffect(() => { - async function getReports() { + async function getReports () { if (!clusterId) return; try { @@ -163,7 +178,7 @@ export default function ClusterSettingsPage() { getReports(); }, [clusterId]); - async function deleteMethod(methodId) { + async function deleteMethod (methodId) { try { const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/method/${methodId}`, { method: 'DELETE', @@ -183,7 +198,7 @@ export default function ClusterSettingsPage() { } } - async function addNewMethod(instructionId, content) { + async function addNewMethod (instructionId, content) { try { const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/method`, { method: 'POST', @@ -212,7 +227,7 @@ export default function ClusterSettingsPage() { } } - async function updateMethod(methodId, content) { + async function updateMethod (methodId, content) { try { const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/method`, { method: 'PATCH', @@ -241,7 +256,7 @@ export default function ClusterSettingsPage() { } } - async function updateInstruction(id, title, description, expectedTime, bad, good, position) { + async function updateInstruction (id, title, description, expectedTime, bad, good, position) { try { const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/instruction`, { method: 'PATCH', @@ -270,7 +285,7 @@ export default function ClusterSettingsPage() { } } - async function addInstruction() { + async function addInstruction () { try { const title = newInstructionTitle.trim(); const description = newInstructionDescription.trim(); @@ -314,7 +329,7 @@ export default function ClusterSettingsPage() { } } - async function deleteInstruction(id) { + async function deleteInstruction (id) { try { const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/instruction/${id}`, { method: 'DELETE', @@ -336,67 +351,69 @@ export default function ClusterSettingsPage() { if (loadingClusters) { return ( -
-

Loading cluster...

+
+

Loading cluster...

); } return ( -
-
-
+
+
+
{/* Header */} -
-
-