mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 01:36:08 +08:00
fix: table columns adding (#3058)
add configurable order for appending table columns Co-authored-by: Vishal Sharma <makeavish786@gmail.com>
This commit is contained in:
parent
1d00ac9ded
commit
eb2a955323
@ -1,4 +1,4 @@
|
|||||||
import { ColumnType } from 'antd/es/table';
|
import { ColumnsType, ColumnType } from 'antd/es/table';
|
||||||
import { IField } from 'types/api/logs/fields';
|
import { IField } from 'types/api/logs/fields';
|
||||||
import { ILog } from 'types/api/logs/log';
|
import { ILog } from 'types/api/logs/log';
|
||||||
|
|
||||||
@ -12,3 +12,12 @@ export type LogsTableViewProps = {
|
|||||||
linesPerRow: number;
|
linesPerRow: number;
|
||||||
onClickExpand: (log: ILog) => void;
|
onClickExpand: (log: ILog) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type UseTableViewResult = {
|
||||||
|
columns: ColumnsType<Record<string, unknown>>;
|
||||||
|
dataSource: Record<string, string>[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type UseTableViewProps = {
|
||||||
|
appendTo?: 'center' | 'end';
|
||||||
|
} & LogsTableViewProps;
|
||||||
|
@ -11,17 +11,22 @@ import { ILog } from 'types/api/logs/log';
|
|||||||
import { ExpandIconWrapper } from '../RawLogView/styles';
|
import { ExpandIconWrapper } from '../RawLogView/styles';
|
||||||
import { defaultCellStyle, defaultTableStyle } from './config';
|
import { defaultCellStyle, defaultTableStyle } from './config';
|
||||||
import { TableBodyContent } from './styles';
|
import { TableBodyContent } from './styles';
|
||||||
import { ColumnTypeRender, LogsTableViewProps } from './types';
|
import {
|
||||||
|
ColumnTypeRender,
|
||||||
export type UseTableViewResult = {
|
UseTableViewProps,
|
||||||
columns: ColumnsType<Record<string, unknown>>;
|
UseTableViewResult,
|
||||||
dataSource: Record<string, string>[];
|
} from './types';
|
||||||
};
|
|
||||||
|
|
||||||
const convert = new Convert();
|
const convert = new Convert();
|
||||||
|
|
||||||
export const useTableView = (props: LogsTableViewProps): UseTableViewResult => {
|
export const useTableView = (props: UseTableViewProps): UseTableViewResult => {
|
||||||
const { logs, fields, linesPerRow, onClickExpand } = props;
|
const {
|
||||||
|
logs,
|
||||||
|
fields,
|
||||||
|
linesPerRow,
|
||||||
|
onClickExpand,
|
||||||
|
appendTo = 'center',
|
||||||
|
} = props;
|
||||||
|
|
||||||
const flattenLogData = useMemo(() => logs.map((log) => FlatLogData(log)), [
|
const flattenLogData = useMemo(() => logs.map((log) => FlatLogData(log)), [
|
||||||
logs,
|
logs,
|
||||||
@ -82,7 +87,7 @@ export const useTableView = (props: LogsTableViewProps): UseTableViewResult => {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
...fieldColumns,
|
...(appendTo === 'center' ? fieldColumns : []),
|
||||||
{
|
{
|
||||||
title: 'body',
|
title: 'body',
|
||||||
dataIndex: 'body',
|
dataIndex: 'body',
|
||||||
@ -101,8 +106,9 @@ export const useTableView = (props: LogsTableViewProps): UseTableViewResult => {
|
|||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
...(appendTo === 'end' ? fieldColumns : []),
|
||||||
];
|
];
|
||||||
}, [fields, linesPerRow, onClickExpand]);
|
}, [fields, linesPerRow, appendTo, onClickExpand]);
|
||||||
|
|
||||||
return { columns, dataSource: flattenLogData };
|
return { columns, dataSource: flattenLogData };
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { LogsTableViewProps } from 'components/Logs/TableView/types';
|
import { UseTableViewProps } from 'components/Logs/TableView/types';
|
||||||
|
|
||||||
export type InfinityTableProps = {
|
export type InfinityTableProps = {
|
||||||
tableViewProps: LogsTableViewProps;
|
tableViewProps: UseTableViewProps;
|
||||||
infitiyTableProps: {
|
infitiyTableProps: {
|
||||||
onEndReached: (index: number) => void;
|
onEndReached: (index: number) => void;
|
||||||
};
|
};
|
||||||
|
@ -104,6 +104,7 @@ function LogsExplorerList({
|
|||||||
fields: selectedFields,
|
fields: selectedFields,
|
||||||
linesPerRow: options.maxLines,
|
linesPerRow: options.maxLines,
|
||||||
onClickExpand: onExpand,
|
onClickExpand: onExpand,
|
||||||
|
appendTo: 'end',
|
||||||
}}
|
}}
|
||||||
infitiyTableProps={{ onEndReached }}
|
infitiyTableProps={{ onEndReached }}
|
||||||
/>
|
/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user