mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-16 04:55:55 +08:00
chore: move the table calculation to backend (#5351)
This commit is contained in:
parent
53c6288025
commit
c5d23336a7
@ -80,6 +80,8 @@ function FullView({
|
|||||||
query: updatedQuery,
|
query: updatedQuery,
|
||||||
globalSelectedInterval: globalSelectedTime,
|
globalSelectedInterval: globalSelectedTime,
|
||||||
variables: getDashboardVariables(selectedDashboard?.data.variables),
|
variables: getDashboardVariables(selectedDashboard?.data.variables),
|
||||||
|
fillGaps: widget.fillSpans,
|
||||||
|
formatForWeb: getGraphType(widget.panelTypes) === PANEL_TYPES.TABLE,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
updatedQuery.builder.queryData[0].pageSize = 10;
|
updatedQuery.builder.queryData[0].pageSize = 10;
|
||||||
|
@ -109,6 +109,7 @@ function GridCardGraph({
|
|||||||
globalSelectedInterval,
|
globalSelectedInterval,
|
||||||
variables: getDashboardVariables(variables),
|
variables: getDashboardVariables(variables),
|
||||||
fillGaps: widget.fillSpans,
|
fillGaps: widget.fillSpans,
|
||||||
|
formatForWeb: getGraphType(widget.panelTypes) === PANEL_TYPES.TABLE,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
updatedQuery.builder.queryData[0].pageSize = 10;
|
updatedQuery.builder.queryData[0].pageSize = 10;
|
||||||
|
215
frontend/src/container/GridTableComponent/__tests__/response.ts
Normal file
215
frontend/src/container/GridTableComponent/__tests__/response.ts
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
export const tableDataMultipleQueriesSuccessResponse = {
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
name: 'service_name',
|
||||||
|
queryName: '',
|
||||||
|
isValueColumn: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'A',
|
||||||
|
queryName: 'A',
|
||||||
|
isValueColumn: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'B',
|
||||||
|
queryName: 'B',
|
||||||
|
isValueColumn: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
rows: [
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
A: 4196.71,
|
||||||
|
B: 'n/a',
|
||||||
|
service_name: 'demo-app',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
A: 500.83,
|
||||||
|
B: 'n/a',
|
||||||
|
service_name: 'customer',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
A: 499.5,
|
||||||
|
B: 'n/a',
|
||||||
|
service_name: 'mysql',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
A: 293.22,
|
||||||
|
B: 'n/a',
|
||||||
|
service_name: 'frontend',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
A: 230.03,
|
||||||
|
B: 'n/a',
|
||||||
|
service_name: 'driver',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
A: 67.09,
|
||||||
|
B: 'n/a',
|
||||||
|
service_name: 'route',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
A: 30.96,
|
||||||
|
B: 'n/a',
|
||||||
|
service_name: 'redis',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
A: 'n/a',
|
||||||
|
B: 112.27,
|
||||||
|
service_name: 'n/a',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const widgetQueryWithLegend = {
|
||||||
|
clickhouse_sql: [
|
||||||
|
{
|
||||||
|
name: 'A',
|
||||||
|
legend: '',
|
||||||
|
disabled: false,
|
||||||
|
query: '',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
promql: [
|
||||||
|
{
|
||||||
|
name: 'A',
|
||||||
|
query: '',
|
||||||
|
legend: '',
|
||||||
|
disabled: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
builder: {
|
||||||
|
queryData: [
|
||||||
|
{
|
||||||
|
dataSource: 'metrics',
|
||||||
|
queryName: 'A',
|
||||||
|
aggregateOperator: 'count',
|
||||||
|
aggregateAttribute: {
|
||||||
|
dataType: 'float64',
|
||||||
|
id: 'signoz_latency--float64--ExponentialHistogram--true',
|
||||||
|
isColumn: true,
|
||||||
|
isJSON: false,
|
||||||
|
key: 'signoz_latency',
|
||||||
|
type: 'ExponentialHistogram',
|
||||||
|
},
|
||||||
|
timeAggregation: '',
|
||||||
|
spaceAggregation: 'p90',
|
||||||
|
functions: [],
|
||||||
|
filters: {
|
||||||
|
items: [],
|
||||||
|
op: 'AND',
|
||||||
|
},
|
||||||
|
expression: 'A',
|
||||||
|
disabled: false,
|
||||||
|
stepInterval: 60,
|
||||||
|
having: [],
|
||||||
|
limit: null,
|
||||||
|
orderBy: [],
|
||||||
|
groupBy: [
|
||||||
|
{
|
||||||
|
dataType: 'string',
|
||||||
|
isColumn: false,
|
||||||
|
isJSON: false,
|
||||||
|
key: 'service_name',
|
||||||
|
type: 'tag',
|
||||||
|
id: 'service_name--string--tag--false',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
legend: 'p99',
|
||||||
|
reduceTo: 'avg',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataSource: 'metrics',
|
||||||
|
queryName: 'B',
|
||||||
|
aggregateOperator: 'rate',
|
||||||
|
aggregateAttribute: {
|
||||||
|
dataType: 'float64',
|
||||||
|
id: 'system_disk_operations--float64--Sum--true',
|
||||||
|
isColumn: true,
|
||||||
|
isJSON: false,
|
||||||
|
key: 'system_disk_operations',
|
||||||
|
type: 'Sum',
|
||||||
|
},
|
||||||
|
timeAggregation: 'rate',
|
||||||
|
spaceAggregation: 'sum',
|
||||||
|
functions: [],
|
||||||
|
filters: {
|
||||||
|
items: [],
|
||||||
|
op: 'AND',
|
||||||
|
},
|
||||||
|
expression: 'B',
|
||||||
|
disabled: false,
|
||||||
|
stepInterval: 60,
|
||||||
|
having: [],
|
||||||
|
limit: null,
|
||||||
|
orderBy: [],
|
||||||
|
groupBy: [],
|
||||||
|
legend: '',
|
||||||
|
reduceTo: 'avg',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
queryFormulas: [],
|
||||||
|
},
|
||||||
|
id: '48ad5a67-9a3c-49d4-a886-d7a34f8b875d',
|
||||||
|
queryType: 'builder',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const expectedOutputWithLegends = {
|
||||||
|
dataSource: [
|
||||||
|
{
|
||||||
|
A: 4196.71,
|
||||||
|
B: 'n/a',
|
||||||
|
service_name: 'demo-app',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
A: 500.83,
|
||||||
|
B: 'n/a',
|
||||||
|
service_name: 'customer',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
A: 499.5,
|
||||||
|
B: 'n/a',
|
||||||
|
service_name: 'mysql',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
A: 293.22,
|
||||||
|
B: 'n/a',
|
||||||
|
service_name: 'frontend',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
A: 230.03,
|
||||||
|
B: 'n/a',
|
||||||
|
service_name: 'driver',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
A: 67.09,
|
||||||
|
B: 'n/a',
|
||||||
|
service_name: 'route',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
A: 30.96,
|
||||||
|
B: 'n/a',
|
||||||
|
service_name: 'redis',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
A: 'n/a',
|
||||||
|
B: 112.27,
|
||||||
|
service_name: 'n/a',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
@ -0,0 +1,42 @@
|
|||||||
|
import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||||
|
|
||||||
|
import { createColumnsAndDataSource, getQueryLegend } from '../utils';
|
||||||
|
import {
|
||||||
|
expectedOutputWithLegends,
|
||||||
|
tableDataMultipleQueriesSuccessResponse,
|
||||||
|
widgetQueryWithLegend,
|
||||||
|
} from './response';
|
||||||
|
|
||||||
|
describe('Table Panel utils', () => {
|
||||||
|
it('createColumnsAndDataSource function', () => {
|
||||||
|
const data = tableDataMultipleQueriesSuccessResponse;
|
||||||
|
const query = widgetQueryWithLegend as Query;
|
||||||
|
|
||||||
|
const { columns, dataSource } = createColumnsAndDataSource(data, query);
|
||||||
|
|
||||||
|
expect(dataSource).toStrictEqual(expectedOutputWithLegends.dataSource);
|
||||||
|
|
||||||
|
// this makes sure that the columns are rendered in the same order as response
|
||||||
|
expect(columns[0].title).toBe('service_name');
|
||||||
|
// the next specifically makes sure that the legends are properly applied in multiple queries
|
||||||
|
expect(columns[1].title).toBe('p99');
|
||||||
|
// this makes sure that the query without a legend takes the title from the query response
|
||||||
|
expect(columns[2].title).toBe('B');
|
||||||
|
|
||||||
|
// this is to ensure that the rows properly map to the column data indexes as the dataIndex should be equal to name of the columns
|
||||||
|
// returned in the response as the rows will be mapped with them
|
||||||
|
expect((columns[0] as any).dataIndex).toBe('service_name');
|
||||||
|
expect((columns[1] as any).dataIndex).toBe('A');
|
||||||
|
expect((columns[2] as any).dataIndex).toBe('B');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getQueryLegend function', () => {
|
||||||
|
const query = widgetQueryWithLegend as Query;
|
||||||
|
|
||||||
|
// query A has a legend of p99
|
||||||
|
expect(getQueryLegend(query, 'A')).toBe('p99');
|
||||||
|
|
||||||
|
// should return undefined when legend not present
|
||||||
|
expect(getQueryLegend(query, 'B')).toBe(undefined);
|
||||||
|
});
|
||||||
|
});
|
@ -3,10 +3,7 @@ import { Space, Tooltip } from 'antd';
|
|||||||
import { getYAxisFormattedValue } from 'components/Graph/yAxisConfig';
|
import { getYAxisFormattedValue } from 'components/Graph/yAxisConfig';
|
||||||
import { Events } from 'constants/events';
|
import { Events } from 'constants/events';
|
||||||
import { QueryTable } from 'container/QueryTable';
|
import { QueryTable } from 'container/QueryTable';
|
||||||
import {
|
import { RowData } from 'lib/query/createTableColumnsFromQuery';
|
||||||
createTableColumnsFromQuery,
|
|
||||||
RowData,
|
|
||||||
} from 'lib/query/createTableColumnsFromQuery';
|
|
||||||
import { cloneDeep, get, isEmpty, set } from 'lodash-es';
|
import { cloneDeep, get, isEmpty, set } from 'lodash-es';
|
||||||
import { memo, ReactNode, useCallback, useEffect, useMemo } from 'react';
|
import { memo, ReactNode, useCallback, useEffect, useMemo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@ -14,7 +11,11 @@ import { eventEmitter } from 'utils/getEventEmitter';
|
|||||||
|
|
||||||
import { WrapperStyled } from './styles';
|
import { WrapperStyled } from './styles';
|
||||||
import { GridTableComponentProps } from './types';
|
import { GridTableComponentProps } from './types';
|
||||||
import { findMatchingThreshold } from './utils';
|
import {
|
||||||
|
createColumnsAndDataSource,
|
||||||
|
findMatchingThreshold,
|
||||||
|
TableData,
|
||||||
|
} from './utils';
|
||||||
|
|
||||||
function GridTableComponent({
|
function GridTableComponent({
|
||||||
data,
|
data,
|
||||||
@ -25,28 +26,26 @@ function GridTableComponent({
|
|||||||
...props
|
...props
|
||||||
}: GridTableComponentProps): JSX.Element {
|
}: GridTableComponentProps): JSX.Element {
|
||||||
const { t } = useTranslation(['valueGraph']);
|
const { t } = useTranslation(['valueGraph']);
|
||||||
|
|
||||||
|
// create columns and dataSource in the ui friendly structure
|
||||||
|
// use the query from the widget here to extract the legend information
|
||||||
const { columns, dataSource: originalDataSource } = useMemo(
|
const { columns, dataSource: originalDataSource } = useMemo(
|
||||||
() =>
|
() => createColumnsAndDataSource((data as unknown) as TableData, query),
|
||||||
createTableColumnsFromQuery({
|
[query, data],
|
||||||
query,
|
|
||||||
queryTableData: data,
|
|
||||||
}),
|
|
||||||
[data, query],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const createDataInCorrectFormat = useCallback(
|
const createDataInCorrectFormat = useCallback(
|
||||||
(dataSource: RowData[]): RowData[] =>
|
(dataSource: RowData[]): RowData[] =>
|
||||||
dataSource.map((d) => {
|
dataSource.map((d) => {
|
||||||
const finalObject = {};
|
const finalObject = {};
|
||||||
const keys = Object.keys(d);
|
|
||||||
keys.forEach((k) => {
|
// we use the order of the columns here to have similar download as the user view
|
||||||
const label = get(
|
columns.forEach((k) => {
|
||||||
columns.find((c) => get(c, 'dataIndex', '') === k) || {},
|
set(
|
||||||
'title',
|
finalObject,
|
||||||
'',
|
get(k, 'title', '') as string,
|
||||||
|
get(d, get(k, 'dataIndex', ''), 'n/a'),
|
||||||
);
|
);
|
||||||
if (label) {
|
|
||||||
set(finalObject, label as string, d[k]);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return finalObject as RowData;
|
return finalObject as RowData;
|
||||||
}),
|
}),
|
||||||
@ -65,7 +64,11 @@ function GridTableComponent({
|
|||||||
const newValue = { ...val };
|
const newValue = { ...val };
|
||||||
Object.keys(val).forEach((k) => {
|
Object.keys(val).forEach((k) => {
|
||||||
if (columnUnits[k]) {
|
if (columnUnits[k]) {
|
||||||
newValue[k] = getYAxisFormattedValue(String(val[k]), columnUnits[k]);
|
// the check below takes care of not adding units for rows that have n/a values
|
||||||
|
newValue[k] =
|
||||||
|
val[k] !== 'n/a'
|
||||||
|
? getYAxisFormattedValue(String(val[k]), columnUnits[k])
|
||||||
|
: val[k];
|
||||||
newValue[`${k}_without_unit`] = val[k];
|
newValue[`${k}_without_unit`] = val[k];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
|
import { ColumnsType, ColumnType } from 'antd/es/table';
|
||||||
import { ThresholdProps } from 'container/NewWidget/RightContainer/Threshold/types';
|
import { ThresholdProps } from 'container/NewWidget/RightContainer/Threshold/types';
|
||||||
|
import { QUERY_TABLE_CONFIG } from 'container/QueryTable/config';
|
||||||
|
import { QueryTableProps } from 'container/QueryTable/QueryTable.intefaces';
|
||||||
|
import { RowData } from 'lib/query/createTableColumnsFromQuery';
|
||||||
|
import { isEmpty, isNaN } from 'lodash-es';
|
||||||
|
import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||||
|
import { EQueryType } from 'types/common/dashboard';
|
||||||
|
|
||||||
// Helper function to evaluate the condition based on the operator
|
// Helper function to evaluate the condition based on the operator
|
||||||
function evaluateCondition(
|
function evaluateCondition(
|
||||||
@ -56,3 +63,85 @@ export function findMatchingThreshold(
|
|||||||
hasMultipleMatches,
|
hasMultipleMatches,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TableData {
|
||||||
|
columns: { name: string; queryName: string; isValueColumn: boolean }[];
|
||||||
|
rows: { data: any }[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getQueryLegend(
|
||||||
|
currentQuery: Query,
|
||||||
|
queryName: string,
|
||||||
|
): string | undefined {
|
||||||
|
let legend: string | undefined;
|
||||||
|
switch (currentQuery.queryType) {
|
||||||
|
case EQueryType.QUERY_BUILDER:
|
||||||
|
// check if the value is present in the queries
|
||||||
|
legend = currentQuery.builder.queryData.find(
|
||||||
|
(query) => query.queryName === queryName,
|
||||||
|
)?.legend;
|
||||||
|
|
||||||
|
if (!legend) {
|
||||||
|
// check if the value is present in the formula
|
||||||
|
legend = currentQuery.builder.queryFormulas.find(
|
||||||
|
(query) => query.queryName === queryName,
|
||||||
|
)?.legend;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EQueryType.CLICKHOUSE:
|
||||||
|
legend = currentQuery.clickhouse_sql.find(
|
||||||
|
(query) => query.name === queryName,
|
||||||
|
)?.legend;
|
||||||
|
break;
|
||||||
|
case EQueryType.PROM:
|
||||||
|
legend = currentQuery.promql.find((query) => query.name === queryName)
|
||||||
|
?.legend;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
legend = undefined;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return legend;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createColumnsAndDataSource(
|
||||||
|
data: TableData,
|
||||||
|
currentQuery: Query,
|
||||||
|
renderColumnCell?: QueryTableProps['renderColumnCell'],
|
||||||
|
): { columns: ColumnsType<RowData>; dataSource: RowData[] } {
|
||||||
|
const columns: ColumnsType<RowData> =
|
||||||
|
data.columns?.reduce<ColumnsType<RowData>>((acc, item) => {
|
||||||
|
// is the column is the value column then we need to check for the available legend
|
||||||
|
const legend = item.isValueColumn
|
||||||
|
? getQueryLegend(currentQuery, item.queryName)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
const column: ColumnType<RowData> = {
|
||||||
|
dataIndex: item.name,
|
||||||
|
// if no legend present then rely on the column name value
|
||||||
|
title: !isEmpty(legend) ? legend : item.name,
|
||||||
|
width: QUERY_TABLE_CONFIG.width,
|
||||||
|
render: renderColumnCell && renderColumnCell[item.name],
|
||||||
|
sorter: (a: RowData, b: RowData): number => {
|
||||||
|
const valueA = Number(a[`${item.name}_without_unit`] ?? a[item.name]);
|
||||||
|
const valueB = Number(b[`${item.name}_without_unit`] ?? b[item.name]);
|
||||||
|
|
||||||
|
if (!isNaN(valueA) && !isNaN(valueB)) {
|
||||||
|
return valueA - valueB;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((a[item.name] as string) || '').localeCompare(
|
||||||
|
(b[item.name] as string) || '',
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return [...acc, column];
|
||||||
|
}, []) || [];
|
||||||
|
|
||||||
|
// the rows returned have data encapsulation hence removing the same here
|
||||||
|
const dataSource = data.rows?.map((d) => d.data) || [];
|
||||||
|
|
||||||
|
return { columns, dataSource };
|
||||||
|
}
|
||||||
|
@ -2,8 +2,6 @@ import { Card, Typography } from 'antd';
|
|||||||
import Spinner from 'components/Spinner';
|
import Spinner from 'components/Spinner';
|
||||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||||
import { WidgetGraphContainerProps } from 'container/NewWidget/types';
|
import { WidgetGraphContainerProps } from 'container/NewWidget/types';
|
||||||
// import useUrlQuery from 'hooks/useUrlQuery';
|
|
||||||
// import { useDashboard } from 'providers/Dashboard/Dashboard';
|
|
||||||
import { getSortedSeriesData } from 'utils/getSortedSeriesData';
|
import { getSortedSeriesData } from 'utils/getSortedSeriesData';
|
||||||
|
|
||||||
import { NotFoundContainer } from './styles';
|
import { NotFoundContainer } from './styles';
|
||||||
@ -59,6 +57,14 @@ function WidgetGraphContainer({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (queryResponse.isIdle) {
|
||||||
|
return (
|
||||||
|
<NotFoundContainer>
|
||||||
|
<Typography>No Data</Typography>
|
||||||
|
</NotFoundContainer>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WidgetGraph
|
<WidgetGraph
|
||||||
selectedWidget={selectedWidget}
|
selectedWidget={selectedWidget}
|
||||||
|
@ -44,6 +44,9 @@ function LeftContainer({
|
|||||||
graphType: getGraphType(selectedGraph || selectedWidget.panelTypes),
|
graphType: getGraphType(selectedGraph || selectedWidget.panelTypes),
|
||||||
query: stagedQuery || initialQueriesMap.metrics,
|
query: stagedQuery || initialQueriesMap.metrics,
|
||||||
globalSelectedInterval,
|
globalSelectedInterval,
|
||||||
|
formatForWeb:
|
||||||
|
getGraphType(selectedGraph || selectedWidget.panelTypes) ===
|
||||||
|
PANEL_TYPES.TABLE,
|
||||||
variables: getDashboardVariables(selectedDashboard?.data.variables),
|
variables: getDashboardVariables(selectedDashboard?.data.variables),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -73,6 +76,9 @@ function LeftContainer({
|
|||||||
graphType: getGraphType(selectedGraph || selectedWidget.panelTypes),
|
graphType: getGraphType(selectedGraph || selectedWidget.panelTypes),
|
||||||
query: stagedQuery,
|
query: stagedQuery,
|
||||||
fillGaps: selectedWidget.fillSpans || false,
|
fillGaps: selectedWidget.fillSpans || false,
|
||||||
|
formatForWeb:
|
||||||
|
getGraphType(selectedGraph || selectedWidget.panelTypes) ===
|
||||||
|
PANEL_TYPES.TABLE,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
@ -9,7 +9,7 @@ function TablePanelWrapper({
|
|||||||
tableProcessedDataRef,
|
tableProcessedDataRef,
|
||||||
}: PanelWrapperProps): JSX.Element {
|
}: PanelWrapperProps): JSX.Element {
|
||||||
const panelData =
|
const panelData =
|
||||||
queryResponse.data?.payload?.data?.newResult?.data?.result || [];
|
(queryResponse.data?.payload?.data?.result?.[0] as any)?.table || [];
|
||||||
const { thresholds } = widget;
|
const { thresholds } = widget;
|
||||||
return (
|
return (
|
||||||
<GridTableComponent
|
<GridTableComponent
|
||||||
|
@ -12,7 +12,7 @@ import {
|
|||||||
} from 'container/TopNav/DateTimeSelectionV2/config';
|
} from 'container/TopNav/DateTimeSelectionV2/config';
|
||||||
import { Pagination } from 'hooks/queryPagination';
|
import { Pagination } from 'hooks/queryPagination';
|
||||||
import { convertNewDataToOld } from 'lib/newQueryBuilder/convertNewDataToOld';
|
import { convertNewDataToOld } from 'lib/newQueryBuilder/convertNewDataToOld';
|
||||||
import { isEmpty } from 'lodash-es';
|
import { isEmpty, cloneDeep } from 'lodash-es';
|
||||||
import { SuccessResponse } from 'types/api';
|
import { SuccessResponse } from 'types/api';
|
||||||
import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';
|
import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';
|
||||||
import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||||
@ -40,6 +40,10 @@ export async function GetMetricQueryRange(
|
|||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (props.formatForWeb) {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
if (response.payload?.data?.result) {
|
if (response.payload?.data?.result) {
|
||||||
const v2Range = convertNewDataToOld(response.payload);
|
const v2Range = convertNewDataToOld(response.payload);
|
||||||
|
|
||||||
@ -76,6 +80,7 @@ export interface GetQueryResultsProps {
|
|||||||
variables?: Record<string, unknown>;
|
variables?: Record<string, unknown>;
|
||||||
params?: Record<string, unknown>;
|
params?: Record<string, unknown>;
|
||||||
fillGaps?: boolean;
|
fillGaps?: boolean;
|
||||||
|
formatForWeb?: boolean;
|
||||||
tableParams?: {
|
tableParams?: {
|
||||||
pagination?: Pagination;
|
pagination?: Pagination;
|
||||||
selectColumns?: any;
|
selectColumns?: any;
|
||||||
|
@ -16,6 +16,7 @@ export const prepareQueryRangePayload = ({
|
|||||||
query,
|
query,
|
||||||
globalSelectedInterval,
|
globalSelectedInterval,
|
||||||
graphType,
|
graphType,
|
||||||
|
formatForWeb,
|
||||||
selectedTime,
|
selectedTime,
|
||||||
tableParams,
|
tableParams,
|
||||||
variables = {},
|
variables = {},
|
||||||
@ -102,6 +103,7 @@ export const prepareQueryRangePayload = ({
|
|||||||
inputFormat: 'ns',
|
inputFormat: 'ns',
|
||||||
}),
|
}),
|
||||||
variables,
|
variables,
|
||||||
|
formatForWeb,
|
||||||
compositeQuery,
|
compositeQuery,
|
||||||
...restParams,
|
...restParams,
|
||||||
};
|
};
|
||||||
|
@ -24,6 +24,7 @@ export type QueryRangePayload = {
|
|||||||
start: number;
|
start: number;
|
||||||
step: number;
|
step: number;
|
||||||
variables?: Record<string, unknown>;
|
variables?: Record<string, unknown>;
|
||||||
|
formatForWeb?: boolean;
|
||||||
[param: string]: unknown;
|
[param: string]: unknown;
|
||||||
};
|
};
|
||||||
export interface MetricRangePayloadProps {
|
export interface MetricRangePayloadProps {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user