diff --git a/internal/site/src/components/routes/system.tsx b/internal/site/src/components/routes/system.tsx index 7af460be..4d314ace 100644 --- a/internal/site/src/components/routes/system.tsx +++ b/internal/site/src/components/routes/system.tsx @@ -41,6 +41,7 @@ import { useIntersectionObserver } from "@/lib/use-intersection-observer" import { chartTimeData, cn, + compareSemVer, debounce, decimalString, formatBytes, @@ -170,8 +171,9 @@ export default memo(function SystemDetail({ id }: { id: string }) { const [system, setSystem] = useState({} as SystemRecord) const [systemStats, setSystemStats] = useState([] as SystemStatsRecord[]) const [containerData, setContainerData] = useState([] as ChartData["containerData"]) - const netCardRef = useRef(null) + const temperatureChartRef = useRef(null) const persistChartTime = useRef(false) + const [bottomSpacing, setBottomSpacing] = useState(0) const [chartLoading, setChartLoading] = useState(true) const isLongerChart = !["1m", "1h"].includes(chartTime) // true if chart time is not 1m or 1h const userSettings = $userSettings.get() @@ -396,6 +398,21 @@ export default memo(function SystemDetail({ id }: { id: string }) { }[] }, [system, t]) + /** Space for tooltip if more than 10 sensors and no containers table */ + useEffect(() => { + const sensors = Object.keys(systemStats.at(-1)?.stats.t ?? {}) + if (!temperatureChartRef.current || sensors.length < 10 || containerData.length > 0) { + setBottomSpacing(0) + return + } + const tooltipHeight = (sensors.length - 10) * 17.8 - 40 + const wrapperEl = chartWrapRef.current as HTMLDivElement + const wrapperRect = wrapperEl.getBoundingClientRect() + const chartRect = temperatureChartRef.current.getBoundingClientRect() + const distanceToBottom = wrapperRect.bottom - chartRect.bottom + setBottomSpacing(tooltipHeight - distanceToBottom) + }, []) + // keyboard navigation between systems useEffect(() => { if (!systems.length) { @@ -728,26 +745,20 @@ export default memo(function SystemDetail({ id }: { id: string }) { {containerFilterBar && containerData.length > 0 && ( -
- - - -
+ + )} {/* Swap chart */} @@ -777,16 +788,21 @@ export default memo(function SystemDetail({ id }: { id: string }) { {/* Temperature chart */} {systemStats.at(-1)?.stats.t && ( - } - legend={Object.keys(systemStats.at(-1)?.stats.t ?? {}).length < 12} +
- - + } + legend={Object.keys(systemStats.at(-1)?.stats.t ?? {}).length < 12} + > + + +
)} {/* Battery chart */} @@ -974,10 +990,13 @@ export default memo(function SystemDetail({ id }: { id: string }) { })} )} - {id && containerData.length > 0 && ( + {containerData.length > 0 && compareSemVer(chartData.agentVersion, parseSemVer("0.14.0")) >= 0 && ( )} + + {/* add space for tooltip if more than 12 containers */} + {bottomSpacing > 0 && } ) }) diff --git a/supplemental/CHANGELOG.md b/supplemental/CHANGELOG.md index 044613b5..0e29fc64 100644 --- a/supplemental/CHANGELOG.md +++ b/supplemental/CHANGELOG.md @@ -2,6 +2,8 @@ - Add `MFA_OTP` environment variable to enable email-based one-time password for users and/or superusers. +- Add spacing for long temperature chart tooltip. (#1299) + ## 0.14.0 - Add `/containers` page for viewing current status of all running containers. (#928)