Improve system information retrieval for macOS and Windows

- Introduce `Os` enum to represent supported operating systems.
- Update `SystemInfo` interface to include OS type.
- Refactor `ContainerChart` component to use `ChartType` enum for better clarity.
- Switched to dynamic units in container memory chart.
This commit is contained in:
henrygd
2025-04-22 20:29:17 -04:00
parent 358e05d544
commit ea665e02da
7 changed files with 89 additions and 24 deletions

View File

@@ -16,16 +16,17 @@ import { useStore } from "@nanostores/react"
import { $containerFilter } from "@/lib/stores"
import { ChartData } from "@/types"
import { Separator } from "../ui/separator"
import { ChartType } from "@/lib/enums"
export default memo(function ContainerChart({
dataKey,
chartData,
chartName,
chartType,
unit = "%",
}: {
dataKey: string
chartData: ChartData
chartName: string
chartType: ChartType
unit?: string
}) {
const filter = useStore($containerFilter)
@@ -33,7 +34,7 @@ export default memo(function ContainerChart({
const { containerData } = chartData
const isNetChart = chartName === "net"
const isNetChart = chartType === ChartType.Network
const chartConfig = useMemo(() => {
let config = {} as Record<
@@ -81,7 +82,7 @@ export default memo(function ContainerChart({
tickFormatter: (value: any) => string
}
// tick formatter
if (chartName === "cpu") {
if (chartType === ChartType.CPU) {
obj.tickFormatter = (value) => {
const val = toFixedWithoutTrailingZeros(value, 2) + unit
return updateYAxisWidth(val)
@@ -111,6 +112,11 @@ export default memo(function ContainerChart({
return null
}
}
} else if (chartType === ChartType.Memory) {
obj.toolTipFormatter = (item: any) => {
const { v, u } = getSizeAndUnit(item.value, false)
return updateYAxisWidth(toFixedFloat(v, 2) + u)
}
} else {
obj.toolTipFormatter = (item: any) => decimalString(item.value) + unit
}