mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
visualize should wait for visualization to finish initialization (#13742)
* visualize should wait for visualization to finish initialization * clear timeout on destroy * fixing based on stacey's review
This commit is contained in:
parent
e672b3f49c
commit
db36ef7735
3 changed files with 13 additions and 4 deletions
|
@ -100,6 +100,12 @@ uiModules
|
|||
const Visualization = $scope.vis.type.visualization;
|
||||
const visualization = new Visualization(getVisEl()[0], $scope.vis);
|
||||
|
||||
if (visualization.init) {
|
||||
visualization.init().then(() => { $scope.vis.initialized = true; });
|
||||
} else {
|
||||
$scope.vis.initialized = true;
|
||||
}
|
||||
|
||||
const renderFunction = _.debounce(() => {
|
||||
$scope.vis.size = [$el.width(), $el.height()];
|
||||
const status = getUpdateStatus($scope);
|
||||
|
@ -115,7 +121,7 @@ uiModules
|
|||
}, 100);
|
||||
|
||||
$scope.$on('render', () => {
|
||||
if (!$scope.vis || ($scope.vis.type.requiresSearch && !$scope.visData)) {
|
||||
if (!$scope.vis || !$scope.vis.initialized || ($scope.vis.type.requiresSearch && !$scope.visData)) {
|
||||
return;
|
||||
}
|
||||
renderFunction();
|
||||
|
|
|
@ -8,7 +8,7 @@ import { getUpdateStatus } from 'ui/vis/update_status';
|
|||
|
||||
uiModules
|
||||
.get('kibana/directive', ['ngSanitize'])
|
||||
.directive('visualizationEditor', function (Private) {
|
||||
.directive('visualizationEditor', function (Private, $timeout) {
|
||||
const editorTypes = Private(VisEditorTypesRegistryProvider);
|
||||
|
||||
return {
|
||||
|
@ -43,6 +43,7 @@ uiModules
|
|||
editor.destroy();
|
||||
});
|
||||
|
||||
$timeout(() => { renderFunction(); });
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
@ -53,8 +53,8 @@ uiModules
|
|||
const responseHandler = getHandler(responseHandlers, $scope.vis.type.responseHandler);
|
||||
|
||||
$scope.fetch = _.debounce(function () {
|
||||
|
||||
// searchSource is only there for courier request handler
|
||||
if (!$scope.vis.initialized) return;
|
||||
// searchSource is only there for courier request handler
|
||||
requestHandler($scope.vis, $scope.appState, $scope.uiState, queryFilter, $scope.savedObj.searchSource)
|
||||
.then(requestHandlerResponse => {
|
||||
|
||||
|
@ -151,6 +151,8 @@ uiModules
|
|||
resizeChecker.destroy();
|
||||
});
|
||||
|
||||
$scope.$watch('vis.initialized', $scope.fetch);
|
||||
|
||||
$scope.fetch();
|
||||
$scope.$root.$broadcast('ready:vis');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue