mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -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 = $scope.vis.type.visualization;
|
||||||
const visualization = new Visualization(getVisEl()[0], $scope.vis);
|
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(() => {
|
const renderFunction = _.debounce(() => {
|
||||||
$scope.vis.size = [$el.width(), $el.height()];
|
$scope.vis.size = [$el.width(), $el.height()];
|
||||||
const status = getUpdateStatus($scope);
|
const status = getUpdateStatus($scope);
|
||||||
|
@ -115,7 +121,7 @@ uiModules
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
$scope.$on('render', () => {
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
renderFunction();
|
renderFunction();
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { getUpdateStatus } from 'ui/vis/update_status';
|
||||||
|
|
||||||
uiModules
|
uiModules
|
||||||
.get('kibana/directive', ['ngSanitize'])
|
.get('kibana/directive', ['ngSanitize'])
|
||||||
.directive('visualizationEditor', function (Private) {
|
.directive('visualizationEditor', function (Private, $timeout) {
|
||||||
const editorTypes = Private(VisEditorTypesRegistryProvider);
|
const editorTypes = Private(VisEditorTypesRegistryProvider);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -43,6 +43,7 @@ uiModules
|
||||||
editor.destroy();
|
editor.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$timeout(() => { renderFunction(); });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -53,8 +53,8 @@ uiModules
|
||||||
const responseHandler = getHandler(responseHandlers, $scope.vis.type.responseHandler);
|
const responseHandler = getHandler(responseHandlers, $scope.vis.type.responseHandler);
|
||||||
|
|
||||||
$scope.fetch = _.debounce(function () {
|
$scope.fetch = _.debounce(function () {
|
||||||
|
if (!$scope.vis.initialized) return;
|
||||||
// searchSource is only there for courier request handler
|
// searchSource is only there for courier request handler
|
||||||
requestHandler($scope.vis, $scope.appState, $scope.uiState, queryFilter, $scope.savedObj.searchSource)
|
requestHandler($scope.vis, $scope.appState, $scope.uiState, queryFilter, $scope.savedObj.searchSource)
|
||||||
.then(requestHandlerResponse => {
|
.then(requestHandlerResponse => {
|
||||||
|
|
||||||
|
@ -151,6 +151,8 @@ uiModules
|
||||||
resizeChecker.destroy();
|
resizeChecker.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$scope.$watch('vis.initialized', $scope.fetch);
|
||||||
|
|
||||||
$scope.fetch();
|
$scope.fetch();
|
||||||
$scope.$root.$broadcast('ready:vis');
|
$scope.$root.$broadcast('ready:vis');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue