mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
stackdriver: remove not needed alignment option
This commit is contained in:
parent
92f50ca384
commit
a7897575b9
@ -16,19 +16,6 @@ export enum ValueTypes {
|
||||
}
|
||||
|
||||
export const alignOptions = [
|
||||
{
|
||||
text: 'none',
|
||||
value: 'ALIGN_NONE',
|
||||
valueTypes: [
|
||||
ValueTypes.INT64,
|
||||
ValueTypes.DOUBLE,
|
||||
ValueTypes.MONEY,
|
||||
ValueTypes.DISTRIBUTION,
|
||||
ValueTypes.BOOL,
|
||||
ValueTypes.STRING,
|
||||
],
|
||||
metricKinds: [MetricKind.GAUGE, MetricKind.DELTA, MetricKind.CUMULATIVE, MetricKind.METRIC_KIND_UNSPECIFIED],
|
||||
},
|
||||
{
|
||||
text: 'delta',
|
||||
value: 'ALIGN_DELTA',
|
||||
|
@ -3,7 +3,7 @@
|
||||
<label class="gf-form-label query-keyword width-9">Aggregation</label>
|
||||
<div class="gf-form-select-wrapper gf-form-select-wrapper--caret-indent">
|
||||
<select class="gf-form-input width-12" ng-model="target.aggregation.crossSeriesReducer" ng-options="f.value as f.text for f in aggOptions"
|
||||
ng-change="onAggregationChange(target.aggregation.crossSeriesReducer)"></select>
|
||||
ng-change="refresh()"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form gf-form--grow">
|
||||
@ -21,7 +21,7 @@
|
||||
<label class="gf-form-label query-keyword width-12">Aligner</label>
|
||||
<div class="gf-form-select-wrapper gf-form-select-wrapper--caret-indent">
|
||||
<select class="gf-form-input width-14" ng-model="target.aggregation.perSeriesAligner" ng-options="f.value as f.text for f in alignOptions"
|
||||
ng-change="onAlignmentChange(target.aggregation.perSeriesAligner)"></select>
|
||||
ng-change="refresh()"></select>
|
||||
</div>
|
||||
|
||||
<div class="gf-form gf-form--grow">
|
||||
|
@ -24,32 +24,10 @@ export class StackdriverAggregationCtrl {
|
||||
this.setAggOptions();
|
||||
this.setAlignOptions();
|
||||
$scope.alignmentPeriods = options.alignmentPeriods;
|
||||
$scope.onAlignmentChange = this.onAlignmentChange.bind(this);
|
||||
$scope.onAggregationChange = this.onAggregationChange.bind(this);
|
||||
$scope.formatAlignmentText = this.formatAlignmentText.bind(this);
|
||||
$scope.$on('metricTypeChanged', this.setAlignOptions.bind(this));
|
||||
}
|
||||
|
||||
onAlignmentChange(newVal: string) {
|
||||
if (newVal === 'ALIGN_NONE') {
|
||||
this.$scope.target.aggregation.crossSeriesReducer = 'REDUCE_NONE';
|
||||
}
|
||||
this.$scope.refresh();
|
||||
}
|
||||
|
||||
onAggregationChange(newVal: string) {
|
||||
if (newVal !== 'REDUCE_NONE' && this.$scope.target.aggregation.perSeriesAligner === 'ALIGN_NONE') {
|
||||
const newAlignmentOption = options.alignOptions.find(
|
||||
o =>
|
||||
o.value !== 'ALIGN_NONE' &&
|
||||
o.valueTypes.indexOf(this.$scope.target.valueType) !== -1 &&
|
||||
o.metricKinds.indexOf(this.$scope.target.metricKind) !== -1
|
||||
);
|
||||
this.$scope.target.aggregation.perSeriesAligner = newAlignmentOption ? newAlignmentOption.value : '';
|
||||
}
|
||||
this.$scope.refresh();
|
||||
}
|
||||
|
||||
setAlignOptions() {
|
||||
this.$scope.alignOptions = !this.$scope.target.valueType
|
||||
? []
|
||||
@ -60,8 +38,8 @@ export class StackdriverAggregationCtrl {
|
||||
);
|
||||
});
|
||||
if (!this.$scope.alignOptions.find(o => o.value === this.$scope.target.aggregation.perSeriesAligner)) {
|
||||
const newValue = this.$scope.alignOptions.find(o => o.value !== 'ALIGN_NONE');
|
||||
this.$scope.target.aggregation.perSeriesAligner = newValue ? newValue.value : '';
|
||||
this.$scope.target.aggregation.perSeriesAligner =
|
||||
this.$scope.alignOptions.length > 0 ? this.$scope.alignOptions[0].value : '';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,34 +29,5 @@ describe('StackdriverAggregationCtrl', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when a user selects ALIGN_NONE and a reducer is selected', () => {
|
||||
beforeEach(async () => {
|
||||
ctrl = new StackdriverAggregationCtrl({
|
||||
$on: () => {},
|
||||
refresh: () => {},
|
||||
target: { aggregation: { crossSeriesReducer: 'RANDOM_REDUCER' } },
|
||||
});
|
||||
ctrl.onAlignmentChange('ALIGN_NONE');
|
||||
});
|
||||
it('should set REDUCE_NONE as selected aggregation', () => {
|
||||
expect(ctrl.$scope.target.aggregation.crossSeriesReducer).toBe('REDUCE_NONE');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when a user a user select a reducer and no alignment is selected', () => {
|
||||
beforeEach(async () => {
|
||||
ctrl = new StackdriverAggregationCtrl({
|
||||
$on: () => {},
|
||||
refresh: () => {},
|
||||
target: { aggregation: { crossSeriesReducer: 'REDUCE_NONE', perSeriesAligner: 'ALIGN_NONE' } },
|
||||
});
|
||||
ctrl.onAggregationChange('ALIGN_NONE');
|
||||
});
|
||||
|
||||
it('should set an alignment', () => {
|
||||
expect(ctrl.$scope.target.aggregation.perSeriesAligner).not.toBe('ALIGN_NONE');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user