mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 01:49:05 +08:00
feat: color coding is added in the table view (#2437)
This commit is contained in:
parent
9af991e424
commit
66b2e17bba
@ -1,7 +1,9 @@
|
|||||||
import { ExpandAltOutlined } from '@ant-design/icons';
|
import { ExpandAltOutlined } from '@ant-design/icons';
|
||||||
|
import Convert from 'ansi-to-html';
|
||||||
import { Table, Typography } from 'antd';
|
import { Table, Typography } from 'antd';
|
||||||
import { ColumnsType, ColumnType } from 'antd/es/table';
|
import { ColumnsType, ColumnType } from 'antd/es/table';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
import dompurify from 'dompurify';
|
||||||
// utils
|
// utils
|
||||||
import { FlatLogData } from 'lib/logs/flatLogData';
|
import { FlatLogData } from 'lib/logs/flatLogData';
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
@ -13,6 +15,7 @@ import { ILog } from 'types/api/logs/log';
|
|||||||
import { ExpandIconWrapper } from '../RawLogView/styles';
|
import { ExpandIconWrapper } from '../RawLogView/styles';
|
||||||
// config
|
// config
|
||||||
import { defaultCellStyle, defaultTableStyle, tableScroll } from './config';
|
import { defaultCellStyle, defaultTableStyle, tableScroll } from './config';
|
||||||
|
import { TableBodyContent } from './styles';
|
||||||
|
|
||||||
type ColumnTypeRender<T = unknown> = ReturnType<
|
type ColumnTypeRender<T = unknown> = ReturnType<
|
||||||
NonNullable<ColumnType<T>['render']>
|
NonNullable<ColumnType<T>['render']>
|
||||||
@ -25,6 +28,8 @@ type LogsTableViewProps = {
|
|||||||
onClickExpand: (log: ILog) => void;
|
onClickExpand: (log: ILog) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const convert = new Convert();
|
||||||
|
|
||||||
function LogsTableView(props: LogsTableViewProps): JSX.Element {
|
function LogsTableView(props: LogsTableViewProps): JSX.Element {
|
||||||
const { logs, fields, linesPerRow, onClickExpand } = props;
|
const { logs, fields, linesPerRow, onClickExpand } = props;
|
||||||
|
|
||||||
@ -94,9 +99,12 @@ function LogsTableView(props: LogsTableViewProps): JSX.Element {
|
|||||||
style: defaultTableStyle,
|
style: defaultTableStyle,
|
||||||
},
|
},
|
||||||
children: (
|
children: (
|
||||||
<Typography.Paragraph ellipsis={{ rows: linesPerRow }}>
|
<TableBodyContent
|
||||||
{field}
|
dangerouslySetInnerHTML={{
|
||||||
</Typography.Paragraph>
|
__html: convert.toHtml(dompurify.sanitize(field)),
|
||||||
|
}}
|
||||||
|
linesPerRow={linesPerRow}
|
||||||
|
/>
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
21
frontend/src/components/Logs/TableView/styles.ts
Normal file
21
frontend/src/components/Logs/TableView/styles.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
interface TableBodyContentProps {
|
||||||
|
linesPerRow: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const TableBodyContent = styled.div<TableBodyContentProps>`
|
||||||
|
margin-bottom: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: ${(props): number => props.linesPerRow};
|
||||||
|
line-clamp: ${(props): number => props.linesPerRow};
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
|
||||||
|
font-size: 0.875rem;
|
||||||
|
|
||||||
|
line-height: 2rem;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
`;
|
Loading…
x
Reference in New Issue
Block a user