mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-18 07:56:56 +00:00
40 lines
799 B
TypeScript
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,
|
|
},
|
|
],
|
|
},
|
|
});
|