@@ -89,6 +89,7 @@ import {
89
89
DETECTOR_STATE ,
90
90
} from '../../../../server/utils/constants' ;
91
91
import { ENTITY_COLORS } from '../../DetectorResults/utils/constants' ;
92
+ import { useLocation } from 'react-router-dom' ;
92
93
93
94
interface AnomalyDetailsChartProps {
94
95
onDateRangeChange (
@@ -113,12 +114,13 @@ interface AnomalyDetailsChartProps {
113
114
selectedHeatmapCell ?: HeatmapCell ;
114
115
onDatePickerRangeChange ?( startDate : number , endDate : number ) : void ;
115
116
openOutOfRangeCallOut ?: boolean ;
116
- dataSourceId ?: string ;
117
117
}
118
118
119
119
export const AnomalyDetailsChart = React . memo (
120
120
( props : AnomalyDetailsChartProps ) => {
121
121
const dispatch = useDispatch ( ) ;
122
+ const location = useLocation ( ) ;
123
+ const dataSourceId = new URLSearchParams ( location . search ) . get ( 'dataSourceId' ) || '' ;
122
124
const [ showAlertsFlyout , setShowAlertsFlyout ] = useState < boolean > ( false ) ;
123
125
const [ alertAnnotations , setAlertAnnotations ] = useState < any [ ] > ( [ ] ) ;
124
126
const [ isLoadingAlerts , setIsLoadingAlerts ] = useState < boolean > ( false ) ;
@@ -175,7 +177,7 @@ export const AnomalyDetailsChart = React.memo(
175
177
zoomRange . endDate ,
176
178
taskId
177
179
) ;
178
- dispatch ( searchResults ( anomalyDataRangeQuery , resultIndex , props . dataSourceId , true ) )
180
+ dispatch ( searchResults ( anomalyDataRangeQuery , resultIndex , dataSourceId , true ) )
179
181
. then ( ( response : any ) => {
180
182
// Only retrieve buckets that are in the anomaly results range. This is so
181
183
// we don't show aggregate results for where there is no data at all
@@ -194,7 +196,7 @@ export const AnomalyDetailsChart = React.memo(
194
196
taskId ,
195
197
selectedAggId
196
198
) ;
197
- dispatch ( searchResults ( historicalAggQuery , resultIndex , props . dataSourceId , true ) )
199
+ dispatch ( searchResults ( historicalAggQuery , resultIndex , dataSourceId , true ) )
198
200
. then ( ( response : any ) => {
199
201
const aggregatedAnomalies = parseHistoricalAggregatedAnomalies (
200
202
response ,
@@ -230,7 +232,7 @@ export const AnomalyDetailsChart = React.memo(
230
232
zoomRange . endDate ,
231
233
taskId
232
234
) ;
233
- dispatch ( searchResults ( anomalyDataRangeQuery , resultIndex , props . dataSourceId , true ) )
235
+ dispatch ( searchResults ( anomalyDataRangeQuery , resultIndex , dataSourceId , true ) )
234
236
. then ( ( response : any ) => {
235
237
const dataStartDate = get (
236
238
response ,
0 commit comments