Skip to content

Commit

Permalink
mds bug fixes (#915)
Browse files Browse the repository at this point in the history
Signed-off-by: Jackie Han <[email protected]>
  • Loading branch information
jackiehanyang authored Oct 25, 2024
1 parent 47e6a15 commit d8f7380
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 30 deletions.
19 changes: 11 additions & 8 deletions public/pages/Dashboard/Container/DashboardOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
13 changes: 8 additions & 5 deletions public/pages/DetectorsList/containers/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
33 changes: 18 additions & 15 deletions public/pages/Overview/containers/AnomalyDetectionOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion public/redux/reducers/ad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion public/redux/reducers/previewAnomalies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ const reducer = handleActions<PreviewAnomalies>(
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;

Expand Down

0 comments on commit d8f7380

Please sign in to comment.