Palash Gupta f4ecfb510a
fix: trace explorer and logs explorer export to dashboard is handled (#4001)
Co-authored-by: Yunus M <myounis.ar@live.com>
2023-11-21 00:52:53 +05:30

40 lines
799 B
TypeScript

import { PANEL_TYPES } from 'constants/queryBuilder';
import { Dashboard } from 'types/api/dashboard/getAll';
import { Query } from 'types/api/queryBuilder/queryBuilderData';
export const addEmptyWidgetInDashboardJSONWithQuery = (
dashboard: Dashboard,
query: Query,
widgetId: string,
panelTypes?: PANEL_TYPES,
): Dashboard => ({
...dashboard,
data: {
...dashboard.data,
layout: [
{
i: widgetId,
w: 6,
x: 0,
h: 3,
y: 0,
},
...(dashboard?.data?.layout || []),
],
widgets: [
...(dashboard?.data?.widgets || []),
{
id: widgetId,
query,
description: '',
isStacked: false,
nullZeroValues: '',
opacity: '',
title: '',
timePreferance: 'GLOBAL_TIME',
panelTypes: panelTypes || PANEL_TYPES.TIME_SERIES,
},
],
},
});