-
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
Should respect pinned filters #13019
Changes from all commits
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 |
---|---|---|
|
@@ -8,51 +8,54 @@ import { ResizeCheckerProvider } from 'ui/resize_checker'; | |
import 'angular-sanitize'; | ||
import './visualization'; | ||
import './visualization_editor'; | ||
import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter'; | ||
|
||
|
||
import { | ||
isTermSizeZeroError, | ||
} from '../elasticsearch_errors'; | ||
|
||
uiModules | ||
.get('kibana/directive', ['ngSanitize']) | ||
.directive('visualize', function (Notifier, Private, timefilter, getAppState) { | ||
const notify = new Notifier({ location: 'Visualize' }); | ||
const requestHandlers = Private(VisRequestHandlersRegistryProvider); | ||
const responseHandlers = Private(VisResponseHandlersRegistryProvider); | ||
const ResizeChecker = Private(ResizeCheckerProvider); | ||
|
||
function getHandler(from, name) { | ||
if (typeof name === 'function') return name; | ||
return from.find(handler => handler.name === name).handler; | ||
} | ||
|
||
return { | ||
restrict: 'E', | ||
scope : { | ||
showSpyPanel: '=?', | ||
editorMode: '=?', | ||
savedObj: '=', | ||
appState: '=', | ||
uiState: '=?' | ||
}, | ||
template: visualizeTemplate, | ||
link: function ($scope, $el) { | ||
const resizeChecker = new ResizeChecker($el); | ||
|
||
$scope.vis = $scope.savedObj.vis; | ||
$scope.editorMode = $scope.editorMode || false; | ||
$scope.vis.editorMode = $scope.editorMode; | ||
$scope.vis.visualizeScope = true; | ||
|
||
if (!$scope.appState) $scope.appState = getAppState(); | ||
|
||
const requestHandler = getHandler(requestHandlers, $scope.vis.type.requestHandler); | ||
const responseHandler = getHandler(responseHandlers, $scope.vis.type.responseHandler); | ||
|
||
$scope.fetch = _.debounce(function () { | ||
.directive('visualize', function (Notifier, Private, timefilter, getAppState) { | ||
const notify = new Notifier({ location: 'Visualize' }); | ||
const requestHandlers = Private(VisRequestHandlersRegistryProvider); | ||
const responseHandlers = Private(VisResponseHandlersRegistryProvider); | ||
const ResizeChecker = Private(ResizeCheckerProvider); | ||
const queryFilter = Private(FilterBarQueryFilterProvider); | ||
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. i am not really sure about using queryFilter here ... 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. queryFilter is more more specific, but much easier to use .... appState + globalState are more generic .... but we shouldn't probably use them directly if we already have abstractions on top of it. |
||
|
||
function getHandler(from, name) { | ||
if (typeof name === 'function') return name; | ||
return from.find(handler => handler.name === name).handler; | ||
} | ||
|
||
return { | ||
restrict: 'E', | ||
scope : { | ||
showSpyPanel: '=?', | ||
editorMode: '=?', | ||
savedObj: '=', | ||
appState: '=', | ||
uiState: '=?' | ||
}, | ||
template: visualizeTemplate, | ||
link: function ($scope, $el) { | ||
const resizeChecker = new ResizeChecker($el); | ||
|
||
$scope.vis = $scope.savedObj.vis; | ||
$scope.editorMode = $scope.editorMode || false; | ||
$scope.vis.editorMode = $scope.editorMode; | ||
$scope.vis.visualizeScope = true; | ||
|
||
if (!$scope.appState) $scope.appState = getAppState(); | ||
|
||
const requestHandler = getHandler(requestHandlers, $scope.vis.type.requestHandler); | ||
const responseHandler = getHandler(responseHandlers, $scope.vis.type.responseHandler); | ||
|
||
$scope.fetch = _.debounce(function () { | ||
|
||
// searchSource is only there for courier request handler | ||
requestHandler($scope.vis, $scope.appState, $scope.uiState, $scope.savedObj.searchSource) | ||
requestHandler($scope.vis, $scope.appState, $scope.uiState, queryFilter, $scope.savedObj.searchSource) | ||
.then(requestHandlerResponse => { | ||
|
||
//No need to call the response handler when there have been no data nor has been there changes | ||
|
@@ -83,73 +86,74 @@ uiModules | |
$scope.$broadcast('render'); | ||
return resp; | ||
}); | ||
}, 100); | ||
}, 100); | ||
|
||
$scope.vis.on('update', () => { | ||
if ($scope.editorMode) { | ||
$scope.appState.vis = $scope.vis.getState(); | ||
$scope.appState.save(); | ||
} else { | ||
$scope.fetch(); | ||
} | ||
}); | ||
$scope.vis.on('update', () => { | ||
if ($scope.editorMode) { | ||
$scope.appState.vis = $scope.vis.getState(); | ||
$scope.appState.save(); | ||
} else { | ||
$scope.fetch(); | ||
} | ||
}); | ||
|
||
const reload = () => { | ||
$scope.vis.reload = true; | ||
$scope.fetch(); | ||
}; | ||
$scope.vis.on('reload', reload); | ||
const reload = () => { | ||
$scope.vis.reload = true; | ||
$scope.fetch(); | ||
}; | ||
$scope.vis.on('reload', reload); | ||
// auto reload will trigger this event | ||
$scope.$on('courier:searchRefresh', reload); | ||
$scope.$on('courier:searchRefresh', reload); | ||
// dashboard will fire fetch event when it wants to refresh | ||
$scope.$on('fetch', reload); | ||
|
||
if ($scope.appState) { | ||
let oldUiState; | ||
const stateMonitor = stateMonitorFactory.create($scope.appState); | ||
stateMonitor.onChange((status, type, keys) => { | ||
if (keys[0] === 'vis') { | ||
if ($scope.appState.vis) $scope.vis.setState($scope.appState.vis); | ||
$scope.fetch(); | ||
} | ||
if ($scope.vis.type.requiresSearch && ['query', 'filters'].includes(keys[0])) { | ||
$scope.fetch(); | ||
} | ||
if (keys[0] === 'uiState') { | ||
$scope.$on('fetch', reload); | ||
queryFilter.on('update', $scope.fetch); | ||
|
||
if ($scope.appState) { | ||
let oldUiState; | ||
const stateMonitor = stateMonitorFactory.create($scope.appState); | ||
stateMonitor.onChange((status, type, keys) => { | ||
if (keys[0] === 'vis') { | ||
if ($scope.appState.vis) $scope.vis.setState($scope.appState.vis); | ||
$scope.fetch(); | ||
} | ||
if ($scope.vis.type.requiresSearch && ['query', 'filters'].includes(keys[0])) { | ||
$scope.fetch(); | ||
} | ||
if (keys[0] === 'uiState') { | ||
// uiState can be changed by other visualizations on dashboard. this makes sure this fires only if | ||
// current visualizations uiState changed. | ||
if (!oldUiState || oldUiState !== JSON.stringify($scope.uiState.toJSON())) { | ||
oldUiState = JSON.stringify($scope.uiState.toJSON()); | ||
$scope.fetch(); | ||
if (!oldUiState || oldUiState !== JSON.stringify($scope.uiState.toJSON())) { | ||
oldUiState = JSON.stringify($scope.uiState.toJSON()); | ||
$scope.fetch(); | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
$scope.$on('$destroy', () => { | ||
stateMonitor.destroy(); | ||
}); | ||
} | ||
$scope.$on('$destroy', () => { | ||
stateMonitor.destroy(); | ||
}); | ||
} | ||
|
||
let resizeInit = false; | ||
const resizeFunc = _.debounce(() => { | ||
if (!resizeInit) return resizeInit = true; | ||
$scope.vis.size = [$el.width(), $el.height()]; | ||
$scope.$broadcast('render'); | ||
}, 200); | ||
resizeChecker.on('resize', resizeFunc); | ||
let resizeInit = false; | ||
const resizeFunc = _.debounce(() => { | ||
if (!resizeInit) return resizeInit = true; | ||
$scope.vis.size = [$el.width(), $el.height()]; | ||
$scope.$broadcast('render'); | ||
}, 200); | ||
resizeChecker.on('resize', resizeFunc); | ||
|
||
// visualize needs to know about timeFilter | ||
$scope.$listen(timefilter, 'fetch', $scope.fetch); | ||
$scope.$on('renderComplete', () => { | ||
$el.trigger('renderComplete'); | ||
}); | ||
$scope.$listen(timefilter, 'fetch', $scope.fetch); | ||
$scope.$on('renderComplete', () => { | ||
$el.trigger('renderComplete'); | ||
}); | ||
|
||
$scope.$on('$destroy', () => { | ||
resizeChecker.destroy(); | ||
}); | ||
$scope.$on('$destroy', () => { | ||
resizeChecker.destroy(); | ||
}); | ||
|
||
$scope.fetch(); | ||
$scope.$root.$broadcast('ready:vis'); | ||
} | ||
}; | ||
}); | ||
$scope.fetch(); | ||
$scope.$root.$broadcast('ready:vis'); | ||
} | ||
}; | ||
}); |
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.
seems github messed up this comparison ? shows whole file is different where only a couple of lines changed ....
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.
not sure. maybe a lintroller thing..