mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-17 15:36:48 +00:00
fix: added loading indicators in traces pages when running query (#8782)
This commit is contained in:
parent
249f8be845
commit
0e3ac2a179
@ -20,6 +20,7 @@ function TimeSeriesViewContainer({
|
|||||||
dataSource = DataSource.TRACES,
|
dataSource = DataSource.TRACES,
|
||||||
isFilterApplied,
|
isFilterApplied,
|
||||||
setWarning,
|
setWarning,
|
||||||
|
setIsLoadingQueries,
|
||||||
}: TimeSeriesViewProps): JSX.Element {
|
}: TimeSeriesViewProps): JSX.Element {
|
||||||
const { stagedQuery, currentQuery, panelType } = useQueryBuilder();
|
const { stagedQuery, currentQuery, panelType } = useQueryBuilder();
|
||||||
|
|
||||||
@ -83,6 +84,14 @@ function TimeSeriesViewContainer({
|
|||||||
[data, isValidToConvertToMs],
|
[data, isValidToConvertToMs],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isLoading || isFetching) {
|
||||||
|
setIsLoadingQueries(true);
|
||||||
|
} else {
|
||||||
|
setIsLoadingQueries(false);
|
||||||
|
}
|
||||||
|
}, [isLoading, isFetching, setIsLoadingQueries]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TimeSeriesView
|
<TimeSeriesView
|
||||||
isFilterApplied={isFilterApplied}
|
isFilterApplied={isFilterApplied}
|
||||||
@ -101,6 +110,7 @@ interface TimeSeriesViewProps {
|
|||||||
dataSource?: DataSource;
|
dataSource?: DataSource;
|
||||||
isFilterApplied: boolean;
|
isFilterApplied: boolean;
|
||||||
setWarning: Dispatch<SetStateAction<Warning | undefined>>;
|
setWarning: Dispatch<SetStateAction<Warning | undefined>>;
|
||||||
|
setIsLoadingQueries: Dispatch<SetStateAction<boolean>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeSeriesViewContainer.defaultProps = {
|
TimeSeriesViewContainer.defaultProps = {
|
||||||
|
|||||||
@ -49,9 +49,14 @@ import { getListColumns, transformDataWithDate } from './utils';
|
|||||||
interface ListViewProps {
|
interface ListViewProps {
|
||||||
isFilterApplied: boolean;
|
isFilterApplied: boolean;
|
||||||
setWarning: Dispatch<SetStateAction<Warning | undefined>>;
|
setWarning: Dispatch<SetStateAction<Warning | undefined>>;
|
||||||
|
setIsLoadingQueries: Dispatch<SetStateAction<boolean>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ListView({ isFilterApplied, setWarning }: ListViewProps): JSX.Element {
|
function ListView({
|
||||||
|
isFilterApplied,
|
||||||
|
setWarning,
|
||||||
|
setIsLoadingQueries,
|
||||||
|
}: ListViewProps): JSX.Element {
|
||||||
const {
|
const {
|
||||||
stagedQuery,
|
stagedQuery,
|
||||||
panelType: panelTypeFromQueryBuilder,
|
panelType: panelTypeFromQueryBuilder,
|
||||||
@ -162,6 +167,14 @@ function ListView({ isFilterApplied, setWarning }: ListViewProps): JSX.Element {
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [data?.payload, data?.warning]);
|
}, [data?.payload, data?.warning]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isLoading || isFetching) {
|
||||||
|
setIsLoadingQueries(true);
|
||||||
|
} else {
|
||||||
|
setIsLoadingQueries(false);
|
||||||
|
}
|
||||||
|
}, [isLoading, isFetching, setIsLoadingQueries]);
|
||||||
|
|
||||||
const dataLength =
|
const dataLength =
|
||||||
data?.payload?.data?.newResult?.data?.result[0]?.list?.length;
|
data?.payload?.data?.newResult?.data?.result[0]?.list?.length;
|
||||||
const totalCount = useMemo(() => dataLength || 0, [dataLength]);
|
const totalCount = useMemo(() => dataLength || 0, [dataLength]);
|
||||||
|
|||||||
@ -16,8 +16,10 @@ import { GlobalReducer } from 'types/reducer/globalTime';
|
|||||||
|
|
||||||
function TableView({
|
function TableView({
|
||||||
setWarning,
|
setWarning,
|
||||||
|
setIsLoadingQueries,
|
||||||
}: {
|
}: {
|
||||||
setWarning: Dispatch<SetStateAction<Warning | undefined>>;
|
setWarning: Dispatch<SetStateAction<Warning | undefined>>;
|
||||||
|
setIsLoadingQueries: Dispatch<SetStateAction<boolean>>;
|
||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
const { stagedQuery, panelType } = useQueryBuilder();
|
const { stagedQuery, panelType } = useQueryBuilder();
|
||||||
|
|
||||||
@ -26,7 +28,7 @@ function TableView({
|
|||||||
GlobalReducer
|
GlobalReducer
|
||||||
>((state) => state.globalTime);
|
>((state) => state.globalTime);
|
||||||
|
|
||||||
const { data, isLoading, isError, error } = useGetQueryRange(
|
const { data, isLoading, isFetching, isError, error } = useGetQueryRange(
|
||||||
{
|
{
|
||||||
query: stagedQuery || initialQueriesMap.traces,
|
query: stagedQuery || initialQueriesMap.traces,
|
||||||
graphType: panelType || PANEL_TYPES.TABLE,
|
graphType: panelType || PANEL_TYPES.TABLE,
|
||||||
@ -49,6 +51,14 @@ function TableView({
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isLoading || isFetching) {
|
||||||
|
setIsLoadingQueries(true);
|
||||||
|
} else {
|
||||||
|
setIsLoadingQueries(false);
|
||||||
|
}
|
||||||
|
}, [isLoading, isFetching, setIsLoadingQueries]);
|
||||||
|
|
||||||
const queryTableData = useMemo(
|
const queryTableData = useMemo(
|
||||||
() =>
|
() =>
|
||||||
data?.payload?.data?.newResult?.data?.result ||
|
data?.payload?.data?.newResult?.data?.result ||
|
||||||
|
|||||||
@ -40,11 +40,13 @@ import { ActionsContainer, Container } from './styles';
|
|||||||
interface TracesViewProps {
|
interface TracesViewProps {
|
||||||
isFilterApplied: boolean;
|
isFilterApplied: boolean;
|
||||||
setWarning: Dispatch<SetStateAction<Warning | undefined>>;
|
setWarning: Dispatch<SetStateAction<Warning | undefined>>;
|
||||||
|
setIsLoadingQueries: Dispatch<SetStateAction<boolean>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function TracesView({
|
function TracesView({
|
||||||
isFilterApplied,
|
isFilterApplied,
|
||||||
setWarning,
|
setWarning,
|
||||||
|
setIsLoadingQueries,
|
||||||
}: TracesViewProps): JSX.Element {
|
}: TracesViewProps): JSX.Element {
|
||||||
const { stagedQuery, panelType } = useQueryBuilder();
|
const { stagedQuery, panelType } = useQueryBuilder();
|
||||||
const [orderBy, setOrderBy] = useState<string>('timestamp:desc');
|
const [orderBy, setOrderBy] = useState<string>('timestamp:desc');
|
||||||
@ -117,6 +119,14 @@ function TracesView({
|
|||||||
[responseData],
|
[responseData],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isLoading || isFetching) {
|
||||||
|
setIsLoadingQueries(true);
|
||||||
|
} else {
|
||||||
|
setIsLoadingQueries(false);
|
||||||
|
}
|
||||||
|
}, [isLoading, isFetching, setIsLoadingQueries]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isLoading && !isFetching && !isError && (tableData || []).length !== 0) {
|
if (!isLoading && !isFetching && !isError && (tableData || []).length !== 0) {
|
||||||
logEvent('Traces Explorer: Data present', {
|
logEvent('Traces Explorer: Data present', {
|
||||||
|
|||||||
@ -69,6 +69,7 @@ function TracesExplorer(): JSX.Element {
|
|||||||
|
|
||||||
// Get panel type from URL
|
// Get panel type from URL
|
||||||
const panelTypesFromUrl = useGetPanelTypesQueryParam(PANEL_TYPES.LIST);
|
const panelTypesFromUrl = useGetPanelTypesQueryParam(PANEL_TYPES.LIST);
|
||||||
|
const [isLoadingQueries, setIsLoadingQueries] = useState<boolean>(false);
|
||||||
|
|
||||||
const [selectedView, setSelectedView] = useState<ExplorerViews>(() =>
|
const [selectedView, setSelectedView] = useState<ExplorerViews>(() =>
|
||||||
getExplorerViewFromUrl(searchParams, panelTypesFromUrl),
|
getExplorerViewFromUrl(searchParams, panelTypesFromUrl),
|
||||||
@ -323,6 +324,7 @@ function TracesExplorer(): JSX.Element {
|
|||||||
rightActions={
|
rightActions={
|
||||||
<RightToolbarActions
|
<RightToolbarActions
|
||||||
onStageRunQuery={(): void => handleRunQuery(true, true)}
|
onStageRunQuery={(): void => handleRunQuery(true, true)}
|
||||||
|
isLoadingQueries={isLoadingQueries}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@ -344,13 +346,21 @@ function TracesExplorer(): JSX.Element {
|
|||||||
|
|
||||||
{selectedView === ExplorerViews.LIST && (
|
{selectedView === ExplorerViews.LIST && (
|
||||||
<div className="trace-explorer-list-view">
|
<div className="trace-explorer-list-view">
|
||||||
<ListView isFilterApplied={isFilterApplied} setWarning={setWarning} />
|
<ListView
|
||||||
|
isFilterApplied={isFilterApplied}
|
||||||
|
setWarning={setWarning}
|
||||||
|
setIsLoadingQueries={setIsLoadingQueries}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{selectedView === ExplorerViews.TRACE && (
|
{selectedView === ExplorerViews.TRACE && (
|
||||||
<div className="trace-explorer-traces-view">
|
<div className="trace-explorer-traces-view">
|
||||||
<TracesView isFilterApplied={isFilterApplied} setWarning={setWarning} />
|
<TracesView
|
||||||
|
isFilterApplied={isFilterApplied}
|
||||||
|
setWarning={setWarning}
|
||||||
|
setIsLoadingQueries={setIsLoadingQueries}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@ -360,13 +370,17 @@ function TracesExplorer(): JSX.Element {
|
|||||||
dataSource={DataSource.TRACES}
|
dataSource={DataSource.TRACES}
|
||||||
isFilterApplied={isFilterApplied}
|
isFilterApplied={isFilterApplied}
|
||||||
setWarning={setWarning}
|
setWarning={setWarning}
|
||||||
|
setIsLoadingQueries={setIsLoadingQueries}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{selectedView === ExplorerViews.TABLE && (
|
{selectedView === ExplorerViews.TABLE && (
|
||||||
<div className="trace-explorer-table-view">
|
<div className="trace-explorer-table-view">
|
||||||
<TableView setWarning={setWarning} />
|
<TableView
|
||||||
|
setWarning={setWarning}
|
||||||
|
setIsLoadingQueries={setIsLoadingQueries}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user