Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spy panel full screen with back button #5854

Merged
merged 1 commit into from
Jan 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
23 changes: 11 additions & 12 deletions src/ui/public/visualize/visualize.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ define(function (require) {
return Boolean(requiresSearch && isZeroHits && shouldShowMessage);
};

$scope.fullScreenSpy = false;
$scope.spy = {};
$scope.spy.mode = ($scope.uiState) ? $scope.uiState.get('spy.mode', {}) : {};

Expand All @@ -63,10 +62,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 @@ -99,18 +96,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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be has instead of get? As it stands now, if either mode.fill or mode.name are not truthy (e.g. 0), this will fail. That may be the intended behavior, but I wanted to make sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_.get is correct, we need to know if both are truthy

&& _.get($scope.spy, 'mode.name');
}

// spy watchers
$scope.$watch('fullScreenSpy', applyClassNames);

$scope.$watchCollection('spy.mode', function () {
$scope.fullScreenSpy = shouldHaveFullSpy();
applyClassNames();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this one, and the one on :109?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oddly enough, yes.

});

Expand Down