mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -26,13 +26,21 @@ function (angular, _, queryDef) {
|
||||
var bucketAggs = $scope.target.bucketAggs;
|
||||
|
||||
$scope.orderByOptions = [];
|
||||
$scope.bucketAggTypes = queryDef.bucketAggTypes;
|
||||
$scope.orderOptions = queryDef.orderOptions;
|
||||
$scope.sizeOptions = queryDef.sizeOptions;
|
||||
|
||||
$scope.getBucketAggTypes = function() {
|
||||
return queryDef.bucketAggTypes;
|
||||
};
|
||||
|
||||
$scope.getOrderOptions = function() {
|
||||
return queryDef.orderOptions;
|
||||
};
|
||||
|
||||
$scope.getSizeOptions = function() {
|
||||
return queryDef.sizeOptions;
|
||||
};
|
||||
|
||||
$rootScope.onAppEvent('elastic-query-updated', function() {
|
||||
$scope.validateModel();
|
||||
$scope.updateOrderByOptions();
|
||||
}, $scope);
|
||||
|
||||
$scope.init = function() {
|
||||
@@ -166,11 +174,10 @@ function (angular, _, queryDef) {
|
||||
|
||||
$scope.toggleOptions = function() {
|
||||
$scope.showOptions = !$scope.showOptions;
|
||||
$scope.updateOrderByOptions();
|
||||
};
|
||||
|
||||
$scope.updateOrderByOptions = function() {
|
||||
$scope.orderByOptions = queryDef.getOrderByOptions($scope.target);
|
||||
$scope.getOrderByOptions = function() {
|
||||
return queryDef.getOrderByOptions($scope.target);
|
||||
};
|
||||
|
||||
$scope.getFieldsInternal = function() {
|
||||
|
||||
@@ -5,8 +5,22 @@
|
||||
<span ng-hide="isFirst">Then by</span>
|
||||
</label>
|
||||
|
||||
<metric-segment-model property="agg.type" options="bucketAggTypes" on-change="onTypeChanged()" custom="false" css-class="width-10"></metric-segment-model>
|
||||
<metric-segment-model ng-if="agg.field" property="agg.field" get-options="getFieldsInternal()" on-change="onChange()" css-class="width-12"></metric-segment-model>
|
||||
<gf-form-dropdown model="agg.type"
|
||||
lookup-text="true"
|
||||
get-options="getBucketAggTypes()"
|
||||
on-change="onTypeChanged()"
|
||||
allow-custom="false"
|
||||
label-mode="true"
|
||||
css-class="width-10">
|
||||
</gf-form-dropdown>
|
||||
<gf-form-dropdown ng-if="agg.field"
|
||||
model="agg.field"
|
||||
get-options="getFieldsInternal()"
|
||||
on-change="onChange()"
|
||||
allow-custom="false"
|
||||
label-mode="true"
|
||||
css-class="width-12">
|
||||
</gf-form-dropdown>
|
||||
</div>
|
||||
|
||||
<div class="gf-form gf-form--grow">
|
||||
@@ -33,7 +47,13 @@
|
||||
<div ng-if="agg.type === 'date_histogram'">
|
||||
<div class="gf-form offset-width-7">
|
||||
<label class="gf-form-label width-10">Interval</label>
|
||||
<metric-segment-model property="agg.settings.interval" get-options="getIntervalOptions()" on-change="onChangeInternal()" css-class="width-12" custom="true"></metric-segment-model>
|
||||
<gf-form-dropdown model="agg.settings.interval"
|
||||
get-options="getIntervalOptions()"
|
||||
on-change="onChangeInternal()"
|
||||
allow-custom="true"
|
||||
label-mode="true"
|
||||
css-class="width-12">
|
||||
</gf-form-dropdown>
|
||||
</div>
|
||||
|
||||
<div class="gf-form offset-width-7">
|
||||
@@ -66,11 +86,23 @@
|
||||
<div ng-if="agg.type === 'terms'">
|
||||
<div class="gf-form offset-width-7">
|
||||
<label class="gf-form-label width-10">Order</label>
|
||||
<metric-segment-model property="agg.settings.order" options="orderOptions" on-change="onChangeInternal()" css-class="width-12"></metric-segment-model>
|
||||
<gf-form-dropdown model="agg.settings.order"
|
||||
lookup-text="true"
|
||||
get-options="getOrderOptions()"
|
||||
on-change="onChangeInternal()"
|
||||
label-mode="true"
|
||||
css-class="width-12">
|
||||
</gf-form-dropdown>
|
||||
</div>
|
||||
<div class="gf-form offset-width-7">
|
||||
<label class="gf-form-label width-10">Size</label>
|
||||
<metric-segment-model property="agg.settings.size" options="sizeOptions" on-change="onChangeInternal()" css-class="width-12"></metric-segment-model>
|
||||
<gf-form-dropdown model="agg.settings.size"
|
||||
lookup-text="true"
|
||||
get-options="getSizeOptions()"
|
||||
on-change="onChangeInternal()"
|
||||
label-mode="true"
|
||||
css-class="width-12">
|
||||
</gf-form-dropdown>
|
||||
</div>
|
||||
<div class="gf-form offset-width-7">
|
||||
<label class="gf-form-label width-10">Min Doc Count</label>
|
||||
@@ -78,7 +110,13 @@
|
||||
</div>
|
||||
<div class="gf-form offset-width-7">
|
||||
<label class="gf-form-label width-10">Order By</label>
|
||||
<metric-segment-model property="agg.settings.orderBy" options="orderByOptions" on-change="onChangeInternal()" css-class="width-12"></metric-segment-model>
|
||||
<gf-form-dropdown model="agg.settings.orderBy"
|
||||
lookup-text="true"
|
||||
get-options="getOrderByOptions()"
|
||||
on-change="onChangeInternal()"
|
||||
label-mode="true"
|
||||
css-class="width-12">
|
||||
</gf-form-dropdown>
|
||||
</div>
|
||||
<div class="gf-form offset-width-7">
|
||||
<label class="gf-form-label width-10">
|
||||
|
||||
@@ -31,11 +31,11 @@ export class ElasticQueryCtrl extends QueryCtrl {
|
||||
|
||||
queryUpdated() {
|
||||
var newJson = angular.toJson(this.datasource.queryBuilder.build(this.target), true);
|
||||
if (newJson !== this.rawQueryOld) {
|
||||
this.rawQueryOld = newJson;
|
||||
if (this.rawQueryOld && newJson !== this.rawQueryOld) {
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
this.rawQueryOld = newJson;
|
||||
this.$rootScope.appEvent('elastic-query-updated');
|
||||
}
|
||||
|
||||
|
||||
@@ -207,15 +207,20 @@ function pushToXBuckets(buckets, point, bucketNum, seriesName) {
|
||||
}
|
||||
|
||||
function pushToYBuckets(buckets, bucketNum, value, point, bounds) {
|
||||
var count = 1;
|
||||
// Use the 3rd argument as scale/count
|
||||
if (point.length > 2) {
|
||||
count = parseInt(point[2]);
|
||||
}
|
||||
if (buckets[bucketNum]) {
|
||||
buckets[bucketNum].values.push(value);
|
||||
buckets[bucketNum].count += 1;
|
||||
buckets[bucketNum].count += count;
|
||||
} else {
|
||||
buckets[bucketNum] = {
|
||||
y: bucketNum,
|
||||
bounds: bounds,
|
||||
values: [value],
|
||||
count: 1,
|
||||
count: count,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user