diff --git a/reporter/utils/utils.go b/reporter/utils/utils.go index 4cb013e..4b36425 100644 --- a/reporter/utils/utils.go +++ b/reporter/utils/utils.go @@ -43,22 +43,23 @@ type ReportDataPayload struct { } type DockerDataPayload struct { - ID string `json:"id"` - Image string `json:"image"` - ImageID string `json:"imageId"` - CreatedAt int64 `json:"createdAt"` - State string `json:"state"` - Status string `json:"status"` - CpuPercent float64 `json:"cpuPercent"` - Memory float64 `json:"memory"` - MemLimit uint64 `json:"memLimit"` - MemPercent float64 `json:"memPercent"` - StorageWriteSize uint64 `json:"storageWriteSize"` - StorageReadSize uint64 `json:"storageReadSize"` - NetworkRx float64 `json:"networkRx"` - NetworkTx float64 `json:"networkTx"` - IORead uint64 `json:"ioRead"` - IOWrite uint64 `json:"ioWrite"` + ID string `json:"id"` + Image string `json:"image"` + ImageID string `json:"imageId"` + Ports []dockerTypes.Port `json:"ports"` + CreatedAt int64 `json:"createdAt"` + State string `json:"state"` + Status string `json:"status"` + CpuPercent float64 `json:"cpuPercent"` + Memory float64 `json:"memory"` + MemLimit uint64 `json:"memLimit"` + MemPercent float64 `json:"memPercent"` + StorageWriteSize uint64 `json:"storageWriteSize"` + StorageReadSize uint64 `json:"storageReadSize"` + NetworkRx float64 `json:"networkRx"` + NetworkTx float64 `json:"networkTx"` + IORead uint64 `json:"ioRead"` + IOWrite uint64 `json:"ioWrite"` } var checkIP int @@ -303,6 +304,7 @@ func GetDockerStat() ([]DockerDataPayload, error) { ID: container.ID[:10], Image: container.Image, ImageID: container.ImageID, + Ports: container.Ports, CreatedAt: container.Created, State: container.State, Status: container.Status, diff --git a/src/client/components/DataTable.tsx b/src/client/components/DataTable.tsx index 614e22d..bdc45d3 100644 --- a/src/client/components/DataTable.tsx +++ b/src/client/components/DataTable.tsx @@ -5,6 +5,7 @@ import { useReactTable, createColumnHelper, getExpandedRowModel, + ExpandedState, } from '@tanstack/react-table'; import { @@ -17,6 +18,9 @@ import { } from '@/components/ui/table'; import { Empty } from 'antd'; import React from 'react'; +import { Button } from './ui/button'; +import { LuArrowRight } from 'react-icons/lu'; +import { cn } from '@/utils/style'; export type { ColumnDef }; export { createColumnHelper }; @@ -32,10 +36,18 @@ export function DataTable({ data, ExpandComponent, }: DataTableProps) { + const [expanded, setExpanded] = React.useState({}); + const canExpand = Boolean(ExpandComponent); + const table = useReactTable({ data, columns, + state: { + expanded, + }, + onExpandedChange: setExpanded, getCoreRowModel: getCoreRowModel(), + getRowCanExpand: () => canExpand, }); return ( @@ -44,6 +56,21 @@ export function DataTable({ {table.getHeaderGroups().map((headerGroup) => ( + {canExpand && ( + +