make defaults for groupBy configurable

We do not know which fields exist at compile time.
But it is a great help to have some pre-selected
fields in groupBy.
Solved by adding a configuration option.
This commit is contained in:
2019-11-10 09:38:16 +01:00
parent c83d0a3e1e
commit 198b51089d
5 changed files with 78 additions and 29 deletions

View File

@@ -1,11 +1,11 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { PlotService, PlotType, PlotRequest, PlotResponse } from '../plot.service';
import { PlotService, PlotType, PlotRequest, PlotResponse, TagField, FilterDefaults } from '../plot.service';
import { Observable } from 'rxjs/Observable';
import { FormControl, Validators } from '@angular/forms';
import { LimitByComponent } from '../limit-by/limit-by.component';
import { YAxisRangeComponent } from '../y-axis-range/y-axis-range.component';
import { QueryAutocompleteComponent } from '../query-autocomplete/query-autocomplete.component';
import {PlotViewComponent, SelectionRange, DateAnchor } from '../plot-view/plot-view.component'
import {PlotViewComponent, SelectionRange, DateAnchor} from '../plot-view/plot-view.component'
import * as moment from 'moment';
@Component({
@@ -27,9 +27,9 @@ export class VisualizationPageComponent implements OnInit {
selectedCombinePlotType = new FormControl('');
combinePlotTypes: Array<any>;
tagFields: Array<any>;
tagFields: Array<TagField> = new Array<TagField>();
groupBy: Array<any> = [];
groupBy = new Array<TagField>();
@ViewChild(LimitByComponent, {static: false})
private limitbycomponent : LimitByComponent;
@@ -62,7 +62,14 @@ export class VisualizationPageComponent implements OnInit {
this.combinePlotTypes = this.getCombinablePlotTypes(this.selectedPlotType.value);
this.tagFields = this.plotService.getTagFields();
that.plotService.getFilterDefaults().subscribe(function(filterDefaults) {
filterDefaults.fields.forEach(function(name) {
that.tagFields.push(new TagField(name));
});
that.groupBy = that.tagFields.filter(val => filterDefaults.groupBy.includes(val.name));
});
this.yAxisScale = "LOG10";
this.selectedPlotType.valueChanges.subscribe(function(selectedMainPlotType){