diff --git a/src/components/MetricsPlot.tsx b/src/components/MetricsPlot.tsx index e600397..cc4c011 100644 --- a/src/components/MetricsPlot.tsx +++ b/src/components/MetricsPlot.tsx @@ -1,13 +1,19 @@ import React from "react"; import Plot from "react-plotly.js"; import { Data } from "plotly.js"; +import ProgressBar from "./ProgressBar"; interface MetricsPlotProps { + isLoadingMetrics: boolean; plotData: Data[]; layout: Partial; } -const MetricsPlot: React.FC = ({ plotData, layout }) => { +const MetricsPlot: React.FC = ({ + isLoadingMetrics, + plotData, + layout, +}) => { const extendedLayout: Partial = { ...layout, xaxis: { @@ -39,16 +45,23 @@ const MetricsPlot: React.FC = ({ plotData, layout }) => { }, }; - console.log(extendedLayout); - return ( - + <> + {isLoadingMetrics ? ( +
+ Loading metrics... + +
+ ) : ( + + )} + ); }; diff --git a/src/hooks/useFetchMetrics.ts b/src/hooks/useFetchMetrics.ts index dee0e34..a92e9c5 100644 --- a/src/hooks/useFetchMetrics.ts +++ b/src/hooks/useFetchMetrics.ts @@ -2,7 +2,7 @@ import { useState, useEffect } from "react"; import { MetricData, Node } from "../types"; const useFetchMetrics = (selectedNode: Node | undefined, nodes: Node[]) => { - const [isLoadingMetrics, setIsLoadingMetrics] = useState(false); + const [isLoadingMetrics, setIsLoadingMetrics] = useState(true); const [metricData, setMetricData] = useState(null); useEffect(() => { diff --git a/src/pages/NodeMetricsPage.tsx b/src/pages/NodeMetricsPage.tsx index 4080934..fdcccb8 100644 --- a/src/pages/NodeMetricsPage.tsx +++ b/src/pages/NodeMetricsPage.tsx @@ -5,7 +5,6 @@ import useFetchNodes from "../hooks/useFetchNodes"; import useFetchMetrics from "../hooks/useFetchMetrics"; import useFilteredNodes from "../hooks/useFilteredNodes"; import { MetricData, Node } from "../types"; -import ProgressBar from "../components/ProgressBar"; import NodeList from "../components/NodeList"; import { Spinner } from "@aleph-front/core"; @@ -92,17 +91,14 @@ const NodeMetricsPage: React.FC = () => { >
- {isLoadingMetrics ? ( -
- Loading metrics... - -
- ) : metricData ? ( - <> - - - ) : isLoadingNodes ? ( + {isLoadingNodes ? ( + ) : selectedNode ? ( + ) : (
Select a node to see its metrics.