Skip to content

Commit

Permalink
Fixes for Dashboard Context for both TSVB and Timelion (#12214) (#12216)
Browse files Browse the repository at this point in the history
* 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

(cherry picked from commit 2908405)

* correct import path
  • Loading branch information
spalger authored Jun 7, 2017
1 parent 9972ad5 commit d2a8839
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// This file is used by Timelion and TSVB
import _ from 'lodash';
import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter';
require('ui/state_management/app_state');
import 'ui/state_management/app_state';


module.exports = function dashboardContext(Private, getAppState) {
return function () {
export function dashboardContextProvider(Private, getAppState) {
return () => {
const queryFilter = Private(FilterBarQueryFilterProvider);
const bool = { must: [], must_not: [] };
const filterBarFilters = queryFilter.getFilters();
Expand All @@ -22,12 +22,14 @@ module.exports = function dashboardContext(Private, getAppState) {

if (filter.meta.disabled) return;
if (filter.meta.negate) {
bool.must_not = bool.must_not || [];
bool.must_not.push(esFilter.query || esFilter);
} else {
bool.must = bool.must || [];
bool.must.push(esFilter.query || esFilter);
}
});

return { bool: bool };
};
};
}
5 changes: 3 additions & 2 deletions src/core_plugins/metrics/public/lib/fetch.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { validateInterval } from './validate_interval';
import { dashboardContextProvider } from 'plugins/kibana/dashboard/dashboard_context';
export default (
timefilter,
Private,
Notifier,
$http,
config
config,
) => {
const dashboardContext = Private(require('../../../timelion/public/services/dashboard_context'));
const dashboardContext = Private(dashboardContextProvider);
const notify = new Notifier({ location: 'Metrics' });
return $scope => () => {
const panel = $scope.model;
Expand Down
16 changes: 9 additions & 7 deletions src/core_plugins/timelion/public/vis/timelion_vis_controller.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter';
import { uiModules } from 'ui/modules';
import timezoneProvider from 'plugins/timelion/services/timezone';
import { dashboardContextProvider } from 'plugins/kibana/dashboard/dashboard_context';
import 'plugins/timelion/directives/chart/chart';
import 'plugins/timelion/directives/interval/interval';
import 'ui/state_management/app_state';

define(function (require) {
require('plugins/timelion/directives/chart/chart');
require('plugins/timelion/directives/interval/interval');
require('ui/state_management/app_state');

const _ = require('lodash');
const module = require('ui/modules').get('kibana/timelion_vis', ['kibana']);
const module = uiModules.get('kibana/timelion_vis', ['kibana']);
module.controller('TimelionVisController', function ($scope, $element, Private, Notifier, $http, $rootScope, timefilter) {
const queryFilter = Private(FilterBarQueryFilterProvider);
const timezone = Private(require('plugins/timelion/services/timezone'))();
const dashboardContext = Private(require('plugins/timelion/services/dashboard_context'));
const timezone = Private(timezoneProvider)();
const dashboardContext = Private(dashboardContextProvider);

const notify = new Notifier({
location: 'Timelion'
Expand Down

0 comments on commit d2a8839

Please sign in to comment.