mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix(elasticsearch): made interval template variable appear in group by time interval dropdown, fixes #3241
This commit is contained in:
@@ -15,7 +15,6 @@ function (angular, _, queryDef) {
|
||||
$scope.bucketAggTypes = queryDef.bucketAggTypes;
|
||||
$scope.orderOptions = queryDef.orderOptions;
|
||||
$scope.sizeOptions = queryDef.sizeOptions;
|
||||
$scope.intervalOptions = queryDef.intervalOptions;
|
||||
|
||||
$rootScope.onAppEvent('elastic-query-updated', function() {
|
||||
$scope.validateModel();
|
||||
@@ -128,6 +127,10 @@ function (angular, _, queryDef) {
|
||||
}
|
||||
};
|
||||
|
||||
$scope.getIntervalOptions = function() {
|
||||
return $q.when(uiSegmentSrv.transformToSegments(true, 'interval')(queryDef.intervalOptions));
|
||||
};
|
||||
|
||||
$scope.addBucketAgg = function() {
|
||||
// if last is date histogram add it before
|
||||
var lastBucket = bucketAggs[bucketAggs.length - 1];
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
Interval
|
||||
</li>
|
||||
<li>
|
||||
<metric-segment-model property="agg.settings.interval" options="intervalOptions" on-change="onChangeInternal()" css-class="last" custom="true"></metric-segment-model>
|
||||
<metric-segment-model property="agg.settings.interval" get-options="getIntervalOptions()" on-change="onChangeInternal()" css-class="last" custom="true"></metric-segment-model>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
define([
|
||||
'angular',
|
||||
'lodash',
|
||||
],
|
||||
function (angular, _) {
|
||||
function (angular) {
|
||||
'use strict';
|
||||
|
||||
var module = angular.module('grafana.controllers');
|
||||
|
||||
module.controller('ElasticQueryCtrl', function($scope, $timeout, uiSegmentSrv, templateSrv) {
|
||||
module.controller('ElasticQueryCtrl', function($scope, $timeout, uiSegmentSrv) {
|
||||
|
||||
$scope.init = function() {
|
||||
var target = $scope.target;
|
||||
@@ -21,7 +20,7 @@ function (angular, _) {
|
||||
$scope.getFields = function(type) {
|
||||
var jsonStr = angular.toJson({find: 'fields', type: type});
|
||||
return $scope.datasource.metricFindQuery(jsonStr)
|
||||
.then($scope.transformToSegments(false))
|
||||
.then(uiSegmentSrv.transformToSegments(false))
|
||||
.then(null, $scope.handleQueryError);
|
||||
};
|
||||
|
||||
@@ -35,21 +34,6 @@ function (angular, _) {
|
||||
$scope.appEvent('elastic-query-updated');
|
||||
};
|
||||
|
||||
$scope.transformToSegments = function(addTemplateVars) {
|
||||
return function(results) {
|
||||
var segments = _.map(results, function(segment) {
|
||||
return uiSegmentSrv.newSegment({ value: segment.text, expandable: segment.expandable });
|
||||
});
|
||||
|
||||
if (addTemplateVars) {
|
||||
_.each(templateSrv.variables, function(variable) {
|
||||
segments.unshift(uiSegmentSrv.newSegment({ type: 'template', value: '$' + variable.name, expandable: true }));
|
||||
});
|
||||
}
|
||||
return segments;
|
||||
};
|
||||
};
|
||||
|
||||
$scope.handleQueryError = function(err) {
|
||||
$scope.parserError = err.message || 'Failed to issue metric query';
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user