mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-06-20 21:41:24 +08:00
feat: add ability to change panel type (#2383)
* feat: add ability to change panel type * feat: add ability to change panel type --------- Co-authored-by: gitstart <gitstart@users.noreply.github.com> Co-authored-by: palashgdev <palashgdev@gmail.com>
This commit is contained in:
parent
eff87f2666
commit
c821e8bb75
@ -1,8 +1,10 @@
|
|||||||
import { Input } from 'antd';
|
import { Input, Select } from 'antd';
|
||||||
import InputComponent from 'components/Input';
|
import InputComponent from 'components/Input';
|
||||||
import TimePreference from 'components/TimePreferenceDropDown';
|
import TimePreference from 'components/TimePreferenceDropDown';
|
||||||
import { GRAPH_TYPES } from 'container/NewDashboard/ComponentsSlider';
|
import { GRAPH_TYPES } from 'container/NewDashboard/ComponentsSlider';
|
||||||
import GraphTypes from 'container/NewDashboard/ComponentsSlider/menuItems';
|
import GraphTypes, {
|
||||||
|
ITEMS,
|
||||||
|
} from 'container/NewDashboard/ComponentsSlider/menuItems';
|
||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
|
|
||||||
import { Container, Title } from './styles';
|
import { Container, Title } from './styles';
|
||||||
@ -10,6 +12,7 @@ import { timePreferance } from './timeItems';
|
|||||||
import YAxisUnitSelector from './YAxisUnitSelector';
|
import YAxisUnitSelector from './YAxisUnitSelector';
|
||||||
|
|
||||||
const { TextArea } = Input;
|
const { TextArea } = Input;
|
||||||
|
const { Option } = Select;
|
||||||
|
|
||||||
function RightContainer({
|
function RightContainer({
|
||||||
description,
|
description,
|
||||||
@ -21,6 +24,7 @@ function RightContainer({
|
|||||||
selectedTime,
|
selectedTime,
|
||||||
yAxisUnit,
|
yAxisUnit,
|
||||||
setYAxisUnit,
|
setYAxisUnit,
|
||||||
|
setGraphHandler,
|
||||||
}: RightContainerProps): JSX.Element {
|
}: RightContainerProps): JSX.Element {
|
||||||
const onChangeHandler = useCallback(
|
const onChangeHandler = useCallback(
|
||||||
(setFunc: React.Dispatch<React.SetStateAction<string>>, value: string) => {
|
(setFunc: React.Dispatch<React.SetStateAction<string>>, value: string) => {
|
||||||
@ -34,14 +38,18 @@ function RightContainer({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<InputComponent
|
<Title>Panel Type</Title>
|
||||||
labelOnTop
|
<Select
|
||||||
label="Panel Type"
|
onChange={(value: ITEMS): void => setGraphHandler(value)}
|
||||||
size="middle"
|
value={selectedGraph}
|
||||||
value={selectedGraphType}
|
style={{ width: '100%', marginBottom: 24 }}
|
||||||
disabled
|
>
|
||||||
/>
|
{GraphTypes.map((item) => (
|
||||||
|
<Option key={item.name} value={item.name}>
|
||||||
|
{item.display}
|
||||||
|
</Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
<Title>Panel Attributes</Title>
|
<Title>Panel Attributes</Title>
|
||||||
|
|
||||||
<InputComponent
|
<InputComponent
|
||||||
@ -140,6 +148,7 @@ interface RightContainerProps {
|
|||||||
selectedTime: timePreferance;
|
selectedTime: timePreferance;
|
||||||
yAxisUnit: string;
|
yAxisUnit: string;
|
||||||
setYAxisUnit: React.Dispatch<React.SetStateAction<string>>;
|
setYAxisUnit: React.Dispatch<React.SetStateAction<string>>;
|
||||||
|
setGraphHandler: (type: ITEMS) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RightContainer;
|
export default RightContainer;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Button, Modal, Typography } from 'antd';
|
import { Button, Modal, Typography } from 'antd';
|
||||||
import ROUTES from 'constants/routes';
|
import ROUTES from 'constants/routes';
|
||||||
import { GRAPH_TYPES } from 'container/NewDashboard/ComponentsSlider';
|
import { GRAPH_TYPES } from 'container/NewDashboard/ComponentsSlider';
|
||||||
|
import { ITEMS } from 'container/NewDashboard/ComponentsSlider/menuItems';
|
||||||
import { getDashboardVariables } from 'lib/dashbaordVariables/getDashboardVariables';
|
import { getDashboardVariables } from 'lib/dashbaordVariables/getDashboardVariables';
|
||||||
import history from 'lib/history';
|
import history from 'lib/history';
|
||||||
import { DashboardWidgetPageParams } from 'pages/DashboardWidget';
|
import { DashboardWidgetPageParams } from 'pages/DashboardWidget';
|
||||||
@ -86,6 +87,7 @@ function NewWidget({
|
|||||||
const [saveModal, setSaveModal] = useState(false);
|
const [saveModal, setSaveModal] = useState(false);
|
||||||
const [hasUnstagedChanges, setHasUnstagedChanges] = useState(false);
|
const [hasUnstagedChanges, setHasUnstagedChanges] = useState(false);
|
||||||
|
|
||||||
|
const [graphType, setGraphType] = useState(selectedGraph);
|
||||||
const getSelectedTime = useCallback(
|
const getSelectedTime = useCallback(
|
||||||
() =>
|
() =>
|
||||||
TimeItems.find(
|
TimeItems.find(
|
||||||
@ -112,6 +114,7 @@ function NewWidget({
|
|||||||
yAxisUnit,
|
yAxisUnit,
|
||||||
widgetId: query.get('widgetId') || '',
|
widgetId: query.get('widgetId') || '',
|
||||||
dashboardId,
|
dashboardId,
|
||||||
|
graphType,
|
||||||
});
|
});
|
||||||
}, [
|
}, [
|
||||||
saveSettingOfPanel,
|
saveSettingOfPanel,
|
||||||
@ -125,6 +128,7 @@ function NewWidget({
|
|||||||
yAxisUnit,
|
yAxisUnit,
|
||||||
query,
|
query,
|
||||||
dashboardId,
|
dashboardId,
|
||||||
|
graphType,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const onClickDiscardHandler = useCallback(() => {
|
const onClickDiscardHandler = useCallback(() => {
|
||||||
@ -140,7 +144,7 @@ function NewWidget({
|
|||||||
query: selectedWidget?.query,
|
query: selectedWidget?.query,
|
||||||
selectedTime: selectedTime.enum,
|
selectedTime: selectedTime.enum,
|
||||||
widgetId: selectedWidget?.id || '',
|
widgetId: selectedWidget?.id || '',
|
||||||
graphType: selectedGraph,
|
graphType,
|
||||||
globalSelectedInterval,
|
globalSelectedInterval,
|
||||||
variables: getDashboardVariables(),
|
variables: getDashboardVariables(),
|
||||||
});
|
});
|
||||||
@ -149,11 +153,18 @@ function NewWidget({
|
|||||||
selectedWidget?.query,
|
selectedWidget?.query,
|
||||||
selectedTime.enum,
|
selectedTime.enum,
|
||||||
selectedWidget?.id,
|
selectedWidget?.id,
|
||||||
selectedGraph,
|
|
||||||
getQueryResults,
|
getQueryResults,
|
||||||
globalSelectedInterval,
|
globalSelectedInterval,
|
||||||
|
graphType,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const setGraphHandler = (type: ITEMS): void => {
|
||||||
|
const params = new URLSearchParams(search);
|
||||||
|
params.set('graphType', type);
|
||||||
|
history.push({ search: params.toString() });
|
||||||
|
setGraphType(type);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getQueryResult();
|
getQueryResult();
|
||||||
}, [getQueryResult]);
|
}, [getQueryResult]);
|
||||||
@ -173,13 +184,14 @@ function NewWidget({
|
|||||||
<LeftContainer
|
<LeftContainer
|
||||||
handleUnstagedChanges={setHasUnstagedChanges}
|
handleUnstagedChanges={setHasUnstagedChanges}
|
||||||
selectedTime={selectedTime}
|
selectedTime={selectedTime}
|
||||||
selectedGraph={selectedGraph}
|
selectedGraph={graphType}
|
||||||
yAxisUnit={yAxisUnit}
|
yAxisUnit={yAxisUnit}
|
||||||
/>
|
/>
|
||||||
</LeftContainerWrapper>
|
</LeftContainerWrapper>
|
||||||
|
|
||||||
<RightContainerWrapper flex={1}>
|
<RightContainerWrapper flex={1}>
|
||||||
<RightContainer
|
<RightContainer
|
||||||
|
setGraphHandler={setGraphHandler}
|
||||||
{...{
|
{...{
|
||||||
title,
|
title,
|
||||||
setTitle,
|
setTitle,
|
||||||
@ -192,7 +204,7 @@ function NewWidget({
|
|||||||
setOpacity,
|
setOpacity,
|
||||||
selectedNullZeroValue,
|
selectedNullZeroValue,
|
||||||
setSelectedNullZeroValue,
|
setSelectedNullZeroValue,
|
||||||
selectedGraph,
|
selectedGraph: graphType,
|
||||||
setSelectedTime,
|
setSelectedTime,
|
||||||
selectedTime,
|
selectedTime,
|
||||||
setYAxisUnit,
|
setYAxisUnit,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import updateDashboardApi from 'api/dashboard/update';
|
import updateDashboardApi from 'api/dashboard/update';
|
||||||
import { AxiosError } from 'axios';
|
import { AxiosError } from 'axios';
|
||||||
import ROUTES from 'constants/routes';
|
import ROUTES from 'constants/routes';
|
||||||
|
import { ITEMS } from 'container/NewDashboard/ComponentsSlider/menuItems';
|
||||||
import history from 'lib/history';
|
import history from 'lib/history';
|
||||||
import { Layout } from 'react-grid-layout';
|
import { Layout } from 'react-grid-layout';
|
||||||
import { generatePath } from 'react-router-dom';
|
import { generatePath } from 'react-router-dom';
|
||||||
@ -21,12 +22,12 @@ export const SaveDashboard = ({
|
|||||||
widgetId,
|
widgetId,
|
||||||
dashboardId,
|
dashboardId,
|
||||||
yAxisUnit,
|
yAxisUnit,
|
||||||
|
graphType,
|
||||||
}: SaveDashboardProps): ((dispatch: Dispatch<AppActions>) => void) =>
|
}: SaveDashboardProps): ((dispatch: Dispatch<AppActions>) => void) =>
|
||||||
// eslint-disable-next-line sonarjs/cognitive-complexity
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||||
async (dispatch: Dispatch<AppActions>): Promise<void> => {
|
async (dispatch: Dispatch<AppActions>): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const dashboard = store.getState();
|
const dashboard = store.getState();
|
||||||
const search = new URLSearchParams(history.location.search);
|
|
||||||
|
|
||||||
const selectedDashboard = dashboard.dashboards.dashboards.find(
|
const selectedDashboard = dashboard.dashboards.dashboards.find(
|
||||||
(e) => e.uuid === uuid,
|
(e) => e.uuid === uuid,
|
||||||
@ -105,7 +106,7 @@ export const SaveDashboard = ({
|
|||||||
title: updatedTitle,
|
title: updatedTitle,
|
||||||
timePreferance: updatedtimePreferance,
|
timePreferance: updatedtimePreferance,
|
||||||
yAxisUnit: updatedYAxisUnit,
|
yAxisUnit: updatedYAxisUnit,
|
||||||
panelTypes: search.get('graphType') as Widgets['panelTypes'],
|
panelTypes: graphType,
|
||||||
queryData: {
|
queryData: {
|
||||||
...selectedWidget.queryData,
|
...selectedWidget.queryData,
|
||||||
},
|
},
|
||||||
@ -151,4 +152,5 @@ export interface SaveDashboardProps {
|
|||||||
widgetId: Widgets['id'];
|
widgetId: Widgets['id'];
|
||||||
dashboardId: string;
|
dashboardId: string;
|
||||||
yAxisUnit: Widgets['yAxisUnit'];
|
yAxisUnit: Widgets['yAxisUnit'];
|
||||||
|
graphType: ITEMS;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user