Commit efc3def7 by Torkel Ödegaard

feat(elasticsearch): small refactoring and polish

parent 6c304924
......@@ -173,11 +173,12 @@ function (angular, app, _, $) {
$scope.valueToSegment = function(value) {
var option = _.findWhere($scope.options, {value: value});
if (option) {
return uiSegmentSrv.newSegment({value: option.text, cssClass: attrs.cssClass, custom: attrs.custom});
} else {
return uiSegmentSrv.newSegment({value: value, cssClass: attrs.cssClass, custom: attrs.custom});
}
var segment = {
cssClass: attrs.cssClass,
custom: attrs.custom,
value: option ? option.text : value,
};
return uiSegmentSrv.newSegment(segment);
};
$scope.getOptionsInternal = function() {
......
......@@ -54,7 +54,7 @@ function (angular, _, queryDef) {
$scope.settingsLinkText += ' (' + $scope.agg.order + ')';
}
} else if ($scope.agg.type === 'date_histogram') {
delete $scope.agg.field;
$scope.agg.field = $scope.target.timeField;
}
return true;
......
......@@ -7,10 +7,10 @@
<li>
<metric-segment-model property="agg.type" options="bucketAggTypes" on-change="onChangeInternal()" custom="false" css-class="tight-form-item-large"></metric-segment-model>
</li>
<li ng-if="agg.field">
<li>
<metric-segment-model property="agg.field" get-options="getFields()" on-change="onChangeInternal()" css-class="tight-form-item-xxlarge"></metric-segment>
</li>
<li class="tight-form-item tight-form-align" ng-if="settingsLinkText">
<li class="tight-form-item last" ng-if="settingsLinkText">
<a ng-click="toggleOptions()">{{settingsLinkText}}</a>
</li>
</ul>
......@@ -27,7 +27,7 @@
</div>
<div class="tight-form" ng-if="showOptions">
<div style="margin: 20px 0 20px 148px;display: inline-block">
<div style="tight-form-inner-box" ng-if="agg.type === 'terms'">
<div class="tight-form">
<ul class="tight-form-list">
<li class="tight-form-item" style="width: 60px">
......
......@@ -9,7 +9,7 @@
<li ng-if="agg.type !== 'count'">
<metric-segment-model property="agg.field" get-options="getFields()" on-change="onChange()" css-class="tight-form-item-xxlarge"></metric-segment>
</li>
<li class="tight-form-item tight-form-align" ng-if="settingsLinkText">
<li class="tight-form-item last" ng-if="settingsLinkText">
<a ng-click="toggleOptions()">{{settingsLinkText}}</a>
</li>
</ul>
......
......@@ -15,6 +15,7 @@ function (angular, _) {
target.metrics = target.metrics || [{ type: 'count', id: '1' }];
target.bucketAggs = target.bucketAggs || [{ type: 'date_histogram', id: '2'}];
target.timeField = $scope.datasource.timeField;
};
$scope.getFields = function() {
......
......@@ -213,3 +213,8 @@ select.tight-form-input {
.tight-form-item-large { width: 115px; }
.tight-form-item-xlarge { width: 150px; }
.tight-form-item-xxlarge { width: 200px; }
.tight-form-inner-box {
margin: 20px 0 20px 148px;
display: inline-block;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment