mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-20 00:46:46 +00:00
* refactor: done with the download option for key-operation * refactor: added search option for key operation metrics * refactor: done with the download option for key-operation * refactor: added search option for key operation metrics * refactor: updated downloadable data * refactor: updated downloadable data for metrics key operation * refactor: updated the data * refactor: map with the correct value for export * refactor: updated downloabable data for metrics * refactor: updated the data for metrics * refactor: added safety check --------- Co-authored-by: Ankit Nayan <ankit@signoz.io>
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import './QueryTable.styles.scss';
|
|
|
|
import { ResizeTable } from 'components/ResizeTable';
|
|
import Download from 'container/Download/Download';
|
|
import { IServiceName } from 'container/MetricsApplication/Tabs/types';
|
|
import { createTableColumnsFromQuery } from 'lib/query/createTableColumnsFromQuery';
|
|
import { useMemo } from 'react';
|
|
import { useParams } from 'react-router-dom';
|
|
|
|
import { QueryTableProps } from './QueryTable.intefaces';
|
|
import { createDownloadableData } from './utils';
|
|
|
|
export function QueryTable({
|
|
queryTableData,
|
|
query,
|
|
renderActionCell,
|
|
modifyColumns,
|
|
renderColumnCell,
|
|
downloadOption,
|
|
...props
|
|
}: QueryTableProps): JSX.Element {
|
|
const { isDownloadEnabled = false, fileName = '' } = downloadOption || {};
|
|
const { servicename } = useParams<IServiceName>();
|
|
const { loading } = props;
|
|
const { columns, dataSource } = useMemo(
|
|
() =>
|
|
createTableColumnsFromQuery({
|
|
query,
|
|
queryTableData,
|
|
renderActionCell,
|
|
renderColumnCell,
|
|
}),
|
|
[query, queryTableData, renderActionCell, renderColumnCell],
|
|
);
|
|
|
|
const downloadableData = createDownloadableData(dataSource);
|
|
|
|
const tableColumns = modifyColumns ? modifyColumns(columns) : columns;
|
|
|
|
return (
|
|
<div className="query-table">
|
|
{isDownloadEnabled && (
|
|
<div className="query-table--download">
|
|
<Download
|
|
data={downloadableData}
|
|
fileName={`${fileName}-${servicename}`}
|
|
isLoading={loading as boolean}
|
|
/>
|
|
</div>
|
|
)}
|
|
<ResizeTable
|
|
columns={tableColumns}
|
|
tableLayout="fixed"
|
|
dataSource={dataSource}
|
|
scroll={{ x: true }}
|
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
{...props}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|