mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-27 15:22:00 +08:00

* feat: add dynamic table based on query * fix: group by repeating * fix: change view when groupBy exist in the list * fix: table scroll * fix: filters for explorer page (#2959) --------- Co-authored-by: Palash Gupta <palashgdev@gmail.com>
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
import type { ColumnsType } from 'antd/es/table';
|
|
import { ResizeTable } from 'components/ResizeTable';
|
|
import dayjs from 'dayjs';
|
|
import {
|
|
createTableColumnsFromQuery,
|
|
RowData,
|
|
} from 'lib/query/createTableColumnsFromQuery';
|
|
import { useMemo } from 'react';
|
|
|
|
import { QueryTableProps } from './QueryTable.intefaces';
|
|
|
|
export function QueryTable({
|
|
queryTableData,
|
|
query,
|
|
renderActionCell,
|
|
...props
|
|
}: QueryTableProps): JSX.Element {
|
|
const { columns, dataSource } = useMemo(
|
|
() =>
|
|
createTableColumnsFromQuery({
|
|
query,
|
|
queryTableData,
|
|
renderActionCell,
|
|
}),
|
|
[query, queryTableData, renderActionCell],
|
|
);
|
|
|
|
const modifiedColumns = useMemo(() => {
|
|
const currentColumns: ColumnsType<RowData> = columns.map((column) =>
|
|
column.key === 'timestamp'
|
|
? {
|
|
...column,
|
|
render: (_, record): string =>
|
|
dayjs(new Date(record.timestamp)).format('MMM DD, YYYY, HH:mm:ss'),
|
|
}
|
|
: column,
|
|
);
|
|
|
|
return currentColumns;
|
|
}, [columns]);
|
|
|
|
return (
|
|
<ResizeTable
|
|
columns={modifiedColumns}
|
|
tableLayout="fixed"
|
|
dataSource={dataSource}
|
|
scroll={{ x: true }}
|
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|