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 interval drop-down for date histogram in discover #10384

Merged
merged 9 commits into from
Mar 28, 2017
10 changes: 1 addition & 9 deletions src/core_plugins/kibana/public/discover/controllers/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ function discoverController($scope, config, courier, $route, $window, Notifier,
return interval.val !== 'custom';
};

$scope.toggleInterval = function () {
$scope.showInterval = !$scope.showInterval;
};
$scope.topNavMenu = [{
key: 'new',
description: 'New Search',
Expand Down Expand Up @@ -236,9 +233,6 @@ function discoverController($scope, config, courier, $route, $window, Notifier,
});

$scope.$watch('state.interval', function (interval, oldInterval) {
if (interval !== oldInterval && interval === 'auto') {
$scope.showInterval = false;
}
$scope.fetch();
});

Expand All @@ -249,9 +243,7 @@ function discoverController($scope, config, courier, $route, $window, Notifier,
const buckets = $scope.vis.aggs.bySchemaGroup.buckets;

if (buckets && buckets.length === 1) {
$scope.intervalName = 'by ' + buckets[0].buckets.getInterval().description;
} else {
$scope.intervalName = 'auto';
$scope.bucketInterval = buckets[0].buckets.getInterval();
}
});

Expand Down
16 changes: 8 additions & 8 deletions src/core_plugins/kibana/public/discover/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,20 @@ <h2>Searching</h2>

&mdash;

<span class="results-interval" ng-hide="showInterval">
<a
ng-click="toggleInterval()">
{{ intervalName }}
</a>
</span>

<span ng-show="showInterval" class="results-interval form-inline">
<span class="results-interval form-inline">
<select
class="form-control"
ng-model="state.interval"
ng-options="interval.val as interval.display for interval in intervalOptions | filter: intervalEnabled"
ng-blur="toggleInterval()"
Copy link
Contributor

Choose a reason for hiding this comment

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

One small suggestion... can we remove this function, and add two to replace it: showInterval and hideInterval? I think this explicitness clarifies the logic behind the behavior.

>
</select>
<kbn-info
ng-show="bucketInterval.scaled"
placement="right"
class="text-warning"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you change this class to kuiIcon--info? It's a bit of a misuse of the class but I think it's OK in this instance because I doubt that class will change.

info="This interval creates {{ bucketInterval.scale > 1 ? 'buckets that are too large' : 'too many buckets' }} to show in the selected time range, so it has been scaled to {{ bucketInterval.description }}">
</kbn-info>
</span>
</center>

Expand Down