mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 11:15:58 +08:00
feat: onClick feature is updated (#895)
This commit is contained in:
parent
b958bad81f
commit
7765cee610
@ -5,6 +5,7 @@ import { SKIP_ONBOARDING } from 'constants/onboarding';
|
|||||||
import ROUTES from 'constants/routes';
|
import ROUTES from 'constants/routes';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
import { servicesListItem } from 'store/actions/MetricsActions/metricsInterfaces';
|
import { servicesListItem } from 'store/actions/MetricsActions/metricsInterfaces';
|
||||||
import { AppState } from 'store/reducers';
|
import { AppState } from 'store/reducers';
|
||||||
import MetricReducer from 'types/reducer/metrics';
|
import MetricReducer from 'types/reducer/metrics';
|
||||||
@ -46,9 +47,9 @@ function Metrics(): JSX.Element {
|
|||||||
key: 'serviceName',
|
key: 'serviceName',
|
||||||
// eslint-disable-next-line react/display-name
|
// eslint-disable-next-line react/display-name
|
||||||
render: (text: string): JSX.Element => (
|
render: (text: string): JSX.Element => (
|
||||||
<div onClick={(): void => onClickHandler(`${ROUTES.APPLICATION}/${text}`)}>
|
<Link to={`${ROUTES.APPLICATION}/${text}`}>
|
||||||
<Name>{text}</Name>
|
<Name>{text}</Name>
|
||||||
</div>
|
</Link>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { TableProps, Tag } from 'antd';
|
import { TableProps, Tag, Typography } from 'antd';
|
||||||
import Table, { ColumnsType } from 'antd/lib/table';
|
import Table, { ColumnsType } from 'antd/lib/table';
|
||||||
import ROUTES from 'constants/routes';
|
import ROUTES from 'constants/routes';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import duration from 'dayjs/plugin/duration';
|
import duration from 'dayjs/plugin/duration';
|
||||||
import history from 'lib/history';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { connect, useSelector } from 'react-redux';
|
import { connect, useSelector } from 'react-redux';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
import { ThunkDispatch } from 'redux-thunk';
|
import { ThunkDispatch } from 'redux-thunk';
|
||||||
import {
|
import {
|
||||||
@ -35,59 +35,99 @@ function TraceTable({ getSpansAggregate }: TraceProps): JSX.Element {
|
|||||||
|
|
||||||
type TableType = FlatArray<TraceReducer['spansAggregate']['data'], 1>;
|
type TableType = FlatArray<TraceReducer['spansAggregate']['data'], 1>;
|
||||||
|
|
||||||
|
const getLink = (record: TableType): string => {
|
||||||
|
return `${ROUTES.TRACE}/${record.traceID}?spanId=${record.spanID}`;
|
||||||
|
};
|
||||||
|
|
||||||
const columns: ColumnsType<TableType> = [
|
const columns: ColumnsType<TableType> = [
|
||||||
{
|
{
|
||||||
title: 'Date',
|
title: 'Date',
|
||||||
dataIndex: 'timestamp',
|
dataIndex: 'timestamp',
|
||||||
key: 'timestamp',
|
key: 'timestamp',
|
||||||
sorter: true,
|
sorter: true,
|
||||||
render: (value: TableType['timestamp']): JSX.Element => {
|
render: (value: TableType['timestamp'], record): JSX.Element => {
|
||||||
const day = dayjs(value);
|
const day = dayjs(value);
|
||||||
return <div>{day.format('YYYY/MM/DD HH:mm:ss')}</div>;
|
return (
|
||||||
|
<Link to={getLink(record)}>
|
||||||
|
<Typography>{day.format('YYYY/MM/DD HH:mm:ss')}</Typography>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Service',
|
title: 'Service',
|
||||||
dataIndex: 'serviceName',
|
dataIndex: 'serviceName',
|
||||||
key: 'serviceName',
|
key: 'serviceName',
|
||||||
|
render: (value, record): JSX.Element => {
|
||||||
|
return (
|
||||||
|
<Link to={getLink(record)}>
|
||||||
|
<Typography>{value}</Typography>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Operation',
|
title: 'Operation',
|
||||||
dataIndex: 'operation',
|
dataIndex: 'operation',
|
||||||
key: 'operation',
|
key: 'operation',
|
||||||
|
render: (value, record): JSX.Element => {
|
||||||
|
return (
|
||||||
|
<Link to={getLink(record)}>
|
||||||
|
<Typography>{value}</Typography>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Duration',
|
title: 'Duration',
|
||||||
dataIndex: 'durationNano',
|
dataIndex: 'durationNano',
|
||||||
key: 'durationNano',
|
key: 'durationNano',
|
||||||
render: (value: TableType['durationNano']): JSX.Element => (
|
render: (value: TableType['durationNano'], record): JSX.Element => (
|
||||||
<div>
|
<Link to={getLink(record)}>
|
||||||
{`${dayjs
|
<Typography>
|
||||||
.duration({ milliseconds: value / 1000000 })
|
{`${dayjs
|
||||||
.asMilliseconds()} ms`}
|
.duration({ milliseconds: value / 1000000 })
|
||||||
</div>
|
.asMilliseconds()} ms`}
|
||||||
|
</Typography>
|
||||||
|
</Link>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Method',
|
title: 'Method',
|
||||||
dataIndex: 'httpMethod',
|
dataIndex: 'httpMethod',
|
||||||
key: 'httpMethod',
|
key: 'httpMethod',
|
||||||
render: (value: TableType['httpMethod']): JSX.Element => {
|
render: (value: TableType['httpMethod'], record): JSX.Element => {
|
||||||
if (value.length === 0) {
|
if (value.length === 0) {
|
||||||
return <div>-</div>;
|
return (
|
||||||
|
<Link to={getLink(record)}>
|
||||||
|
<Typography>-</Typography>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return <Tag color="magenta">{value}</Tag>;
|
return (
|
||||||
|
<Link to={getLink(record)}>
|
||||||
|
<Tag color="magenta">{value}</Tag>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Status Code',
|
title: 'Status Code',
|
||||||
dataIndex: 'httpCode',
|
dataIndex: 'httpCode',
|
||||||
key: 'httpCode',
|
key: 'httpCode',
|
||||||
render: (value: TableType['httpCode']): JSX.Element => {
|
render: (value: TableType['httpMethod'], record): JSX.Element => {
|
||||||
if (value.length === 0) {
|
if (value.length === 0) {
|
||||||
return <div>-</div>;
|
return (
|
||||||
|
<Link to={getLink(record)}>
|
||||||
|
<Typography>-</Typography>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return <Tag color="magenta">{value}</Tag>;
|
return (
|
||||||
|
<Link to={getLink(record)}>
|
||||||
|
<Tag color="magenta">{value}</Tag>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -118,12 +158,6 @@ function TraceTable({ getSpansAggregate }: TraceProps): JSX.Element {
|
|||||||
dataSource={spansAggregate.data}
|
dataSource={spansAggregate.data}
|
||||||
loading={loading || filterLoading}
|
loading={loading || filterLoading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
onRow={(record) => ({
|
|
||||||
onClick: (): void => {
|
|
||||||
window.open(`${ROUTES.TRACE}/${record.traceID}?spanId=${record.spanID}`);
|
|
||||||
},
|
|
||||||
})}
|
|
||||||
size="middle"
|
|
||||||
rowKey="timestamp"
|
rowKey="timestamp"
|
||||||
style={{
|
style={{
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user