From a7897575b941e07766b8fc9ce87bcd464b3ad660 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Thu, 27 Sep 2018 14:43:30 +0200 Subject: [PATCH] stackdriver: remove not needed alignment option --- .../datasource/stackdriver/constants.ts | 13 --------- .../partials/query.aggregation.html | 4 +-- .../stackdriver/query_aggregation_ctrl.ts | 26 ++--------------- .../specs/query_aggregation_ctrl.test.ts | 29 ------------------- 4 files changed, 4 insertions(+), 68 deletions(-) diff --git a/public/app/plugins/datasource/stackdriver/constants.ts b/public/app/plugins/datasource/stackdriver/constants.ts index 30fec1396f1..78586a06309 100644 --- a/public/app/plugins/datasource/stackdriver/constants.ts +++ b/public/app/plugins/datasource/stackdriver/constants.ts @@ -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', diff --git a/public/app/plugins/datasource/stackdriver/partials/query.aggregation.html b/public/app/plugins/datasource/stackdriver/partials/query.aggregation.html index 1f1386741e3..3bf57606367 100755 --- a/public/app/plugins/datasource/stackdriver/partials/query.aggregation.html +++ b/public/app/plugins/datasource/stackdriver/partials/query.aggregation.html @@ -3,7 +3,7 @@
+ ng-change="refresh()">
@@ -21,7 +21,7 @@
+ ng-change="refresh()">
diff --git a/public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts b/public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts index 1afb464bc12..30089588da6 100644 --- a/public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts +++ b/public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts @@ -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 : ''; } } diff --git a/public/app/plugins/datasource/stackdriver/specs/query_aggregation_ctrl.test.ts b/public/app/plugins/datasource/stackdriver/specs/query_aggregation_ctrl.test.ts index efc935dd338..d3a20deed77 100644 --- a/public/app/plugins/datasource/stackdriver/specs/query_aggregation_ctrl.test.ts +++ b/public/app/plugins/datasource/stackdriver/specs/query_aggregation_ctrl.test.ts @@ -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'); - }); - }); }); });