mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-13 04:29:04 +08:00
feat: added custom title handling in gridtablecomponent
This commit is contained in:
parent
21d239ce68
commit
b24095236f
@ -3555,6 +3555,12 @@ export const getAllEndpointsWidgetData = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
widget.renderColumnCell = {
|
widget.renderColumnCell = {
|
||||||
|
'http.url': (url: any): ReactNode => {
|
||||||
|
const { endpoint } = extractPortAndEndpoint(url);
|
||||||
|
return (
|
||||||
|
<span>{endpoint === 'n/a' || url === undefined ? '-' : endpoint}</span>
|
||||||
|
);
|
||||||
|
},
|
||||||
A: (numOfCalls: any): ReactNode => (
|
A: (numOfCalls: any): ReactNode => (
|
||||||
<span>
|
<span>
|
||||||
{numOfCalls === 'n/a' || numOfCalls === undefined ? '-' : numOfCalls}
|
{numOfCalls === 'n/a' || numOfCalls === undefined ? '-' : numOfCalls}
|
||||||
@ -3604,6 +3610,11 @@ export const getAllEndpointsWidgetData = (
|
|||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
widget.customColTitles = {
|
||||||
|
'http.url': 'Endpoint',
|
||||||
|
'net.peer.port': 'Port',
|
||||||
|
};
|
||||||
|
|
||||||
return widget;
|
return widget;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -227,6 +227,18 @@ function GridTableComponent({
|
|||||||
[newColumnData, props.renderColumnCell],
|
[newColumnData, props.renderColumnCell],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const newColumnsWithCustomColTitles = useMemo(
|
||||||
|
() =>
|
||||||
|
newColumnsWithRenderColumnCell.map((column) => ({
|
||||||
|
...column,
|
||||||
|
...('dataIndex' in column &&
|
||||||
|
props.customColTitles?.[column.dataIndex as string]
|
||||||
|
? { title: props.customColTitles[column.dataIndex as string] }
|
||||||
|
: {}),
|
||||||
|
})),
|
||||||
|
[newColumnsWithRenderColumnCell, props.customColTitles],
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
eventEmitter.emit(Events.TABLE_COLUMNS_DATA, {
|
eventEmitter.emit(Events.TABLE_COLUMNS_DATA, {
|
||||||
columns: newColumnData,
|
columns: newColumnData,
|
||||||
@ -243,7 +255,7 @@ function GridTableComponent({
|
|||||||
columns={
|
columns={
|
||||||
openTracesButton
|
openTracesButton
|
||||||
? columnDataWithOpenTracesButton
|
? columnDataWithOpenTracesButton
|
||||||
: newColumnsWithRenderColumnCell
|
: newColumnsWithCustomColTitles
|
||||||
}
|
}
|
||||||
dataSource={dataSource}
|
dataSource={dataSource}
|
||||||
sticky={sticky}
|
sticky={sticky}
|
||||||
|
@ -21,6 +21,7 @@ export type GridTableComponentProps = {
|
|||||||
customOnRowClick?: (record: RowData) => void;
|
customOnRowClick?: (record: RowData) => void;
|
||||||
widgetId?: string;
|
widgetId?: string;
|
||||||
renderColumnCell?: QueryTableProps['renderColumnCell'];
|
renderColumnCell?: QueryTableProps['renderColumnCell'];
|
||||||
|
customColTitles?: Record<string, string>;
|
||||||
} & Pick<LogsExplorerTableProps, 'data'> &
|
} & Pick<LogsExplorerTableProps, 'data'> &
|
||||||
Omit<TableProps<RowData>, 'columns' | 'dataSource'>;
|
Omit<TableProps<RowData>, 'columns' | 'dataSource'>;
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ function TablePanelWrapper({
|
|||||||
customOnRowClick={customOnRowClick}
|
customOnRowClick={customOnRowClick}
|
||||||
widgetId={widget.id}
|
widgetId={widget.id}
|
||||||
renderColumnCell={widget.renderColumnCell}
|
renderColumnCell={widget.renderColumnCell}
|
||||||
|
customColTitles={widget.customColTitles}
|
||||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||||
{...GRID_TABLE_CONFIG}
|
{...GRID_TABLE_CONFIG}
|
||||||
/>
|
/>
|
||||||
|
@ -115,6 +115,7 @@ export interface IBaseWidget {
|
|||||||
export interface Widgets extends IBaseWidget {
|
export interface Widgets extends IBaseWidget {
|
||||||
query: Query;
|
query: Query;
|
||||||
renderColumnCell?: QueryTableProps['renderColumnCell'];
|
renderColumnCell?: QueryTableProps['renderColumnCell'];
|
||||||
|
customColTitles?: Record<string, string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PromQLWidgets extends IBaseWidget {
|
export interface PromQLWidgets extends IBaseWidget {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user