diff --git a/agent/agent.go b/agent/agent.go index 91ef0299..1b761a21 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -166,7 +166,7 @@ func (a *Agent) gatherStats(cacheTimeMs uint16) *system.CombinedData { } data.Stats.ExtraFs = make(map[string]*system.FsStats) - data.Info.ExtraFsPct = make(map[string]system.ExtraFsInfo) + data.Info.ExtraFsPct = make(map[string]float64) for name, stats := range a.fsStats { if !stats.Root && stats.DiskTotal > 0 { // Use custom name if available, otherwise use device name @@ -177,8 +177,8 @@ func (a *Agent) gatherStats(cacheTimeMs uint16) *system.CombinedData { data.Stats.ExtraFs[key] = stats // Add percentage info to Info struct for dashboard if stats.DiskTotal > 0 { - pct := (stats.DiskUsed / stats.DiskTotal) * 100 - data.Info.ExtraFsPct[key] = system.ExtraFsInfo{DiskPct: pct} + pct := twoDecimals((stats.DiskUsed / stats.DiskTotal) * 100) + data.Info.ExtraFsPct[key] = pct } } } diff --git a/internal/entities/system/system.go b/internal/entities/system/system.go index c51699c5..652c8e80 100644 --- a/internal/entities/system/system.go +++ b/internal/entities/system/system.go @@ -99,10 +99,6 @@ type FsStats struct { MaxDiskWriteBytes uint64 `json:"wbm,omitempty" cbor:"-"` } -// ExtraFsInfo contains summary info for extra filesystems in the system info -type ExtraFsInfo struct { - DiskPct float64 `json:"dp" cbor:"0,keyasint"` -} type NetIoStats struct { BytesRecv uint64 @@ -151,7 +147,7 @@ type Info struct { // TODO: remove load fields in future release in favor of load avg array LoadAvg [3]float64 `json:"la,omitempty" cbor:"19,keyasint"` ConnectionType ConnectionType `json:"ct,omitempty" cbor:"20,keyasint,omitempty,omitzero"` - ExtraFsPct map[string]ExtraFsInfo `json:"efsp,omitempty" cbor:"21,keyasint,omitempty"` + ExtraFsPct map[string]float64 `json:"efs,omitempty" cbor:"21,keyasint,omitempty"` } // Final data structure to return to the hub diff --git a/internal/site/src/components/systems-table/systems-table-columns.tsx b/internal/site/src/components/systems-table/systems-table-columns.tsx index 2fc59379..419ab4e0 100644 --- a/internal/site/src/components/systems-table/systems-table-columns.tsx +++ b/internal/site/src/components/systems-table/systems-table-columns.tsx @@ -358,84 +358,66 @@ function TableCellWithMeter(info: CellContext) { function DiskCellWithMultiple(info: CellContext) { const { info: sysInfo, status } = info.row.original const rootDiskPct = sysInfo.dp - const extraFsData = sysInfo.efsp + const extraFsData = sysInfo.efs const extraFsCount = extraFsData ? Object.keys(extraFsData).length : 0 - const threshold = getMeterState(rootDiskPct) - const meterClass = cn( - "h-full", - (status !== SystemStatus.Up && STATUS_COLORS.paused) || - (threshold === MeterState.Good && STATUS_COLORS.up) || - (threshold === MeterState.Warn && STATUS_COLORS.pending) || - STATUS_COLORS.down - ) + function getMeterClass(pct: number) { + const threshold = getMeterState(pct) + return cn( + "h-full", + (status !== SystemStatus.Up && STATUS_COLORS.paused) || + (threshold === MeterState.Good && STATUS_COLORS.up) || + (threshold === MeterState.Warn && STATUS_COLORS.pending) || + STATUS_COLORS.down + ) + } // No extra disks - show simple meter if (extraFsCount === 0) { - return ( -
- {decimalString(rootDiskPct, rootDiskPct >= 10 ? 1 : 2)}% - - - -
- ) + return TableCellWithMeter(info) } // Has extra disks - show with tooltip return ( -
+
{decimalString(rootDiskPct, rootDiskPct >= 10 ? 1 : 2)}% - + + {extraFsData && Object.entries(extraFsData).slice(0, 2).map(([_name, pct], index) => ( + + ))}
-
+{extraFsCount} more
-
+
- -
-
- - {t`All Disks`} -
+
-
{t`Root`}
+
{t`Root`}
{decimalString(rootDiskPct, rootDiskPct >= 10 ? 1 : 2)}% - - + +
- {extraFsData && Object.entries(extraFsData).map(([name, fs]) => { - const pct = fs.dp - const fsThreshold = getMeterState(pct) - const fsMeterClass = cn( - "h-full", - (status !== SystemStatus.Up && STATUS_COLORS.paused) || - (fsThreshold === MeterState.Good && STATUS_COLORS.up) || - (fsThreshold === MeterState.Warn && STATUS_COLORS.pending) || - STATUS_COLORS.down - ) + {extraFsData && Object.entries(extraFsData).map(([name, pct]) => { return (
{name}
{decimalString(pct, pct >= 10 ? 1 : 2)}% - - + +
) })}
-
) diff --git a/internal/site/src/types.d.ts b/internal/site/src/types.d.ts index 67488ca7..9e8c0f9f 100644 --- a/internal/site/src/types.d.ts +++ b/internal/site/src/types.d.ts @@ -78,13 +78,9 @@ export interface SystemInfo { /** connection type */ ct?: ConnectionType /** extra filesystem percentages */ - efsp?: Record + efs?: Record } -export interface ExtraFsInfo { - /** disk percent */ - dp: number -} export interface SystemStats { /** cpu percent */