-
Notifications
You must be signed in to change notification settings - Fork 1k
/
bindings.jsx
365 lines (350 loc) · 14.5 KB
/
bindings.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
// @flow strict
import React from 'react';
import Routes from 'routing/Routes';
import * as Permissions from 'views/Permissions';
import { get } from 'lodash';
import { MessageListHandler } from 'views/logic/searchtypes';
import { MessageList } from 'views/components/widgets';
import AddToTableActionHandler from 'views/logic/fieldactions/AddToTableActionHandler';
import AddToAllTablesActionHandler from 'views/logic/fieldactions/AddToAllTablesActionHandler';
import AddToQueryHandler from 'views/logic/valueactions/AddToQueryHandler';
import AggregateActionHandler from 'views/logic/fieldactions/AggregateActionHandler';
import ChartActionHandler from 'views/logic/fieldactions/ChartActionHandler';
import AggregationBuilder from 'views/components/aggregationbuilder/AggregationBuilder';
import BarVisualization from 'views/components/visualizations/bar/BarVisualization';
import LineVisualization from 'views/components/visualizations/line/LineVisualization';
import NumberVisualization from 'views/components/visualizations/number/NumberVisualization';
import PieVisualization from 'views/components/visualizations/pie/PieVisualization';
import ScatterVisualization from 'views/components/visualizations/scatter/ScatterVisualization';
import WorldMapVisualization from 'views/components/visualizations/worldmap/WorldMapVisualization';
import HeatmapVisualization from 'views/components/visualizations/heatmap/HeatmapVisualization';
import MigrateFieldCharts from 'views/components/MigrateFieldCharts';
import IfSearch from 'views/components/search/IfSearch';
import PivotConfigGenerator from 'views/logic/searchtypes/aggregation/PivotConfigGenerator';
import PivotHandler from 'views/logic/searchtypes/pivot/PivotHandler';
import PivotTransformer from 'views/logic/searchresulttransformers/PivotTransformer';
import EventHandler from 'views/logic/searchtypes/events/EventHandler';
import Widget from 'views/logic/widgets/Widget';
import AggregationWidget from 'views/logic/aggregationbuilder/AggregationWidget';
import MessagesWidget from 'views/logic/widgets/MessagesWidget';
import DataTable from 'views/components/datatable/DataTable';
import FieldStatisticsHandler from 'views/logic/fieldactions/FieldStatisticsHandler';
import ExcludeFromQueryHandler from 'views/logic/valueactions/ExcludeFromQueryHandler';
import { isFunction } from 'views/logic/aggregationbuilder/Series';
import AggregationControls from 'views/components/aggregationbuilder/AggregationControls';
import EditMessageList from 'views/components/widgets/EditMessageList';
import { DashboardsPage, ShowViewPage, NewSearchPage, ViewManagementPage, NewDashboardPage, StreamSearchPage } from 'views/pages';
import AppWithExtendedSearchBar from 'routing/AppWithExtendedSearchBar';
import AddMessageCountActionHandler from 'views/logic/fieldactions/AddMessageCountActionHandler';
import AddMessageTableActionHandler from 'views/logic/fieldactions/AddMessageTableActionHandler';
import RemoveFromTableActionHandler from 'views/logic/fieldactions/RemoveFromTableActionHandler';
import RemoveFromAllTablesActionHandler from 'views/logic/fieldactions/RemoveFromAllTablesActionHandler';
import CreateCustomAggregation from 'views/logic/creatoractions/CreateCustomAggregation';
import SelectExtractorType from 'views/logic/valueactions/SelectExtractorType';
import VisualizationConfig from 'views/logic/aggregationbuilder/visualizations/VisualizationConfig';
import WorldMapVisualizationConfig from 'views/logic/aggregationbuilder/visualizations/WorldMapVisualizationConfig';
import BarVisualizationConfig from 'views/logic/aggregationbuilder/visualizations/BarVisualizationConfig';
import ViewSharing from 'views/logic/views/sharing/ViewSharing';
import AllUsersOfInstance from 'views/logic/views/sharing/AllUsersOfInstance';
import SpecificRoles from 'views/logic/views/sharing/SpecificRoles';
import SpecificUsers from 'views/logic/views/sharing/SpecificUsers';
import ShowDocumentsHandler from 'views/logic/valueactions/ShowDocumentsHandler';
import HighlightValueHandler from 'views/logic/valueactions/HighlightValueHandler';
import FieldNameCompletion from 'views/components/searchbar/completions/FieldNameCompletion';
import OperatorCompletion from 'views/components/searchbar/completions/OperatorCompletion';
import requirementsProvided from 'views/hooks/RequirementsProvided';
import bindSearchParamsFromQuery from 'views/hooks/BindSearchParamsFromQuery';
import {
dashboardsPath, dashboardsTvPath,
extendedSearchPath,
newDashboardsPath,
showDashboardsPath,
showViewsPath,
showSearchPath,
viewsPath,
} from 'views/Constants';
import ShowDashboardInBigDisplayMode from 'views/pages/ShowDashboardInBigDisplayMode';
import LookupTableParameter from 'views/logic/parameters/LookupTableParameter';
import type { ActionHandlerArguments, ActionHandlerCondition } from './components/actions/ActionHandler';
import NumberVisualizationConfig from './logic/aggregationbuilder/visualizations/NumberVisualizationConfig';
import BarVisualizationConfiguration from './components/aggregationbuilder/BarVisualizationConfiguration';
import NumberVisualizationConfiguration from './components/aggregationbuilder/NumberVisualizationConfiguration';
import AreaVisualization from './components/visualizations/area/AreaVisualization';
import LineVisualizationConfig from './logic/aggregationbuilder/visualizations/LineVisualizationConfig';
import AreaVisualizationConfig from './logic/aggregationbuilder/visualizations/AreaVisualizationConfig';
import LineVisualizationConfiguration from './components/aggregationbuilder/LineVisualizationConfiguration';
import AreaVisualizationConfiguration from './components/aggregationbuilder/AreaVisualizationConfiguration';
import Parameter from './logic/parameters/Parameter';
import ValueParameter from './logic/parameters/ValueParameter';
import MessageConfigGenerator from './logic/searchtypes/MessageConfigGenerator';
import UnknownWidget from './components/widgets/UnknownWidget';
Widget.registerSubtype(AggregationWidget.type, AggregationWidget);
Widget.registerSubtype(MessagesWidget.type, MessagesWidget);
// $FlowFixMe: type is not undefined in this case.
VisualizationConfig.registerSubtype(WorldMapVisualization.type, WorldMapVisualizationConfig);
// $FlowFixMe: type is not undefined in this case.
VisualizationConfig.registerSubtype(BarVisualization.type, BarVisualizationConfig);
VisualizationConfig.registerSubtype(NumberVisualization.type, NumberVisualizationConfig);
// $FlowFixMe: type is not undefined in this case.
VisualizationConfig.registerSubtype(LineVisualization.type, LineVisualizationConfig);
// $FlowFixMe: type is not undefined in this case.
VisualizationConfig.registerSubtype(AreaVisualization.type, AreaVisualizationConfig);
ViewSharing.registerSubtype(AllUsersOfInstance.Type, AllUsersOfInstance);
ViewSharing.registerSubtype(SpecificRoles.Type, SpecificRoles);
ViewSharing.registerSubtype(SpecificUsers.Type, SpecificUsers);
Parameter.registerSubtype(ValueParameter.type, ValueParameter);
Parameter.registerSubtype(LookupTableParameter.type, LookupTableParameter);
export default {
pages: {
search: { component: NewSearchPage },
},
routes: [
{ path: newDashboardsPath, component: NewDashboardPage, parentComponent: AppWithExtendedSearchBar },
{ path: showSearchPath, component: ShowViewPage, parentComponent: AppWithExtendedSearchBar },
{ path: dashboardsTvPath, component: ShowDashboardInBigDisplayMode, parentComponent: null },
{ path: Routes.stream_search(':streamId'), component: StreamSearchPage, parentComponent: AppWithExtendedSearchBar },
{ path: dashboardsPath, component: DashboardsPage },
{ path: showDashboardsPath, component: ShowViewPage, parentComponent: AppWithExtendedSearchBar },
{ path: extendedSearchPath, component: NewSearchPage, permissions: Permissions.ExtendedSearch.Use },
{ path: viewsPath, component: ViewManagementPage, permissions: Permissions.View.Use },
{ path: showViewsPath, component: ShowViewPage, parentComponent: AppWithExtendedSearchBar },
],
enterpriseWidgets: [
{
type: 'MESSAGES',
displayName: 'Message List',
defaultHeight: 5,
defaultWidth: 6,
visualizationComponent: MessageList,
editComponent: EditMessageList,
needsControlledHeight: () => false,
searchResultTransformer: (data: Array<*>) => data[0],
searchTypes: MessageConfigGenerator,
titleGenerator: () => 'Untitled Message Table',
},
{
type: 'AGGREGATION',
displayName: 'Results',
defaultHeight: 4,
defaultWidth: 4,
visualizationComponent: AggregationBuilder,
editComponent: AggregationControls,
needsControlledHeight: (widget: Widget) => {
const widgetVisualization = get(widget, 'config.visualization');
const flexibleHeightWidgets = [
DataTable.type,
];
return !flexibleHeightWidgets.find(visualization => visualization === widgetVisualization);
},
searchResultTransformer: PivotTransformer,
searchTypes: PivotConfigGenerator,
titleGenerator: (widget: Widget) => {
if (widget.config.rowPivots.length > 0) {
return `Aggregating ${widget.config.series.map(s => s.effectiveName).join(', ')} by ${widget.config.rowPivots.map(({ field }) => field).join(', ')}`;
}
if (widget.config.series.length > 0) {
return `Aggregating ${widget.config.series.map(s => s.effectiveName).join(', ')}`;
}
return 'Untitled Aggregation';
},
},
{
type: 'default',
visualizationComponent: UnknownWidget,
needsControlledHeight: () => true,
editComponent: UnknownWidget,
searchTypes: () => [],
},
],
searchTypes: [
{
type: 'messages',
handler: MessageListHandler,
defaults: {
limit: 150,
offset: 0,
},
},
{
type: 'pivot',
handler: PivotHandler,
defaults: {},
},
{
type: 'events',
handler: EventHandler,
defaults: {},
},
],
fieldActions: [
{
type: 'chart',
title: 'Chart',
handler: ChartActionHandler,
isEnabled: (({ type }) => type.isNumeric(): ActionHandlerCondition),
},
{
type: 'aggregate',
title: 'Aggregate',
handler: AggregateActionHandler,
isEnabled: (({ field, type }) => (!isFunction(field) && !type.isCompound() && !type.isDecorated()): ActionHandlerCondition),
},
{
type: 'statistics',
title: 'Statistics',
isEnabled: (({ field, type }) => (!isFunction(field) && !type.isDecorated()): ActionHandlerCondition),
handler: FieldStatisticsHandler,
},
{
type: 'add-to-table',
title: 'Add to table',
handler: AddToTableActionHandler,
isEnabled: AddToTableActionHandler.isEnabled,
isHidden: AddToTableActionHandler.isHidden,
},
{
type: 'remove-from-table',
title: 'Remove from table',
handler: RemoveFromTableActionHandler,
isEnabled: RemoveFromTableActionHandler.isEnabled,
isHidden: RemoveFromTableActionHandler.isHidden,
},
{
type: 'add-to-all-tables',
title: 'Add to all tables',
handler: AddToAllTablesActionHandler,
isEnabled: (({ field, type }) => (!isFunction(field) && !type.isDecorated()): ActionHandlerCondition),
},
{
type: 'remove-from-all-tables',
title: 'Remove from all tables',
handler: RemoveFromAllTablesActionHandler,
isEnabled: (({ field, type }) => (!isFunction(field) && !type.isDecorated()): ActionHandlerCondition),
},
],
valueActions: [
{
type: 'exclude',
title: 'Exclude from results',
handler: new ExcludeFromQueryHandler().handle,
isEnabled: ({ field, type }: ActionHandlerArguments) => (!isFunction(field) && !type.isDecorated()),
},
{
type: 'add-to-query',
title: 'Add to query',
handler: new AddToQueryHandler().handle,
isEnabled: ({ field, type }: ActionHandlerArguments) => (!isFunction(field) && !type.isDecorated()),
},
{
type: 'show-bucket',
title: 'Show documents for value',
handler: ShowDocumentsHandler,
isEnabled: ShowDocumentsHandler.isEnabled,
},
{
type: 'create-extractor',
title: 'Create extractor',
isEnabled: (({ type, contexts }) => (!!contexts.message && !type.isDecorated()): ActionHandlerCondition),
component: SelectExtractorType,
},
{
type: 'highlight-value',
title: 'Highlight this value',
handler: HighlightValueHandler,
isEnabled: HighlightValueHandler.isEnabled,
},
],
visualizationTypes: [
{
type: AreaVisualization.type,
displayName: 'Area Chart',
component: AreaVisualization,
},
{
type: BarVisualization.type,
displayName: 'Bar Chart',
component: BarVisualization,
},
{
type: LineVisualization.type,
displayName: 'Line Chart',
component: LineVisualization,
},
{
type: WorldMapVisualization.type,
displayName: 'World Map',
component: WorldMapVisualization,
},
{
type: PieVisualization.type,
displayName: 'Pie Chart',
component: PieVisualization,
},
{
type: DataTable.type,
displayName: 'Data Table',
component: DataTable,
},
{
type: NumberVisualization.type,
displayName: 'Single Number',
component: NumberVisualization,
},
{
type: ScatterVisualization.type,
displayName: 'Scatter Plot',
component: ScatterVisualization,
},
{
type: HeatmapVisualization.type,
displayName: 'Heatmap',
component: HeatmapVisualization,
},
],
visualizationConfigTypes: [
{
type: AreaVisualization.type,
component: AreaVisualizationConfiguration,
},
{
type: BarVisualization.type,
component: BarVisualizationConfiguration,
},
{
type: LineVisualization.type,
component: LineVisualizationConfiguration,
},
{
type: NumberVisualization.type,
component: NumberVisualizationConfiguration,
},
],
creators: [
{
type: 'preset',
title: 'Message Count',
func: AddMessageCountActionHandler,
},
{
type: 'preset',
title: 'Message Table',
func: AddMessageTableActionHandler,
},
{
type: 'generic',
title: 'Aggregation',
func: CreateCustomAggregation,
},
],
'views.completers': [
new FieldNameCompletion(),
new OperatorCompletion(),
],
'views.hooks.loadingView': [
requirementsProvided,
bindSearchParamsFromQuery,
],
'views.elements.header': [
() => <IfSearch><MigrateFieldCharts /></IfSearch>,
],
};