From 43e777b93b6e008b959a752b751b685af4bcf124 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Fri, 8 Jan 2016 12:34:06 -0700 Subject: [PATCH] merge #5854 --- src/ui/public/visualize/spy.html | 2 +- src/ui/public/visualize/visualize.js | 31 ++++++++++++++++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/ui/public/visualize/spy.html b/src/ui/public/visualize/spy.html index e0778b5c651640..689a4151e5eb93 100644 --- a/src/ui/public/visualize/spy.html +++ b/src/ui/public/visualize/spy.html @@ -15,7 +15,7 @@
- + diff --git a/src/ui/public/visualize/visualize.js b/src/ui/public/visualize/visualize.js index bc9224fb6783bd..45c97e5a9354a7 100644 --- a/src/ui/public/visualize/visualize.js +++ b/src/ui/public/visualize/visualize.js @@ -44,6 +44,15 @@ define(function (require) { var getVisEl = getter('.visualize-chart'); var getVisContainer = getter('.vis-container'); + // Show no results message when isZeroHits is true and it requires search + $scope.showNoResultsMessage = function () { + var requiresSearch = _.get($scope, 'vis.type.requiresSearch'); + var isZeroHits = _.get($scope,'esResp.hits.total') === 0; + var shouldShowMessage = !_.get($scope, 'vis.params.handleNoResults'); + + return Boolean(requiresSearch && isZeroHits && shouldShowMessage); + }; + $scope.fullScreenSpy = false; $scope.spy = {}; $scope.spy.mode = ($scope.uiState) ? $scope.uiState.get('spy.mode', {}) : {}; @@ -54,10 +63,8 @@ define(function (require) { $visEl.toggleClass('spy-only', Boolean(fullSpy)); - // Basically a magic number, chart must be at least this big or only the spy will show - var visTooSmall = 100; $timeout(function () { - if ($visEl.height() < visTooSmall) { + if (shouldHaveFullSpy()) { $visEl.addClass('spy-only'); }; }, 0); @@ -90,18 +97,20 @@ define(function (require) { 'transition-delay': loadingDelay }; - // spy watchers - $scope.$watch('fullScreenSpy', applyClassNames); - - $scope.$watchCollection('spy.mode', function (spyMode, oldSpyMode) { + function shouldHaveFullSpy() { var $visEl = getVisEl(); if (!$visEl) return; - // if the spy has been opened, check chart height - if (spyMode && !oldSpyMode) { - $scope.fullScreenSpy = $visEl.height() < minVisChartHeight; - } + return ($visEl.height() < minVisChartHeight) + && _.get($scope.spy, 'mode.fill') + && _.get($scope.spy, 'mode.name'); + } + + // spy watchers + $scope.$watch('fullScreenSpy', applyClassNames); + $scope.$watchCollection('spy.mode', function () { + $scope.fullScreenSpy = shouldHaveFullSpy(); applyClassNames(); });