diff --git a/src/hooks/useQueryResult.tsx b/src/hooks/useQueryResult.tsx index 92354e56..81b05604 100644 --- a/src/hooks/useQueryResult.tsx +++ b/src/hooks/useQueryResult.tsx @@ -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; @@ -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: , - 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) => { diff --git a/src/pages/Stream/components/EventTimeLineGraph.tsx b/src/pages/Stream/components/EventTimeLineGraph.tsx index 0ab33921..7a61600f 100644 --- a/src/pages/Stream/components/EventTimeLineGraph.tsx +++ b/src/pages/Stream/components/EventTimeLineGraph.tsx @@ -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 ( - No new events in the selected time range. + + {props.isError ? 'Failed to fetch data' : ' No new events in the selected time range.'} + ); @@ -329,7 +331,7 @@ const EventTimeLineGraph = () => { dotProps={{ strokeWidth: 1, r: 2.5 }} /> ) : ( - + )}