Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: export as csv for logs and traces table panel type #6047

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions frontend/src/container/GridTableComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getYAxisFormattedValue } from 'components/Graph/yAxisConfig';
import { Events } from 'constants/events';
import { QueryTable } from 'container/QueryTable';
import { RowData } from 'lib/query/createTableColumnsFromQuery';
import { cloneDeep, get, isEmpty, set } from 'lodash-es';
import { cloneDeep, get, isEmpty } from 'lodash-es';
import { memo, ReactNode, useCallback, useEffect, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { eventEmitter } from 'utils/getEventEmitter';
Expand Down Expand Up @@ -38,15 +38,13 @@ function GridTableComponent({
const createDataInCorrectFormat = useCallback(
(dataSource: RowData[]): RowData[] =>
dataSource.map((d) => {
const finalObject = {};
const finalObject: Record<string, number | string> = {};

// we use the order of the columns here to have similar download as the user view
// the [] access for the object is used because the titles can contain dot(.) as well
columns.forEach((k) => {
set(
finalObject,
get(k, 'title', '') as string,
get(d, get(k, 'dataIndex', ''), 'n/a'),
);
finalObject[`${get(k, 'title', '')}`] =
d[`${get(k, 'dataIndex', '')}`] || 'n/a';
});
return finalObject as RowData;
}),
Expand Down Expand Up @@ -86,6 +84,7 @@ function GridTableComponent({
applyColumnUnits,
originalDataSource,
]);

useEffect(() => {
if (tableProcessedDataRef) {
// eslint-disable-next-line no-param-reassign
Expand Down
Loading