diff --git a/beszel/site/src/components/routes/system.tsx b/beszel/site/src/components/routes/system.tsx
index cdbabe9..38b1ae2 100644
--- a/beszel/site/src/components/routes/system.tsx
+++ b/beszel/site/src/components/routes/system.tsx
@@ -1,6 +1,6 @@
-import { $systems, pb, $chartTime, $containerFilter, $userSettings, $direction } from "@/lib/stores"
+import { $systems, pb, $chartTime, $containerFilter, $userSettings, $direction, $maxValues } from "@/lib/stores"
import { ChartData, ChartTimes, ContainerStatsRecord, GPUData, SystemRecord, SystemStatsRecord } from "@/types"
-import React, { lazy, useCallback, useEffect, useMemo, useRef, useState } from "react"
+import React, { lazy, memo, useCallback, useEffect, useMemo, useRef, useState } from "react"
import { Card, CardHeader, CardTitle, CardDescription } from "../ui/card"
import { useStore } from "@nanostores/react"
import Spinner from "../spinner"
@@ -98,10 +98,7 @@ export default function SystemDetail({ name }: { name: string }) {
const { _ } = useLingui()
const systems = useStore($systems)
const chartTime = useStore($chartTime)
- /** Max CPU toggle value */
- const cpuMaxStore = useState(false)
- const bandwidthMaxStore = useState(false)
- const diskIoMaxStore = useState(false)
+ const maxValues = useStore($maxValues)
const [grid, setGrid] = useLocalStorage("grid", true)
const [system, setSystem] = useState({} as SystemRecord)
const [systemStats, setSystemStats] = useState([] as SystemStatsRecord[])
@@ -121,9 +118,6 @@ export default function SystemDetail({ name }: { name: string }) {
setContainerData([])
setContainerFilterBar(null)
$containerFilter.set("")
- cpuMaxStore[1](false)
- bandwidthMaxStore[1](false)
- diskIoMaxStore[1](false)
}
}, [name])
@@ -291,6 +285,9 @@ export default function SystemDetail({ name }: { name: string }) {
return null
}
+ // select field for switching between avg and max values
+ const maxValSelect = isLongerChart ? : null
+
// if no data, show empty message
const dataEmpty = !chartLoading && chartData.systemStats.length === 0
const lastGpuVals = Object.values(systemStats.at(-1)?.stats.g ?? {})
@@ -385,9 +382,9 @@ export default function SystemDetail({ name }: { name: string }) {
grid={grid}
title={_(t`CPU Usage`)}
description={t`Average system-wide CPU utilization`}
- cornerEl={isLongerChart ? : null}
+ cornerEl={maxValSelect}
>
-
+
{containerFilterBar && (
@@ -432,19 +429,19 @@ export default function SystemDetail({ name }: { name: string }) {
grid={grid}
title={t`Disk I/O`}
description={t`Throughput of root filesystem`}
- cornerEl={isLongerChart ? : null}
+ cornerEl={maxValSelect}
>
-
+
: null}
+ cornerEl={maxValSelect}
description={t`Network traffic of public interfaces`}
>
-
+
{containerFilterBar && containerData.length > 0 && (
@@ -564,13 +561,9 @@ export default function SystemDetail({ name }: { name: string }) {
grid={grid}
title={`${extraFsName} I/O`}
description={t`Throughput of ${extraFsName}`}
- cornerEl={isLongerChart ? : null}
+ cornerEl={maxValSelect}
>
-
+
)
@@ -612,12 +605,10 @@ function ContainerFilterBar() {
)
}
-function SelectAvgMax({ store }: { store: [boolean, React.Dispatch>] }) {
- const [max, setMax] = store
+const SelectAvgMax = memo(({ max }: { max: boolean }) => {
const Icon = max ? ChartMax : ChartAverage
-
return (
-