mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Tag Cloud should deal with empty responses correctly (#9354)
tag cloud did not work with empty responses correctly. One of the side-effects is that the back button did not work properly. For example, pressing the back button would not empty out the screen and show stale clouds. This also caused a type-error. Empty configurations meant that we could not access any aggregation-configs to produce a label.
This commit is contained in:
parent
ac6c4cd3ef
commit
5b61fc346b
2 changed files with 31 additions and 3 deletions
|
@ -129,8 +129,23 @@ class TagCloud extends EventEmitter {
|
|||
|
||||
const job = this._queue.pop();
|
||||
this._inFlight = true;
|
||||
this._onLayoutEnd(job);
|
||||
|
||||
if (job.words.length) {
|
||||
this._onLayoutEnd(job);
|
||||
} else {
|
||||
this._emptyCloud(job);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_emptyCloud(job) {
|
||||
this._svgGroup.selectAll('text').remove();
|
||||
this._cloudWidth = 0;
|
||||
this._cloudHeight = 0;
|
||||
this._allInViewBox = true;
|
||||
this._inFlight = false;
|
||||
this._currentJob = job;
|
||||
this._processQueue();
|
||||
}
|
||||
|
||||
_onLayoutEnd(job) {
|
||||
|
|
|
@ -21,13 +21,23 @@ module.controller('KbnTagCloudController', function ($scope, $element, Private,
|
|||
clickHandler({point: {aggConfigResult: aggConfigResult}});
|
||||
});
|
||||
tagCloud.on('renderComplete', () => {
|
||||
|
||||
const truncatedMessage = containerNode.querySelector('.tagcloud-truncated-message');
|
||||
const incompleteMessage = containerNode.querySelector('.tagcloud-incomplete-message');
|
||||
|
||||
if (!$scope.vis.aggs[0] || !$scope.vis.aggs[1]) {
|
||||
incompleteMessage.style.display = 'none';
|
||||
truncatedMessage.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
const bucketName = containerNode.querySelector('.tagcloud-custom-label');
|
||||
bucketName.innerHTML = `${$scope.vis.aggs[0].makeLabel()} - ${$scope.vis.aggs[1].makeLabel()}`;
|
||||
|
||||
const truncatedMessage = containerNode.querySelector('.tagcloud-truncated-message');
|
||||
|
||||
truncatedMessage.style.display = truncated ? 'block' : 'none';
|
||||
|
||||
const incompleteMessage = containerNode.querySelector('.tagcloud-incomplete-message');
|
||||
|
||||
const status = tagCloud.getStatus();
|
||||
|
||||
if (TagCloud.STATUS.COMPLETE === status) {
|
||||
|
@ -36,17 +46,20 @@ module.controller('KbnTagCloudController', function ($scope, $element, Private,
|
|||
incompleteMessage.style.display = 'block';
|
||||
}
|
||||
|
||||
|
||||
$element.trigger('renderComplete');
|
||||
});
|
||||
|
||||
$scope.$watch('esResponse', async function (response) {
|
||||
|
||||
if (!response) {
|
||||
tagCloud.setData([]);
|
||||
return;
|
||||
}
|
||||
|
||||
const tagsAggId = _.first(_.pluck($scope.vis.aggs.bySchemaName.segment, 'id'));
|
||||
if (!tagsAggId || !response.aggregations) {
|
||||
tagCloud.setData([]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue