diff --git a/public/pages/Dashboard/Container/DashboardOverview.tsx b/public/pages/Dashboard/Container/DashboardOverview.tsx index 66d2da08..13c6d70e 100644 --- a/public/pages/Dashboard/Container/DashboardOverview.tsx +++ b/public/pages/Dashboard/Container/DashboardOverview.tsx @@ -207,15 +207,18 @@ export function DashboardOverview(props: OverviewProps) { }; const intializeDetectors = async () => { - dispatch( - getDetectorList( - getAllDetectorsQueryParamsWithDataSourceId( - MDSOverviewState.selectedDataSourceId + // wait until selected data source is ready before doing dispatch calls if mds is enabled + if (!dataSourceEnabled || (MDSOverviewState.selectedDataSourceId && MDSOverviewState.selectedDataSourceId !== "")) { + dispatch( + getDetectorList( + getAllDetectorsQueryParamsWithDataSourceId( + MDSOverviewState.selectedDataSourceId + ) ) - ) - ); - dispatch(getIndices('', MDSOverviewState.selectedDataSourceId)); - dispatch(getAliases('', MDSOverviewState.selectedDataSourceId)); + ); + dispatch(getIndices('', MDSOverviewState.selectedDataSourceId)); + dispatch(getAliases('', MDSOverviewState.selectedDataSourceId)); + } }; useEffect(() => { diff --git a/public/pages/DetectorsList/containers/List/List.tsx b/public/pages/DetectorsList/containers/List/List.tsx index 2db748bc..09b31ae4 100644 --- a/public/pages/DetectorsList/containers/List/List.tsx +++ b/public/pages/DetectorsList/containers/List/List.tsx @@ -330,11 +330,14 @@ export const DetectorList = (props: ListProps) => { }, [confirmModalState.isRequestingToClose, isLoading]); const getUpdatedDetectors = async () => { - dispatch( - getDetectorList( - getAllDetectorsQueryParamsWithDataSourceId(state.selectedDataSourceId) - ) - ); + // wait until selected data source is ready before doing dispatch calls if mds is enabled + if (!dataSourceEnabled || (state.selectedDataSourceId && state.selectedDataSourceId !== "")) { + dispatch( + getDetectorList( + getAllDetectorsQueryParamsWithDataSourceId(state.selectedDataSourceId) + ) + ); + } }; const handlePageChange = (pageNumber: number) => { diff --git a/public/pages/Overview/containers/AnomalyDetectionOverview.tsx b/public/pages/Overview/containers/AnomalyDetectionOverview.tsx index 04b7c52c..4a02aa5e 100644 --- a/public/pages/Overview/containers/AnomalyDetectionOverview.tsx +++ b/public/pages/Overview/containers/AnomalyDetectionOverview.tsx @@ -155,23 +155,26 @@ export function AnomalyDetectionOverview(props: AnomalyDetectionOverviewProps) { // fetch smaple detectors and sample indices const fetchData = async () => { - await dispatch( - getDetectorList( - getSampleDetectorsQueryParamsWithDataSouceId( + // wait until selected data source is ready before doing dispatch calls if mds is enabled + if (!dataSourceEnabled || (MDSOverviewState.selectedDataSourceId && MDSOverviewState.selectedDataSourceId !== "")) { + await dispatch( + getDetectorList( + getSampleDetectorsQueryParamsWithDataSouceId( + MDSOverviewState.selectedDataSourceId + ) + ) + ).catch((error: any) => { + console.error('Error getting sample detectors: ', error); + }); + await dispatch( + getIndices( + GET_SAMPLE_INDICES_QUERY, MDSOverviewState.selectedDataSourceId ) - ) - ).catch((error: any) => { - console.error('Error getting sample detectors: ', error); - }); - await dispatch( - getIndices( - GET_SAMPLE_INDICES_QUERY, - MDSOverviewState.selectedDataSourceId - ) - ).catch((error: any) => { - console.error('Error getting sample indices: ', error); - }); + ).catch((error: any) => { + console.error('Error getting sample indices: ', error); + }); + } }; // Create and populate sample index, create and start sample detector diff --git a/public/redux/reducers/ad.ts b/public/redux/reducers/ad.ts index 9d456912..ce382ed7 100644 --- a/public/redux/reducers/ad.ts +++ b/public/redux/reducers/ad.ts @@ -419,7 +419,7 @@ export const getDetector = ( export const getDetectorList = ( queryParams: GetDetectorsQueryParams ): APIAction => { - const dataSourceId = queryParams.dataSourceId || ''; + const dataSourceId = queryParams.dataSourceId; const baseUrl = `${AD_NODE_API.DETECTOR}/_list`; const url = dataSourceId diff --git a/public/redux/reducers/previewAnomalies.ts b/public/redux/reducers/previewAnomalies.ts index 01e36f29..45ea558a 100644 --- a/public/redux/reducers/previewAnomalies.ts +++ b/public/redux/reducers/previewAnomalies.ts @@ -59,7 +59,9 @@ const reducer = handleActions( initialDetectorsState ); -export const previewDetector = (requestBody: any, dataSourceId: string = ''): APIAction => { +export const previewDetector = (requestBody: any): APIAction => { + const dataSourceId = requestBody.dataSourceId; + const baseUrl = `..${AD_NODE_API.DETECTOR}/preview`; const url = dataSourceId ? `${baseUrl}/${dataSourceId}` : baseUrl;