-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Visualizations] Pass 'aggs' parameter to custom request handlers #71423
Changes from 1 commit
17448ee
14e7d66
af3164e
68c81a6
86302a7
3c38e0b
3f251b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ import { get } from 'lodash'; | |
import { i18n } from '@kbn/i18n'; | ||
import { VisResponseValue, PersistedState } from '../../../../plugins/visualizations/public'; | ||
import { ExpressionFunctionDefinition, Render } from '../../../../plugins/expressions/public'; | ||
import { getTypes, getIndexPatterns, getFilterManager } from '../services'; | ||
import { getTypes, getIndexPatterns, getFilterManager, getSearch } from '../services'; | ||
|
||
interface Arguments { | ||
index?: string | null; | ||
|
@@ -31,6 +31,7 @@ interface Arguments { | |
schemas?: string; | ||
visConfig?: string; | ||
uiState?: string; | ||
aggConfigs?: string; | ||
} | ||
|
||
export type ExpressionFunctionVisualization = ExpressionFunctionDefinition< | ||
|
@@ -84,6 +85,11 @@ export const visualization = (): ExpressionFunctionVisualization => ({ | |
default: '"{}"', | ||
help: 'User interface state', | ||
}, | ||
aggConfigs: { | ||
types: ['string'], | ||
default: '"{}"', | ||
help: 'Aggregation configurations', | ||
}, | ||
}, | ||
async fn(input, args, { inspectorAdapters }) { | ||
const visConfigParams = args.visConfig ? JSON.parse(args.visConfig) : {}; | ||
|
@@ -94,6 +100,9 @@ export const visualization = (): ExpressionFunctionVisualization => ({ | |
const uiStateParams = args.uiState ? JSON.parse(args.uiState) : {}; | ||
const uiState = new PersistedState(uiStateParams); | ||
|
||
const aggConfigsState = args.aggConfigs ? JSON.parse(args.aggConfigs) : {}; | ||
const aggConfigs = indexPattern ? getSearch().aggs.createAggConfigs(indexPattern, aggConfigsState) : null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than setting to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I guess that's what I'm proposing. Basically so that the argument to the request handler is I don't feel strongly about this though. In the end it won't make a huge difference since the request handler will likely check |
||
|
||
if (typeof visType.requestHandler === 'function') { | ||
input = await visType.requestHandler({ | ||
partialRows: args.partialRows, | ||
|
@@ -107,6 +116,7 @@ export const visualization = (): ExpressionFunctionVisualization => ({ | |
inspectorAdapters, | ||
queryFilter: getFilterManager(), | ||
forceFetch: true, | ||
aggConfigs, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we call this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, I'll do that. |
||
}); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you want
{}
as a fallback here...createAggConfigs
expects an array of serialized agg configs as theaggConfigsState
:So you can probably either fall back to
[]
, or toundefined
(in which casecreateAggConfigs
will default to[]
anyway).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I'll put
[]
here.Unless you prefer
undefined
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes no difference IMHO. Inside
createAggConfigs
it will be[]
either way