Skip to content
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

Filter editors #11375

Merged
merged 105 commits into from
Jun 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
62a9188
Add terms filter
lukasolson Mar 8, 2017
b42732b
First stab at inline filter editors
lukasolson Apr 19, 2017
d0c83dd
Merge remote-tracking branch 'upstream/master' into filter-editors
lukasolson Apr 20, 2017
adb8b57
Cleanup
lukasolson Apr 20, 2017
dbcbf23
Move endpoint to server
lukasolson Apr 20, 2017
c6ebede
Merge branch 'master' into filter-editors
lukasolson Apr 21, 2017
74fd6aa
Add delete button to filter editor
lukasolson Apr 21, 2017
4c8af2b
Add sort prefix first utility
lukasolson Apr 21, 2017
cfdb4c2
Sort ui-select items by prefix first
lukasolson Apr 21, 2017
b44f423
Add sortPrefixFirst tests
lukasolson Apr 21, 2017
6269933
Merge branch 'master' into filter-editors
lukasolson Apr 21, 2017
f5de43c
Use small text input instead of styles
lukasolson Apr 26, 2017
f883caf
Merge branch 'master' into filter-editors
lukasolson Apr 28, 2017
f1ed5b4
More keyboard-driven filter creation
lukasolson Apr 28, 2017
a8f8d21
Merge branch 'master' into filter-editors
lukasolson May 1, 2017
d4498ee
Merge branch 'master' into filter-editors
lukasolson May 2, 2017
cb7b350
Add custom dsl edit support
lukasolson May 3, 2017
784925c
Add more actions
lukasolson May 3, 2017
cf684ac
Add alias support
lukasolson May 3, 2017
8f4dd11
Simplify label
lukasolson May 3, 2017
942d477
Merge branch 'master' into filter-editors
lukasolson May 8, 2017
35ef626
Allow freeform entries
lukasolson May 8, 2017
3cadcd4
Fix visualize
lukasolson May 8, 2017
5fd9bff
Support for dashboard
lukasolson May 8, 2017
7a9377f
Move styles to less and fix visual issues
lukasolson May 9, 2017
7fca941
Merge branch 'master' into filter-editors
lukasolson May 9, 2017
af7364c
Rename map_match to map_phrase
lukasolson May 10, 2017
32231e0
Detect scripted filters for filter editors
lukasolson May 10, 2017
7e50ce0
Simplify range map
lukasolson May 10, 2017
120c217
Use match_phrase instead of terms
lukasolson May 10, 2017
5987e7b
Fix scripted exists
lukasolson May 10, 2017
f402050
Support scripted phrases
lukasolson May 10, 2017
87aa348
Don't show DSL editor for new filters
lukasolson May 10, 2017
df25b78
Disable save unless valid
lukasolson May 10, 2017
f51626f
Merge branch 'master' into filter-editors
lukasolson May 15, 2017
35edd89
Fix error when searching for numbers
lukasolson May 15, 2017
5af844a
Return correct error and dont suggest values for numbers
lukasolson May 16, 2017
68ba6d8
Only suggest filterable fields
lukasolson May 16, 2017
95e66dc
Clear params on field change
lukasolson May 16, 2017
b78015b
Clear suggestions on field change
lukasolson May 16, 2017
6f5dd66
Cache response
lukasolson May 16, 2017
1f5165f
Preserve selected params
lukasolson May 17, 2017
456e4b3
Fix multiple selection
lukasolson May 17, 2017
fb93283
Don't overflow on multiselect
lukasolson May 18, 2017
32a0e97
Show tooltip on long values
lukasolson May 18, 2017
2a2edec
Use different input for different types
lukasolson May 18, 2017
14d360e
Show all actions again
lukasolson May 18, 2017
4f3dbc8
Move dsl editor to directive
lukasolson May 18, 2017
62f1e32
Update filter query dsl editor
lukasolson May 19, 2017
833ff23
Clean up code
lukasolson May 19, 2017
e7cba21
Move filter field select into own directive
lukasolson May 19, 2017
322175f
Move filter operator select into own directive
lukasolson May 19, 2017
33041cc
Move utils to separate file
lukasolson May 19, 2017
2b62d33
Move field options to field directive
lukasolson May 19, 2017
94502e2
Move operator options to operator directive
lukasolson May 19, 2017
0a9d9a8
Move params under operator type
lukasolson May 19, 2017
410a76b
Move params editor into own directive
lukasolson May 19, 2017
86e0181
Merge branch 'master' into filter-editors
lukasolson May 22, 2017
3ab569f
Move param editors to own directives
lukasolson May 22, 2017
1da04a9
Don't highlight values
lukasolson May 23, 2017
3f831e3
Don't use unnecessary onChange
lukasolson May 23, 2017
42689a9
Use text input if no suggestions
lukasolson May 23, 2017
79ac016
Remove unused updateFilter
lukasolson May 23, 2017
6ee2d9b
Merge branch 'master' into filter-editors
lukasolson May 24, 2017
49ae873
Enhance params editors
lukasolson May 24, 2017
5f45dc4
Update save filter api
lukasolson May 25, 2017
13b9ac8
Update save filter api
lukasolson May 25, 2017
25dbcf7
Fix a couple tests
lukasolson May 26, 2017
4fd6bb4
Merge branch 'master' into filter-editors
lukasolson May 26, 2017
770b3dc
Fix more tests
lukasolson May 26, 2017
1e87b6f
Fix map phrase test
lukasolson May 26, 2017
3eba161
test cleanup
lukasolson May 26, 2017
cd6edba
Merge remote-tracking branch 'upstream/master' into filter-editors
lukasolson May 26, 2017
3ac0ab4
Hide editor on esc key
lukasolson May 26, 2017
a791298
Use first index pattern if none specified
lukasolson May 26, 2017
d54df02
Merge branch 'master' into filter-editors
lukasolson May 30, 2017
a02e12a
FilterEditorUtils test and fix range error
lukasolson May 30, 2017
6ab2910
fix date phrase
lukasolson May 30, 2017
5ecbf3f
Date format should allow date math values
lukasolson May 30, 2017
434e046
Only show add filter button if there are index patterns
lukasolson May 31, 2017
da08291
Look up field from indexPatterns service rather than passed index pat…
lukasolson May 31, 2017
4178ea2
Use basepath instead of relative path
lukasolson May 31, 2017
70e1960
Feedback from bargs
lukasolson May 31, 2017
2c8cf77
Merge branch 'filter-editors' of https://github.com/lukasolson/kibana…
stacey-gammon May 31, 2017
f7ecaf8
Merge branch 'master' into filter-editors
lukasolson May 31, 2017
8f228ab
Don't show filter bar when ya shouldnt
lukasolson May 31, 2017
bc6390f
don't reload panel saved objects
stacey-gammon May 31, 2017
b612cdd
Show date math instead of formatted date
lukasolson May 31, 2017
bc50e25
Merge remote-tracking branch 'stacey/filter-suggestion' into filter-e…
lukasolson May 31, 2017
bc59261
Focus on params even when not ui-select
lukasolson May 31, 2017
ba26a0a
Merge branch 'master' into filter-editors
lukasolson Jun 1, 2017
26db446
Hide editor on delete
lukasolson Jun 1, 2017
148d154
Update styles to BEM format
lukasolson Jun 1, 2017
c2e0ec9
Update styles
lukasolson Jun 1, 2017
fd88d0a
Add more tests
lukasolson Jun 1, 2017
a5ee8a3
Don't show pin/disable
lukasolson Jun 2, 2017
5baab3f
Merge branch 'master' into filter-editors
lukasolson Jun 2, 2017
3173cf4
Fix bug where saving a filter edit without making changes messed up p…
lukasolson Jun 2, 2017
d1a1ebf
Update styles to camelcase
lukasolson Jun 2, 2017
6cbff9f
Fix cutoff from top of screen for ui-select
lukasolson Jun 2, 2017
9aaac8c
Add accessibility
lukasolson Jun 2, 2017
2281298
Align to top
lukasolson Jun 2, 2017
fe0d62f
Align inputs and add placeholders
lukasolson Jun 2, 2017
d30467d
Dynamic input sizing
lukasolson Jun 2, 2017
0759978
Fix dashboard panel test
lukasolson Jun 2, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/core_plugins/kibana/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ingest from './server/routes/api/ingest';
import search from './server/routes/api/search';
import settings from './server/routes/api/settings';
import scripts from './server/routes/api/scripts';
import { registerSuggestionsApi } from './server/routes/api/suggestions';
import * as systemApi from './server/lib/system_api';
import handleEsError from './server/lib/handle_es_error';
import mappings from './mappings.json';
Expand Down Expand Up @@ -127,6 +128,7 @@ module.exports = function (kibana) {
search(server);
settings(server);
scripts(server);
registerSuggestionsApi(server);

server.expose('systemApi', systemApi);
server.expose('handleEsError', handleEsError);
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/kibana/public/context/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>
</div>

<filter-bar></filter-bar>
<filter-bar index-patterns="[contextApp.indexPattern]"></filter-bar>

<!-- Error feedback -->
<div
Expand Down
2 changes: 2 additions & 0 deletions src/core_plugins/kibana/public/dashboard/__tests__/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('dashboard panel', function () {
parentScope.createChildUiState = sinon.stub().returns(mockUiState);
parentScope.getVisClickHandler = sinon.stub();
parentScope.getVisBrushHandler = sinon.stub();
parentScope.registerPanelIndexPattern = sinon.stub();
parentScope.panel = {
col: 3,
id: 'foo1',
Expand All @@ -45,6 +46,7 @@ describe('dashboard panel', function () {
get-vis-click-handler="getVisClickHandler"
get-vis-brush-handler="getVisBrushHandler"
save-state="saveState"
register-panel-index-pattern="registerPanelIndexPattern"
create-child-ui-state="createChildUiState">
</dashboard-panel>`)(parentScope);
$scope = $el.isolateScope();
Expand Down
7 changes: 6 additions & 1 deletion src/core_plugins/kibana/public/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
</kbn-top-nav>

<!-- Filters. -->
<filter-bar state="state"></filter-bar>
<filter-bar
state="state"
index-patterns="indexPatterns"
></filter-bar>

<div
ng-show="getShouldShowEditHelp()"
Expand Down Expand Up @@ -106,6 +109,7 @@ <h2 class="kuiTitle kuiVerticalRhythm">
toggle-expand="toggleExpandPanel"
create-child-ui-state="createChildUiState"
toggle-expand="toggleExpandPanel"
register-panel-index-pattern="registerPanelIndexPattern"
data-shared-items-count="{{panels.length}}"
></dashboard-grid>

Expand All @@ -118,6 +122,7 @@ <h2 class="kuiTitle kuiVerticalRhythm">
get-vis-click-handler="getFilterBarClickHandler"
get-vis-brush-handler="getBrushEvent"
save-state="saveState"
register-panel-index-pattern="registerPanelIndexPattern"
create-child-ui-state="createChildUiState"
toggle-expand="toggleExpandPanel(expandedPanel.panelIndex)"
></dashboard-panel>
Expand Down
14 changes: 12 additions & 2 deletions src/core_plugins/kibana/public/dashboard/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { UtilsBrushEventProvider } from 'ui/utils/brush_event';
import { FilterBarClickHandlerProvider } from 'ui/filter_bar/filter_bar_click_handler';
import { DashboardState } from './dashboard_state';
import { notify } from 'ui/notify';
import './panel/get_object_loaders_for_dashboard';
import { documentationLinks } from 'ui/documentation_links/documentation_links';
import { showCloneModal } from './top_nav/show_clone_modal';

Expand Down Expand Up @@ -201,15 +202,24 @@ app.directive('dashboardApp', function ($injector) {
return dashboardState.uiState.createChild(path, uiState, true);
};

$scope.onPanelRemoved = (panelIndex) => dashboardState.removePanel(panelIndex);

$scope.$watch('model.darkTheme', () => {
dashboardState.setDarkTheme($scope.model.darkTheme);
updateTheme();
});
$scope.$watch('model.description', () => dashboardState.setDescription($scope.model.description));
$scope.$watch('model.title', () => dashboardState.setTitle($scope.model.title));
$scope.$watch('model.timeRestore', () => dashboardState.setTimeRestore($scope.model.timeRestore));
$scope.indexPatterns = [];

$scope.registerPanelIndexPattern = (panelIndex, pattern) => {
dashboardState.registerPanelIndexPatternMap(panelIndex, pattern);
$scope.indexPatterns = dashboardState.getPanelIndexPatterns();
};

$scope.onPanelRemoved = (panelIndex) => {
dashboardState.removePanel(panelIndex);
$scope.indexPatterns = dashboardState.getPanelIndexPatterns();
};

$scope.$listen(timefilter, 'fetch', $scope.refresh);

Expand Down
12 changes: 12 additions & 0 deletions src/core_plugins/kibana/public/dashboard/dashboard_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,21 @@ export class DashboardState {
//in the 'lose changes' warning message.
this.lastSavedDashboardFilters = this.getFilterState();

// A mapping of panel index to the index pattern it uses.
this.panelIndexPatternMapping = {};

PanelUtils.initPanelIndexes(this.getPanels());
this.createStateMonitor();
}

registerPanelIndexPatternMap(panelIndex, indexPattern) {
this.panelIndexPatternMapping[panelIndex] = indexPattern;
}

getPanelIndexPatterns() {
return _.uniq(Object.values(this.panelIndexPatternMapping));
}

/**
* Resets the state back to the last saved version of the dashboard.
*/
Expand Down Expand Up @@ -271,6 +282,7 @@ export class DashboardState {
_.remove(this.getPanels(), (panel) => {
if (panel.panelIndex === panelIndex) {
this.uiState.removeChild(getPersistedStateId(panel));
delete this.panelIndexPatternMapping[panelIndex];
return true;
} else {
return false;
Expand Down
7 changes: 7 additions & 0 deletions src/core_plugins/kibana/public/dashboard/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ app.directive('dashboardGrid', function ($compile, Notifier) {
* @type {function} - Returns a {PersistedState} child uiState for this scope.
*/
createChildUiState: '=',
/**
* Registers an index pattern with the dashboard app used by each panel. The index patterns are used by the
* filter bar for generating field suggestions.
* @type {function(IndexPattern)}
*/
registerPanelIndexPattern: '=',
/**
* Trigger after a panel has been removed from the grid.
*/
Expand Down Expand Up @@ -195,6 +201,7 @@ app.directive('dashboardGrid', function ($compile, Notifier) {
get-vis-click-handler="getVisClickHandler"
get-vis-brush-handler="getVisBrushHandler"
save-state="saveState"
register-panel-index-pattern="registerPanelIndexPattern"
toggle-expand="toggleExpand(${panel.panelIndex})"
create-child-ui-state="createChildUiState">
</li>`;
Expand Down
10 changes: 10 additions & 0 deletions src/core_plugins/kibana/public/dashboard/panel/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ uiModules
* @type {function} - Returns a {PersistedState} child uiState for this scope.
*/
createChildUiState: '=',
/**
* Registers an index pattern with the dashboard app used by this panel. Used by the filter bar for
* generating field suggestions.
* @type {function(IndexPattern)}
*/
registerPanelIndexPattern: '=',
/**
* Contains information about this panel.
* @type {PanelState}
Expand Down Expand Up @@ -105,7 +111,11 @@ uiModules
$scope.savedObj.vis.setUiState($scope.uiState);
$scope.savedObj.vis.listeners.click = $scope.getVisClickHandler();
$scope.savedObj.vis.listeners.brush = $scope.getVisBrushHandler();
$scope.registerPanelIndexPattern($scope.panel.panelIndex, $scope.savedObj.vis.indexPattern);
} else if ($scope.panel.type === savedSearches.type) {
if ($scope.savedObj.searchSource) {
$scope.registerPanelIndexPattern($scope.panel.panelIndex, $scope.savedObj.searchSource.get('index'));
}
// This causes changes to a saved search to be hidden, but also allows
// the user to locally modify and save changes to a saved search only in a dashboard.
// See https://github.com/elastic/kibana/issues/9523 for more details.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DEFAULT_PANEL_WIDTH, DEFAULT_PANEL_HEIGHT } from 'plugins/kibana/dashboard/panel/panel_state';

import _ from 'lodash';

export class PanelUtils {
Expand Down
5 changes: 4 additions & 1 deletion src/core_plugins/kibana/public/discover/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@

<div class="container-fluid" role="main">
<div class="row">
<filter-bar state="state"></filter-bar>
<filter-bar
state="state"
index-patterns="[indexPattern]"
></filter-bar>
</div>
<div class="row">
<div class="col-md-2 sidebar-container collapsible-sidebar">
Expand Down
5 changes: 4 additions & 1 deletion src/core_plugins/kibana/public/visualize/editor/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@
</kbn-top-nav>

<!-- Filters. -->
<filter-bar state="state"></filter-bar>
<filter-bar
state="state"
index-patterns="[indexPattern]"
></filter-bar>

<!-- Custom, full-screen editing UI. -->
<div
Expand Down
1 change: 1 addition & 0 deletions src/core_plugins/kibana/public/visualize/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ function VisEditor($rootScope, $scope, $route, timefilter, AppState, $window, kb
$scope.editableVis = editableVis;
$scope.state = $state;
$scope.queryDocLinks = documentationLinks.query;
$scope.dateDocLinks = documentationLinks.date;

// Create a PersistedState instance.
$scope.uiState = $state.makeStateful('uiState');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { registerValueSuggestions } from './register_value_suggestions';

export function registerSuggestionsApi(server) {
registerValueSuggestions(server);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import handleESError from '../../../lib/handle_es_error';

export function registerValueSuggestions(server) {
server.route({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some API tests would be good for this route.

path: '/api/kibana/suggestions/values/{index}',
method: ['POST'],
handler: function (req, reply) {
const { index } = req.params;
const { field, query } = req.payload;

const { callWithRequest } = server.plugins.elasticsearch.getCluster('data');
const include = query ? `.*${query}.*` : undefined;
const body = getBody({ field, include });

return callWithRequest(req, 'search', { index, body })
.then((res) => {
const suggestions = res.aggregations.suggestions.buckets.map(bucket => bucket.key);
return reply(suggestions);
})
.catch(error => reply(handleESError(error)));
}
});
}

function getBody(terms) {
return {
aggs: {
suggestions: { terms }
}
};
}
16 changes: 16 additions & 0 deletions src/fixtures/filters/exists_filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const existsFilter = {
'meta': {
'index': 'logstash-*',
'negate': false,
'disabled': false,
'type': 'exists',
'key': 'machine.os',
'value': 'exists'
},
'exists': {
'field': 'machine.os'
},
'$state': {
'store': 'appState'
}
};
5 changes: 5 additions & 0 deletions src/fixtures/filters/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export { phraseFilter } from './phrase_filter';
export { scriptedPhraseFilter } from './scripted_phrase_filter';
export { phrasesFilter } from './phrases_filter';
export { rangeFilter } from './range_filter';
export { existsFilter } from './exists_filter';
21 changes: 21 additions & 0 deletions src/fixtures/filters/phrase_filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export const phraseFilter = {
meta: {
negate: false,
index: 'logstash-*',
type: 'phrase',
key: 'machine.os',
value: 'ios',
disabled: false
},
query: {
match: {
'machine.os': {
query: 'ios',
type: 'phrase'
}
}
},
$state: {
store: 'appState'
}
};
34 changes: 34 additions & 0 deletions src/fixtures/filters/phrases_filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export const phrasesFilter = {
meta: {
index: 'logstash-*',
type: 'phrases',
key: 'machine.os.raw',
value: 'win xp, osx',
params: [
'win xp',
'osx'
],
negate: false,
disabled: false
},
query: {
bool: {
should: [
{
match_phrase: {
'machine.os.raw': 'win xp'
}
},
{
match_phrase: {
'machine.os.raw': 'osx'
}
}
],
minimum_should_match: 1
}
},
$state: {
store: 'appState'
}
};
20 changes: 20 additions & 0 deletions src/fixtures/filters/range_filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export const rangeFilter = {
'meta': {
'index': 'logstash-*',
'negate': false,
'disabled': false,
'alias': null,
'type': 'range',
'key': 'bytes',
'value': '0 to 10'
},
'range': {
'bytes': {
'gte': 0,
'lt': 10
}
},
'$state': {
'store': 'appState'
}
};
23 changes: 23 additions & 0 deletions src/fixtures/filters/scripted_phrase_filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export const scriptedPhraseFilter = {
'meta': {
'negate': false,
'index': 'logstash-*',
'field': 'script string',
'type': 'phrase',
'key': 'script string',
'value': 'i am a string',
'disabled': false
},
'script': {
'script': {
'inline': 'boolean compare(Supplier s, def v) {return s.get() == v;}compare(() -> { \'i am a string\' }, params.value);',
'lang': 'painless',
'params': {
'value': 'i am a string'
}
}
},
'$state': {
'store': 'appState'
}
};
8 changes: 7 additions & 1 deletion src/ui/public/agg_types/controls/date_ranges.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@
<tr>
<td colspan="3">
<small>
<a target="_window" href="http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html#date-math">Accepted Date Formats <i class="fa-link fa"></i></a>
<a
class="kuiLink"
ng-href="{{dateDocLinks.dateMath}}"
target="_blank"
>
Accepted date formats
</a>
</small>
</td>
</tr>
Expand Down
Loading