From 874bdbcae55efb0ac910bbd2edaa3ca6381f3fde Mon Sep 17 00:00:00 2001 From: yashsinghcodes Date: Mon, 9 Feb 2026 13:26:29 +0530 Subject: [PATCH] fix opensearch prefix button on health page --- frontend/src/components/HealthPage.jsx | 59 +++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/HealthPage.jsx b/frontend/src/components/HealthPage.jsx index 287ad9b1..b60a46be 100644 --- a/frontend/src/components/HealthPage.jsx +++ b/frontend/src/components/HealthPage.jsx @@ -24,6 +24,7 @@ const HealthPage = (props) => { const [liveExecutionsRange, setLiveExecutionsRange] = useState('1h'); // Default to 1h const [isHealthLoading, setIsHealthLoading] = useState(false); // Loading state for HealthBarChart const [isLiveExecutionsLoading, setIsLiveExecutionsLoading] = useState(false); // Loading state for LiveExecutionsChart + const [isFixingOpensearchPrefix, setIsFixingOpensearchPrefix] = useState(false); const isCloud = (window.location.host === "localhost:3002" || window.location.host === "shuffler.io") ? true : (import.meta.env.VITE_IS_SSR === "true"); @@ -364,19 +365,63 @@ const HealthPage = (props) => { } }; + const handleFixOpensearchPrefix = async () => { + if (isFixingOpensearchPrefix) { + return; + } + + setIsFixingOpensearchPrefix(true); + try { + const response = await fetch(`${globalUrl}/api/v1/health/opensearch-prefix`, { + method: "POST", + headers: { + "Content-Type": "application/json", + Accept: "application/json", + }, + credentials: "include", + }); + + const data = await response.json(); + if (!response.ok || !data.success) { + const reason = data && data.reason ? data.reason : "Failed to fix opensearch prefix"; + throw new Error(reason); + } + + const reindexed = data.reindexed ? data.reindexed.length : 0; + const aliasUpdates = data.alias_updates ? data.alias_updates.length : 0; + const deleted = data.deleted_indices ? data.deleted_indices.length : 0; + toast.success(`Fixed opensearch prefix (reindexed ${reindexed}, aliases ${aliasUpdates}, deleted ${deleted})`); + } catch (error) { + console.error("Error fixing opensearch prefix:", error); + toast.error(error.message || "Failed to fix opensearch prefix"); + } finally { + setIsFixingOpensearchPrefix(false); + } + }; + const healthBarData = updateChartData() return (
{/* Health Bar Chart Section */} - - - - - - - +
+ + + + + + + + +
{/* Loading Bar for HealthBarChart */} {isHealthLoading && (