@@ -134,16 +134,23 @@ function AddAnomalyDetector({
134
134
> ( ) ;
135
135
136
136
const indexPatternId = embeddable . vis . data . aggs . indexPattern . id ;
137
- const [ dataSourceId , setDataSourceId ] = useState < string | undefined > ( undefined ) ;
137
+ const [ dataSourceId , setDataSourceId ] = useState < string | undefined > (
138
+ undefined
139
+ ) ;
138
140
139
141
async function getDataSourceId ( ) {
140
142
try {
141
- const indexPattern = await getSavedObjectsClient ( ) . get ( 'index-pattern' , indexPatternId ) ;
143
+ const indexPattern = await getSavedObjectsClient ( ) . get (
144
+ 'index-pattern' ,
145
+ indexPatternId
146
+ ) ;
142
147
const refs = indexPattern . references as References [ ] ;
143
- const foundDataSourceId = refs . find ( ref => ref . type === 'data-source' ) ?. id ;
144
- setDataSourceId ( foundDataSourceId ) ;
148
+ const foundDataSourceId = refs . find (
149
+ ( ref ) => ref . type === 'data-source'
150
+ ) ?. id ;
151
+ setDataSourceId ( foundDataSourceId ) ;
145
152
} catch ( error ) {
146
- console . error ( " Error fetching index pattern:" , error ) ;
153
+ console . error ( ' Error fetching index pattern:' , error ) ;
147
154
}
148
155
}
149
156
@@ -152,8 +159,12 @@ function AddAnomalyDetector({
152
159
async function fetchData ( ) {
153
160
await getDataSourceId ( ) ;
154
161
155
- const getIndicesDispatchCall = dispatch ( getIndices ( queryText , dataSourceId ) ) ;
156
- const getMappingDispatchCall = dispatch ( getMappings ( embeddable . vis . data . aggs . indexPattern . title , dataSourceId ) ) ;
162
+ const getIndicesDispatchCall = dispatch (
163
+ getIndices ( queryText , dataSourceId )
164
+ ) ;
165
+ const getMappingDispatchCall = dispatch (
166
+ getMappings ( [ embeddable . vis . data . aggs . indexPattern . title ] , dataSourceId )
167
+ ) ;
157
168
await Promise . all ( [ getIndicesDispatchCall , getMappingDispatchCall ] ) ;
158
169
}
159
170
@@ -167,7 +178,7 @@ function AddAnomalyDetector({
167
178
}
168
179
fetchData ( ) ;
169
180
createEmbeddable ( ) ;
170
- } , [ dataSourceId ] ) ;
181
+ } , [ dataSourceId ] ) ;
171
182
172
183
const [ isShowVis , setIsShowVis ] = useState ( false ) ;
173
184
const [ accordionsOpen , setAccordionsOpen ] = useState ( { modelFeatures : true } ) ;
@@ -335,7 +346,7 @@ function AddAnomalyDetector({
335
346
name : OVERLAY_ANOMALIES ,
336
347
args : {
337
348
detectorId : detectorId ,
338
- dataSourceId : dataSourceId
349
+ dataSourceId : dataSourceId ,
339
350
} ,
340
351
} as VisLayerExpressionFn ;
341
352
0 commit comments