Skip to content

Commit 404c226

Browse files
jackiehanyanggithub-actions[bot]
authored andcommitted
mds bug fixes (#915)
Signed-off-by: Jackie Han <jkhanjob@gmail.com> (cherry picked from commit d8f7380)
1 parent f388b4b commit 404c226

File tree

5 files changed

+41
-30
lines changed

5 files changed

+41
-30
lines changed

public/pages/Dashboard/Container/DashboardOverview.tsx

+11-8
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,18 @@ export function DashboardOverview(props: OverviewProps) {
207207
};
208208

209209
const intializeDetectors = async () => {
210-
dispatch(
211-
getDetectorList(
212-
getAllDetectorsQueryParamsWithDataSourceId(
213-
MDSOverviewState.selectedDataSourceId
210+
// wait until selected data source is ready before doing dispatch calls if mds is enabled
211+
if (!dataSourceEnabled || (MDSOverviewState.selectedDataSourceId && MDSOverviewState.selectedDataSourceId !== "")) {
212+
dispatch(
213+
getDetectorList(
214+
getAllDetectorsQueryParamsWithDataSourceId(
215+
MDSOverviewState.selectedDataSourceId
216+
)
214217
)
215-
)
216-
);
217-
dispatch(getIndices('', MDSOverviewState.selectedDataSourceId));
218-
dispatch(getAliases('', MDSOverviewState.selectedDataSourceId));
218+
);
219+
dispatch(getIndices('', MDSOverviewState.selectedDataSourceId));
220+
dispatch(getAliases('', MDSOverviewState.selectedDataSourceId));
221+
}
219222
};
220223

221224
useEffect(() => {

public/pages/DetectorsList/containers/List/List.tsx

+8-5
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,14 @@ export const DetectorList = (props: ListProps) => {
330330
}, [confirmModalState.isRequestingToClose, isLoading]);
331331

332332
const getUpdatedDetectors = async () => {
333-
dispatch(
334-
getDetectorList(
335-
getAllDetectorsQueryParamsWithDataSourceId(state.selectedDataSourceId)
336-
)
337-
);
333+
// wait until selected data source is ready before doing dispatch calls if mds is enabled
334+
if (!dataSourceEnabled || (state.selectedDataSourceId && state.selectedDataSourceId !== "")) {
335+
dispatch(
336+
getDetectorList(
337+
getAllDetectorsQueryParamsWithDataSourceId(state.selectedDataSourceId)
338+
)
339+
);
340+
}
338341
};
339342

340343
const handlePageChange = (pageNumber: number) => {

public/pages/Overview/containers/AnomalyDetectionOverview.tsx

+18-15
Original file line numberDiff line numberDiff line change
@@ -155,23 +155,26 @@ export function AnomalyDetectionOverview(props: AnomalyDetectionOverviewProps) {
155155

156156
// fetch smaple detectors and sample indices
157157
const fetchData = async () => {
158-
await dispatch(
159-
getDetectorList(
160-
getSampleDetectorsQueryParamsWithDataSouceId(
158+
// wait until selected data source is ready before doing dispatch calls if mds is enabled
159+
if (!dataSourceEnabled || (MDSOverviewState.selectedDataSourceId && MDSOverviewState.selectedDataSourceId !== "")) {
160+
await dispatch(
161+
getDetectorList(
162+
getSampleDetectorsQueryParamsWithDataSouceId(
163+
MDSOverviewState.selectedDataSourceId
164+
)
165+
)
166+
).catch((error: any) => {
167+
console.error('Error getting sample detectors: ', error);
168+
});
169+
await dispatch(
170+
getIndices(
171+
GET_SAMPLE_INDICES_QUERY,
161172
MDSOverviewState.selectedDataSourceId
162173
)
163-
)
164-
).catch((error: any) => {
165-
console.error('Error getting sample detectors: ', error);
166-
});
167-
await dispatch(
168-
getIndices(
169-
GET_SAMPLE_INDICES_QUERY,
170-
MDSOverviewState.selectedDataSourceId
171-
)
172-
).catch((error: any) => {
173-
console.error('Error getting sample indices: ', error);
174-
});
174+
).catch((error: any) => {
175+
console.error('Error getting sample indices: ', error);
176+
});
177+
}
175178
};
176179

177180
// Create and populate sample index, create and start sample detector

public/redux/reducers/ad.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ export const getDetector = (
419419
export const getDetectorList = (
420420
queryParams: GetDetectorsQueryParams
421421
): APIAction => {
422-
const dataSourceId = queryParams.dataSourceId || '';
422+
const dataSourceId = queryParams.dataSourceId;
423423

424424
const baseUrl = `${AD_NODE_API.DETECTOR}/_list`;
425425
const url = dataSourceId

public/redux/reducers/previewAnomalies.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ const reducer = handleActions<PreviewAnomalies>(
5959
initialDetectorsState
6060
);
6161

62-
export const previewDetector = (requestBody: any, dataSourceId: string = ''): APIAction => {
62+
export const previewDetector = (requestBody: any): APIAction => {
63+
const dataSourceId = requestBody.dataSourceId;
64+
6365
const baseUrl = `..${AD_NODE_API.DETECTOR}/preview`;
6466
const url = dataSourceId ? `${baseUrl}/${dataSourceId}` : baseUrl;
6567

0 commit comments

Comments
 (0)