Skip to content

Commit

Permalink
Merge pull request #1657 from spenceralger/fix/1656
Browse files Browse the repository at this point in the history
Update visualize for non-time-based indices
  • Loading branch information
rashidkpc committed Oct 15, 2014
2 parents fa98708 + 9e961ad commit 1c8df75
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
11 changes: 11 additions & 0 deletions src/kibana/apps/visualize/editor/agg_param.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
define(function (require) {
var _ = require('lodash');

require('modules')
.get('app/visualize')
.directive('visAggParamEditor', function () {
Expand All @@ -12,6 +14,15 @@ define(function (require) {
},
template: function ($el, attr) {
return $el.html();
},
link: function ($scope) {
$scope.optionEnabled = function (option) {
if (option && _.isFunction(option.enabled)) {
return option.enabled($scope.aggConfig);
}

return true;
};
}
};
});
Expand Down
7 changes: 5 additions & 2 deletions src/kibana/apps/visualize/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ define(function (require) {
'kibana/courier'
])
.controller('VisEditor', function ($scope, $route, timefilter, AppState, $location, kbnUrl, $timeout, courier) {

var _ = require('lodash');
var angular = require('angular');
var ConfigTemplate = require('utils/config_template');
Expand Down Expand Up @@ -83,6 +82,7 @@ define(function (require) {
function init() {
// export some objects
$scope.savedVis = savedVis;
$scope.searchSource = searchSource;
$scope.vis = vis;
$scope.editableVis = editableVis;
$scope.state = $state;
Expand Down Expand Up @@ -112,6 +112,10 @@ define(function (require) {
editableVis.dirty = !angular.equals(newState, vis.getState());
}, true);

$scope.$watch('searchSource.get("index").timeFieldName', function (timeField) {
timefilter.enabled = !!timeField;
});

$scope.$listen($state, 'fetch_with_changes', function () {

vis.setState($state.vis);
Expand All @@ -128,7 +132,6 @@ define(function (require) {

});

timefilter.enabled = true;
$scope.$listen(timefilter, 'update', _.bindKey($scope, 'fetch'));

$scope.$on('ready:vis', function () {
Expand Down
5 changes: 4 additions & 1 deletion src/kibana/components/agg_types/buckets/_interval_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ define(function (require) {
return [
{
display: 'Auto',
val: 'auto'
val: 'auto',
enabled: function (aggConfig) {
return !!aggConfig.vis.indexPattern.timeFieldName;
}
},
{
display: 'Second',
Expand Down
2 changes: 1 addition & 1 deletion src/kibana/components/agg_types/buckets/date_histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ define(function (require) {
min: val.min,
max: val.max
};
} else {
} else if (aggConfig.vis.indexPattern.timeFieldName) {
var tfBounds = timefilter.getBounds();
output.params.extended_bounds = {
min: tfBounds.min,
Expand Down
3 changes: 2 additions & 1 deletion src/kibana/components/agg_types/controls/interval.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
ng-if="aggParam.options"
ng-model="params.interval"
required
ng-options="opt as opt.display for opt in aggParam.options"
ng-options="opt as opt.display for opt in aggParam.options.raw | filter:optionEnabled"
class="form-control"
name="interval">
<option value="">-- select a valid interval --</option>
</select>
<input
ng-if="!aggParam.options"
Expand Down

0 comments on commit 1c8df75

Please sign in to comment.