Skip to content

Commit

Permalink
merge #5854
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashid Khan committed Jan 11, 2016
1 parent a0910d3 commit 43e777b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/ui/public/visualize/spy.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</a>
</div>
<div class="button-group visualize-spy-fill">
<a ng-if="!fullScreenSpy" ng-click="toggleFullPage()">
<a ng-click="toggleFullPage()">
<i ng-if="!spy.mode.fill" class="fa fa-expand"></i>
<i ng-if="spy.mode.fill" class="fa fa-compress"></i>
</a>
Expand Down
31 changes: 20 additions & 11 deletions src/ui/public/visualize/visualize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {}) : {};
Expand All @@ -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);
Expand Down Expand Up @@ -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();
});

Expand Down

0 comments on commit 43e777b

Please sign in to comment.