|
|
@@ -29,10 +29,16 @@ export class StackdriverAggregationCtrl {
|
|
|
constructor(private $scope, private templateSrv) {
|
|
|
this.$scope.ctrl = this;
|
|
|
this.target = $scope.target;
|
|
|
- this.alignmentPeriods = alignmentPeriods.map(ap => ({
|
|
|
- ...ap,
|
|
|
- label: ap.text,
|
|
|
- }));
|
|
|
+ this.alignmentPeriods = [
|
|
|
+ {
|
|
|
+ label: 'Alignment Periods',
|
|
|
+ expanded: true,
|
|
|
+ options: alignmentPeriods.map(ap => ({
|
|
|
+ ...ap,
|
|
|
+ label: ap.text,
|
|
|
+ })),
|
|
|
+ },
|
|
|
+ ];
|
|
|
this.setAggOptions();
|
|
|
this.setAlignOptions();
|
|
|
const self = this;
|
|
|
@@ -46,28 +52,43 @@ export class StackdriverAggregationCtrl {
|
|
|
}
|
|
|
|
|
|
setAlignOptions() {
|
|
|
- this.alignOptions = getAlignmentOptionsByMetric(this.target.valueType, this.target.metricKind).map(a => ({
|
|
|
+ const alignOptions = getAlignmentOptionsByMetric(this.target.valueType, this.target.metricKind).map(a => ({
|
|
|
...a,
|
|
|
label: a.text,
|
|
|
}));
|
|
|
- if (!this.alignOptions.find(o => o.value === this.templateSrv.replace(this.target.aggregation.perSeriesAligner))) {
|
|
|
- this.target.aggregation.perSeriesAligner = this.alignOptions.length > 0 ? this.alignOptions[0].value : '';
|
|
|
+ if (!alignOptions.find(o => o.value === this.templateSrv.replace(this.target.aggregation.perSeriesAligner))) {
|
|
|
+ this.target.aggregation.perSeriesAligner = alignOptions.length > 0 ? alignOptions[0].value : '';
|
|
|
}
|
|
|
+ this.alignOptions = [
|
|
|
+ {
|
|
|
+ label: 'Alignment Options',
|
|
|
+ expanded: true,
|
|
|
+ options: alignOptions,
|
|
|
+ },
|
|
|
+ ];
|
|
|
}
|
|
|
|
|
|
setAggOptions() {
|
|
|
- this.aggOptions = getAggregationOptionsByMetric(this.target.valueType, this.target.metricKind).map(a => ({
|
|
|
+ let aggOptions = getAggregationOptionsByMetric(this.target.valueType, this.target.metricKind).map(a => ({
|
|
|
...a,
|
|
|
label: a.text,
|
|
|
}));
|
|
|
- if (!this.aggOptions.find(o => o.value === this.templateSrv.replace(this.target.aggregation.crossSeriesReducer))) {
|
|
|
+ if (!aggOptions.find(o => o.value === this.templateSrv.replace(this.target.aggregation.crossSeriesReducer))) {
|
|
|
this.deselectAggregationOption('REDUCE_NONE');
|
|
|
}
|
|
|
|
|
|
if (this.target.aggregation.groupBys.length > 0) {
|
|
|
- this.aggOptions = this.aggOptions.filter(o => o.value !== 'REDUCE_NONE');
|
|
|
+ aggOptions = aggOptions.filter(o => o.value !== 'REDUCE_NONE');
|
|
|
this.deselectAggregationOption('REDUCE_NONE');
|
|
|
}
|
|
|
+
|
|
|
+ this.aggOptions = [
|
|
|
+ {
|
|
|
+ label: 'Aggregation Options',
|
|
|
+ expanded: true,
|
|
|
+ options: aggOptions,
|
|
|
+ },
|
|
|
+ ];
|
|
|
}
|
|
|
|
|
|
handleAlignmentChange(value) {
|