mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-13 06:09:02 +08:00
chore: dashboard detail - panel data fetched - telemetry (#5871)
* chore: dashboard detail - panel data fetched - telemetry * chore: dashboard detail - code refactor
This commit is contained in:
parent
4eb533fff8
commit
292b3f418e
@ -22,6 +22,7 @@ import { getSortedSeriesData } from 'utils/getSortedSeriesData';
|
|||||||
import EmptyWidget from '../EmptyWidget';
|
import EmptyWidget from '../EmptyWidget';
|
||||||
import { MenuItemKeys } from '../WidgetHeader/contants';
|
import { MenuItemKeys } from '../WidgetHeader/contants';
|
||||||
import { GridCardGraphProps } from './types';
|
import { GridCardGraphProps } from './types';
|
||||||
|
import { isDataAvailableByPanelType } from './utils';
|
||||||
import WidgetGraphComponent from './WidgetGraphComponent';
|
import WidgetGraphComponent from './WidgetGraphComponent';
|
||||||
|
|
||||||
function GridCardGraph({
|
function GridCardGraph({
|
||||||
@ -182,7 +183,9 @@ function GridCardGraph({
|
|||||||
setErrorMessage(error.message);
|
setErrorMessage(error.message);
|
||||||
},
|
},
|
||||||
onSettled: (data) => {
|
onSettled: (data) => {
|
||||||
dataAvailable?.(Boolean(data?.payload?.data?.result?.length));
|
dataAvailable?.(
|
||||||
|
isDataAvailableByPanelType(data?.payload?.data, widget?.panelTypes),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
/* eslint-disable sonarjs/cognitive-complexity */
|
/* eslint-disable sonarjs/cognitive-complexity */
|
||||||
import { LOCALSTORAGE } from 'constants/localStorage';
|
import { LOCALSTORAGE } from 'constants/localStorage';
|
||||||
|
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||||
import getLabelName from 'lib/getLabelName';
|
import getLabelName from 'lib/getLabelName';
|
||||||
|
import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';
|
||||||
import { QueryData } from 'types/api/widgets/getQuery';
|
import { QueryData } from 'types/api/widgets/getQuery';
|
||||||
|
|
||||||
import { LegendEntryProps } from './FullView/types';
|
import { LegendEntryProps } from './FullView/types';
|
||||||
@ -131,3 +133,21 @@ export const toggleGraphsVisibilityInChart = ({
|
|||||||
lineChartRef?.current?.toggleGraph(index, showLegendData);
|
lineChartRef?.current?.toggleGraph(index, showLegendData);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const isDataAvailableByPanelType = (
|
||||||
|
data?: MetricRangePayloadProps['data'],
|
||||||
|
panelType?: string,
|
||||||
|
): boolean => {
|
||||||
|
const getPanelData = (): any[] | undefined => {
|
||||||
|
switch (panelType) {
|
||||||
|
case PANEL_TYPES.TABLE:
|
||||||
|
return (data?.result?.[0] as any)?.table?.rows;
|
||||||
|
case PANEL_TYPES.LIST:
|
||||||
|
return data?.newResult?.data?.result?.[0]?.list as any[];
|
||||||
|
default:
|
||||||
|
return data?.result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return Boolean(getPanelData()?.length);
|
||||||
|
};
|
||||||
|
@ -438,6 +438,10 @@ function GraphLayout(props: GraphLayoutProps): JSX.Element {
|
|||||||
: true,
|
: true,
|
||||||
[selectedDashboard],
|
[selectedDashboard],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let isDataAvailableInAnyWidget = false;
|
||||||
|
const isLogEventCalled = useRef<boolean>(false);
|
||||||
|
|
||||||
return isDashboardEmpty ? (
|
return isDashboardEmpty ? (
|
||||||
<DashboardEmptyState />
|
<DashboardEmptyState />
|
||||||
) : (
|
) : (
|
||||||
@ -516,6 +520,18 @@ function GraphLayout(props: GraphLayoutProps): JSX.Element {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const checkIfDataExists = (isDataAvailable: boolean): void => {
|
||||||
|
if (!isDataAvailableInAnyWidget && isDataAvailable) {
|
||||||
|
isDataAvailableInAnyWidget = true;
|
||||||
|
}
|
||||||
|
if (!isLogEventCalled.current && isDataAvailableInAnyWidget) {
|
||||||
|
isLogEventCalled.current = true;
|
||||||
|
logEvent('Dashboard Detail: Panel data fetched', {
|
||||||
|
isDataAvailableInAnyWidget,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CardContainer
|
<CardContainer
|
||||||
className={isDashboardLocked ? '' : 'enable-resize'}
|
className={isDashboardLocked ? '' : 'enable-resize'}
|
||||||
@ -534,6 +550,7 @@ function GraphLayout(props: GraphLayoutProps): JSX.Element {
|
|||||||
variables={variables}
|
variables={variables}
|
||||||
version={selectedDashboard?.data?.version}
|
version={selectedDashboard?.data?.version}
|
||||||
onDragSelect={onDragSelect}
|
onDragSelect={onDragSelect}
|
||||||
|
dataAvailable={checkIfDataExists}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</CardContainer>
|
</CardContainer>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user