Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/hooks/useQueryResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { getQueryResultWithHeaders, getQueryResult } from '@/api/query';
import { LogsQuery } from '@/@types/parseable/api/query';
import { notifications } from '@mantine/notifications';
import { isAxiosError, AxiosError } from 'axios';
import { IconCheck, IconFileAlert } from '@tabler/icons-react';
import { IconCheck } from '@tabler/icons-react';
import { useMutation, useQuery } from 'react-query';
import { logsStoreReducers, useLogsStore } from '@/pages/Stream/providers/LogsProvider';
import _ from 'lodash';
import { useAppStore } from '@/layouts/MainLayout/providers/AppProvider';
import { notifyError } from '@/utils/notification';

type QueryData = {
logsQuery: LogsQuery;
Expand All @@ -26,14 +27,10 @@ export const useQueryResult = () => {
const fetchQueryMutation = useMutation(fetchQueryHandler, {
onError: (data: AxiosError) => {
if (isAxiosError(data) && data.response) {
notifications.update({
id: 'load-data',
color: 'red',
title: 'Error occurred',
message: 'Error occurred, please check your query and try again',
icon: <IconFileAlert size="1rem" />,
autoClose: 2000,
});
const error = data.response?.data as string;
typeof error === 'string' && notifyError({ message: error });
} else if (data.message && typeof data.message === 'string') {
notifyError({ message: data.message });
}
},
onSuccess: (_data, variables) => {
Expand Down
8 changes: 5 additions & 3 deletions src/pages/Stream/components/EventTimeLineGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,13 @@ const generateCountQuery = (
return `SELECT DATE_BIN('${range}', p_timestamp, '${startTime.toISOString()}') AS date_bin_timestamp, COUNT(*) AS log_count FROM ${streamName} WHERE p_timestamp BETWEEN '${startTime.toISOString()}' AND '${endTime.toISOString()}' AND ${whereClause} GROUP BY date_bin_timestamp ORDER BY date_bin_timestamp`;
};

const NoDataView = () => {
const NoDataView = (props: { isError: boolean }) => {
return (
<Stack style={{ width: '100%', height: '100%', alignItems: 'center', justifyContent: 'center' }}>
<Stack className={classes.noDataContainer}>
<Text className={classes.noDataText}>No new events in the selected time range.</Text>
<Text className={classes.noDataText}>
{props.isError ? 'Failed to fetch data' : ' No new events in the selected time range.'}
</Text>
</Stack>
</Stack>
);
Expand Down Expand Up @@ -329,7 +331,7 @@ const EventTimeLineGraph = () => {
dotProps={{ strokeWidth: 1, r: 2.5 }}
/>
) : (
<NoDataView />
<NoDataView isError={fetchQueryMutation.isError}/>
)}
</Skeleton>
</Stack>
Expand Down