feat: restrict timestamp from adding it to query (#1517)

Co-authored-by: Palash Gupta <palashgdev@gmail.com>
This commit is contained in:
Pranshu Chittora 2022-08-16 18:53:34 +05:30 committed by GitHub
parent b23d63cb2b
commit 166e5612eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 18 deletions

View File

@ -2,6 +2,7 @@ import { blue, grey, orange } from '@ant-design/colors';
import { CopyFilled, CopyrightCircleFilled, ExpandAltOutlined } from '@ant-design/icons';
import { Button, Card, Divider, Row, Typography } from 'antd';
import { map } from 'd3';
import dayjs from 'dayjs';
import { FlatLogData } from 'lib/logs/flatLogData';
import { flatMap, flatMapDeep } from 'lodash-es';
import React, { useCallback, useMemo } from 'react';
@ -95,7 +96,7 @@ function LogItem({ logData }) {
)}
<LogGeneralField
fieldKey="timestamp"
fieldValue={flattenLogData.timestamp}
fieldValue={dayjs(flattenLogData.timestamp / 1e6).format()}
/>
</div>
{'}'}

View File

@ -14,6 +14,9 @@ import React, { useMemo, useState } from 'react';
import ActionItem from './ActionItem';
// Fields which should be restricted from adding it to query
const RESTRICTED_FIELDS = ['timestamp'];
function TableView({ logData }) {
const [fieldSearchInput, setFieldSearchInput] = useState<string>('');
@ -38,27 +41,33 @@ function TableView({ logData }) {
{
title: 'Action',
width: 75,
render: (fieldData) => (
<ActionItem
fieldKey={fieldData.field.split('.').slice(-1)}
fieldValue={fieldData.value}
/>
),
render: (fieldData) => {
const fieldKey = fieldData.field.split('.').slice(-1);
if (!RESTRICTED_FIELDS.includes(fieldKey[0])) {
return <ActionItem fieldKey={fieldKey} fieldValue={fieldData.value} />;
}
return null;
},
},
{
title: 'Field',
dataIndex: 'field',
key: 'field',
width: '35%',
render: (field: string) => (
<AddToQueryHOC
fieldKey={field.split('.').slice(-1)}
fieldValue={flattenLogData[field]}
>
{' '}
<span style={{ color: blue[4] }}>{field}</span>
</AddToQueryHOC>
),
render: (field: string) => {
const fieldKey = field.split('.').slice(-1);
const renderedField = <span style={{ color: blue[4] }}>{field}</span>;
if (!RESTRICTED_FIELDS.includes(fieldKey[0])) {
return (
<AddToQueryHOC fieldKey={fieldKey} fieldValue={flattenLogData[field]}>
{' '}
{renderedField}
</AddToQueryHOC>
);
}
return renderedField;
},
},
{
title: 'Value',
@ -83,7 +92,7 @@ function TableView({ logData }) {
/>
<Table
// scroll={{ x: true }}
tableLayout='fixed'
tableLayout="fixed"
dataSource={dataSource}
columns={columns}
pagination={false}

View File

@ -110,7 +110,7 @@ function LogLiveTail() {
const timeStamp = dayjs().subtract(liveTailStartRange, 'minute').valueOf();
const queryParams = new URLSearchParams({
...(queryString ? { q: queryString } : {}),
timestampStart: timeStamp,
timestampStart: timeStamp * 1e6,
...(liveTailSourceRef.current && logs.length > 0
? {
idGt: logs[0].id,