Skip to content

Commit 2908405

Browse files
simianhackerspalger
authored andcommitted
Fixes for Dashboard Context for both TSVB and Timelion (#12214)
* Decoupling TSVB from timelion * Changing behavior back to the provider pattern * Fixing Timelion's dashboard context provider * Moving dashboard_context out of Timelion and TSVB into Kibana
1 parent abe3fb1 commit 2908405

File tree

4 files changed

+39
-35
lines changed

4 files changed

+39
-35
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// This file is used by Timelion and TSVB
2+
import _ from 'lodash';
3+
import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter';
4+
import 'ui/state_management/app_state';
5+
6+
export function dashboardContextProvider(Private, getAppState) {
7+
return () => {
8+
const queryFilter = Private(FilterBarQueryFilterProvider);
9+
const bool = { must: [], must_not: [] };
10+
const filterBarFilters = queryFilter.getFilters();
11+
const queryBarFilter = getAppState().query;
12+
13+
// Add the query bar filter, its handled differently.
14+
bool.must.push(queryBarFilter);
15+
16+
// Add each of the filter bar filters
17+
_.each(filterBarFilters, function (filter) {
18+
const esFilter = _.omit(filter, function (val, key) {
19+
if (key === 'meta' || key[0] === '$') return true;
20+
return false;
21+
});
22+
23+
if (filter.meta.disabled) return;
24+
if (filter.meta.negate) {
25+
bool.must_not = bool.must_not || [];
26+
bool.must_not.push(esFilter.query || esFilter);
27+
} else {
28+
bool.must = bool.must || [];
29+
bool.must.push(esFilter.query || esFilter);
30+
}
31+
});
32+
33+
return { bool: bool };
34+
};
35+
}

src/core_plugins/metrics/public/lib/fetch.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { validateInterval } from './validate_interval';
2+
import { dashboardContextProvider } from 'plugins/kibana/dashboard/dashboard_context';
23
export default (
34
timefilter,
45
Private,
56
Notifier,
67
$http,
7-
config
8+
config,
89
) => {
9-
const dashboardContext = Private(require('../../../timelion/public/services/dashboard_context'));
10+
const dashboardContext = Private(dashboardContextProvider);
1011
const notify = new Notifier({ location: 'Metrics' });
1112
return $scope => () => {
1213
const panel = $scope.model;

src/core_plugins/timelion/public/services/dashboard_context.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/core_plugins/timelion/public/vis/timelion_vis_controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import _ from 'lodash';
22
import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter';
33
import { uiModules } from 'ui/modules';
44
import timezoneProvider from 'plugins/timelion/services/timezone';
5-
import dashboardContextProvider from 'plugins/timelion/services/dashboard_context';
5+
import { dashboardContextProvider } from 'plugins/kibana/dashboard/dashboard_context';
66
import 'plugins/timelion/directives/chart/chart';
77
import 'plugins/timelion/directives/timelion_interval/timelion_interval';
88
import 'ui/state_management/app_state';

0 commit comments

Comments
 (0)