2022-08-11 11:45:28 +05:30
|
|
|
import { blue } from '@ant-design/colors';
|
|
|
|
|
import { CopyFilled } from '@ant-design/icons';
|
|
|
|
|
import { Button, Row } from 'antd';
|
|
|
|
|
import Editor from 'components/Editor';
|
2023-05-19 13:14:32 +05:30
|
|
|
import { useMemo } from 'react';
|
2022-08-11 11:45:28 +05:30
|
|
|
import { useCopyToClipboard } from 'react-use';
|
|
|
|
|
|
2023-09-15 18:13:25 +05:30
|
|
|
import { JSONViewProps } from './LogDetailedView.types';
|
|
|
|
|
import { aggregateAttributesResourcesToString } from './utils';
|
|
|
|
|
|
2022-08-19 17:16:04 +05:30
|
|
|
function JSONView({ logData }: JSONViewProps): JSX.Element {
|
|
|
|
|
const [, copyToClipboard] = useCopyToClipboard();
|
2023-09-15 18:13:25 +05:30
|
|
|
|
|
|
|
|
const LogJsonData = useMemo(
|
|
|
|
|
() => aggregateAttributesResourcesToString(logData),
|
|
|
|
|
[logData],
|
|
|
|
|
);
|
2022-08-19 17:16:04 +05:30
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<Row
|
|
|
|
|
style={{
|
|
|
|
|
justifyContent: 'flex-end',
|
|
|
|
|
margin: '0.5rem 0',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
size="small"
|
|
|
|
|
type="text"
|
|
|
|
|
onClick={(): void => copyToClipboard(LogJsonData)}
|
|
|
|
|
>
|
|
|
|
|
<CopyFilled /> <span style={{ color: blue[5] }}>Copy to Clipboard</span>
|
|
|
|
|
</Button>
|
|
|
|
|
</Row>
|
|
|
|
|
<div style={{ marginTop: '0.5rem' }}>
|
|
|
|
|
<Editor
|
|
|
|
|
value={LogJsonData}
|
|
|
|
|
language="json"
|
|
|
|
|
height="70vh"
|
|
|
|
|
readOnly
|
|
|
|
|
onChange={(): void => {}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2022-08-11 11:45:28 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default JSONView;
|