mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
express more control over initial render of the visualization by validation the 'timefilter.time' watcher and waiting for the visualization to emit load before fetching
This commit is contained in:
parent
85ab3f208c
commit
2bd1d36802
1 changed files with 15 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
define(function (require) {
|
||||
var _ = require('lodash');
|
||||
var angular = require('angular');
|
||||
var ConfigTemplate = require('utils/config_template');
|
||||
var typeDefs = require('../saved_visualizations/_type_defs');
|
||||
|
||||
|
@ -64,6 +65,14 @@ define(function (require) {
|
|||
|
||||
var visConfigProperties = Object.keys(visConfigCategories.byName);
|
||||
|
||||
var init = function () {
|
||||
$scope.$on('ready:vis', function () {
|
||||
// once the visualization is ready, boot up
|
||||
vis.setState($state);
|
||||
$scope.$emit('application.load');
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Write the latest changes made on the visualization to the $state. This
|
||||
* will cause a fetch if there were changes
|
||||
|
@ -130,7 +139,11 @@ define(function (require) {
|
|||
*/
|
||||
timefilter.enabled(true);
|
||||
$scope.timefilter = timefilter;
|
||||
$scope.$watchCollection('timefilter.time', $scope.doVisualize);
|
||||
// TODO: Switch this to watching time.string when we implement it
|
||||
$scope.$watchCollection('timefilter.time', function (newTime, oldTime) {
|
||||
// don't fetch unless there was a previous value and the values are not loosly equal
|
||||
if (!_.isUndefined(oldTime) && !angular.equals(newTime, oldTime)) $scope.doVisualize();
|
||||
});
|
||||
|
||||
// config panel templates
|
||||
var configTemplate = $scope.configTemplate = new ConfigTemplate({
|
||||
|
@ -152,7 +165,7 @@ define(function (require) {
|
|||
$scope.conf = _.pick($scope, 'doSave', 'vis');
|
||||
|
||||
// init
|
||||
readStateAndFetch();
|
||||
init();
|
||||
});
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue