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:
@@ -9,18 +9,10 @@ import { Observable } from 'rxjs/Observable';
|
|||||||
export class PlotService {
|
export class PlotService {
|
||||||
|
|
||||||
plotTypes: Array<PlotType>;
|
plotTypes: Array<PlotType>;
|
||||||
|
|
||||||
tagFields: Array<TagField>;
|
|
||||||
|
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient) {
|
||||||
this.plotTypes = new Array<PlotType>();
|
this.plotTypes = new Array<PlotType>();
|
||||||
this.plotTypes.push(new PlotType(
|
this.plotTypes.push(new PlotType("SCATTER","Scatter","scatter-chart2",true,DataType.Time,DataType.Duration));
|
||||||
"SCATTER",
|
|
||||||
"Scatter",
|
|
||||||
"scatter-chart2",
|
|
||||||
true,
|
|
||||||
DataType.Time,
|
|
||||||
DataType.Duration));
|
|
||||||
this.plotTypes.push(new PlotType("HEATMAP", "Heatmap", "heatmap", false, DataType.Other, DataType.Other));
|
this.plotTypes.push(new PlotType("HEATMAP", "Heatmap", "heatmap", false, DataType.Other, DataType.Other));
|
||||||
this.plotTypes.push(new PlotType("CONTOUR", "Contour", "contour-chart", false, DataType.Time, DataType.Duration));
|
this.plotTypes.push(new PlotType("CONTOUR", "Contour", "contour-chart", false, DataType.Time, DataType.Duration));
|
||||||
this.plotTypes.push(new PlotType("CUM_DISTRIBUTION", "Cumulative Distribution", "cumulative-distribution-chart", true, DataType.Percent, DataType.Duration));
|
this.plotTypes.push(new PlotType("CUM_DISTRIBUTION", "Cumulative Distribution", "cumulative-distribution-chart", true, DataType.Percent, DataType.Duration));
|
||||||
@@ -33,8 +25,6 @@ export class PlotService {
|
|||||||
this.plotTypes.push(new PlotType("PIE", "Pie", "pie-chart", false, DataType.Other, DataType.Other));
|
this.plotTypes.push(new PlotType("PIE", "Pie", "pie-chart", false, DataType.Other, DataType.Other));
|
||||||
this.plotTypes.push(new PlotType("BAR", "Bar", "bar-chart", false, DataType.Other, DataType.Other));
|
this.plotTypes.push(new PlotType("BAR", "Bar", "bar-chart", false, DataType.Other, DataType.Other));
|
||||||
this.plotTypes.push(new PlotType("STEP_FIT", "Step Fit", "step-fit", false, DataType.Other, DataType.Other));
|
this.plotTypes.push(new PlotType("STEP_FIT", "Step Fit", "step-fit", false, DataType.Other, DataType.Other));
|
||||||
|
|
||||||
this.tagFields = new Array<TagField>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -45,16 +35,8 @@ export class PlotService {
|
|||||||
return this.plotTypes.filter(plotType => plotType.active);
|
return this.plotTypes.filter(plotType => plotType.active);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTagFields(): Array<TagField> {
|
getTagFields(): Observable<Array<string>> {
|
||||||
const that = this;
|
return this.http.get<Array<string>>('//'+window.location.hostname+':8080/fields');
|
||||||
this.http.get('//'+window.location.hostname+':8080/fields').subscribe(data => {
|
|
||||||
if (data instanceof Array){
|
|
||||||
data.forEach(function(name) {
|
|
||||||
that.tagFields.push(new TagField(name));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return this.tagFields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
autocomplete(query: string, caretIndex: number): Observable<AutocompleteResult>
|
autocomplete(query: string, caretIndex: number): Observable<AutocompleteResult>
|
||||||
@@ -72,6 +54,10 @@ export class PlotService {
|
|||||||
console.log("send plot request: "+ JSON.stringify(plotRequest));
|
console.log("send plot request: "+ JSON.stringify(plotRequest));
|
||||||
return this.http.post<PlotResponse>('//'+window.location.hostname+':8080/plots', plotRequest);
|
return this.http.post<PlotResponse>('//'+window.location.hostname+':8080/plots', plotRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFilterDefaults(): Observable<FilterDefaults>{
|
||||||
|
return this.http.get<FilterDefaults>('//'+window.location.hostname+':8080/filters/defaults')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -181,3 +167,7 @@ export class DataSeriesStats {
|
|||||||
plottedValues : number;
|
plottedValues : number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class FilterDefaults {
|
||||||
|
groupBy: Array<string>;
|
||||||
|
fields: Array<string>;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
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 { Observable } from 'rxjs/Observable';
|
||||||
import { FormControl, Validators } from '@angular/forms';
|
import { FormControl, Validators } from '@angular/forms';
|
||||||
import { LimitByComponent } from '../limit-by/limit-by.component';
|
import { LimitByComponent } from '../limit-by/limit-by.component';
|
||||||
import { YAxisRangeComponent } from '../y-axis-range/y-axis-range.component';
|
import { YAxisRangeComponent } from '../y-axis-range/y-axis-range.component';
|
||||||
import { QueryAutocompleteComponent } from '../query-autocomplete/query-autocomplete.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';
|
import * as moment from 'moment';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -27,9 +27,9 @@ export class VisualizationPageComponent implements OnInit {
|
|||||||
selectedCombinePlotType = new FormControl('');
|
selectedCombinePlotType = new FormControl('');
|
||||||
combinePlotTypes: Array<any>;
|
combinePlotTypes: Array<any>;
|
||||||
|
|
||||||
tagFields: Array<any>;
|
tagFields: Array<TagField> = new Array<TagField>();
|
||||||
|
|
||||||
groupBy: Array<any> = [];
|
groupBy = new Array<TagField>();
|
||||||
|
|
||||||
@ViewChild(LimitByComponent, {static: false})
|
@ViewChild(LimitByComponent, {static: false})
|
||||||
private limitbycomponent : LimitByComponent;
|
private limitbycomponent : LimitByComponent;
|
||||||
@@ -62,7 +62,14 @@ export class VisualizationPageComponent implements OnInit {
|
|||||||
|
|
||||||
this.combinePlotTypes = this.getCombinablePlotTypes(this.selectedPlotType.value);
|
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.yAxisScale = "LOG10";
|
||||||
|
|
||||||
this.selectedPlotType.valueChanges.subscribe(function(selectedMainPlotType){
|
this.selectedPlotType.valueChanges.subscribe(function(selectedMainPlotType){
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -29,6 +31,7 @@ import org.lucares.pdb.plot.api.PlotSettings;
|
|||||||
import org.lucares.pdbui.domain.AutocompleteProposal;
|
import org.lucares.pdbui.domain.AutocompleteProposal;
|
||||||
import org.lucares.pdbui.domain.AutocompleteProposalByValue;
|
import org.lucares.pdbui.domain.AutocompleteProposalByValue;
|
||||||
import org.lucares.pdbui.domain.AutocompleteResponse;
|
import org.lucares.pdbui.domain.AutocompleteResponse;
|
||||||
|
import org.lucares.pdbui.domain.FilterDefaults;
|
||||||
import org.lucares.pdbui.domain.PlotRequest;
|
import org.lucares.pdbui.domain.PlotRequest;
|
||||||
import org.lucares.pdbui.domain.PlotResponse;
|
import org.lucares.pdbui.domain.PlotResponse;
|
||||||
import org.lucares.pdbui.domain.PlotResponseStats;
|
import org.lucares.pdbui.domain.PlotResponseStats;
|
||||||
@@ -76,8 +79,11 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
|||||||
@Value("${" + PRODUCTION_MODE + ":true}")
|
@Value("${" + PRODUCTION_MODE + ":true}")
|
||||||
private boolean modeProduction;
|
private boolean modeProduction;
|
||||||
|
|
||||||
@Value("${"+QUERY_EXAMPLES+":}")
|
@Value("${"+DEFAULTS_QUERY_EXAMPLES+":}")
|
||||||
private String queryExamples;
|
private String queryExamples;
|
||||||
|
|
||||||
|
@Value("${"+DEFAULTS_GROUP_BY+":}")
|
||||||
|
private String defaultsGroupBy;
|
||||||
|
|
||||||
public PdbController(final PerformanceDb db, final Plotter plotter) {
|
public PdbController(final PerformanceDb db, final Plotter plotter) {
|
||||||
this.db = db;
|
this.db = db;
|
||||||
@@ -292,6 +298,17 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
|||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(path = "/filters/defaults", //
|
||||||
|
method = RequestMethod.GET, //
|
||||||
|
produces = MediaType.APPLICATION_JSON_VALUE //
|
||||||
|
)
|
||||||
|
@ResponseBody
|
||||||
|
public FilterDefaults getFilterDefaults() {
|
||||||
|
Set<String> groupBy = defaultsGroupBy.isBlank() ? Set.of() : Set.of(defaultsGroupBy.split("\\s*,\\s*"));
|
||||||
|
List<String> fields = fields();
|
||||||
|
return new FilterDefaults(fields, groupBy);
|
||||||
|
}
|
||||||
|
|
||||||
private List<AutocompleteProposal> toAutocompleteProposals(final List<Proposal> proposals) {
|
private List<AutocompleteProposal> toAutocompleteProposals(final List<Proposal> proposals) {
|
||||||
|
|
||||||
|
|||||||
@@ -18,5 +18,7 @@ public interface PropertyKeys {
|
|||||||
*/
|
*/
|
||||||
String PRODUCTION_MODE = "mode.production";
|
String PRODUCTION_MODE = "mode.production";
|
||||||
|
|
||||||
String QUERY_EXAMPLES = "query.examples";
|
String DEFAULTS_QUERY_EXAMPLES = "defaults.query.examples";
|
||||||
|
|
||||||
|
String DEFAULTS_GROUP_BY = "defaults.groupBy";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package org.lucares.pdbui.domain;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class FilterDefaults {
|
||||||
|
private Set<String> groupBy;
|
||||||
|
|
||||||
|
private List<String> fields;
|
||||||
|
|
||||||
|
public FilterDefaults(final List<String> fields, final Set<String> groupBy) {
|
||||||
|
this.fields = new ArrayList<String>(fields);
|
||||||
|
this.groupBy = new HashSet<String>(groupBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getGroupBy() {
|
||||||
|
return new HashSet<String>(groupBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupBy(Set<String> groupBy) {
|
||||||
|
this.groupBy = new HashSet<String>(groupBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getFields() {
|
||||||
|
return new ArrayList<String>(fields);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFields(List<String> fields) {
|
||||||
|
this.fields = new ArrayList<String>(fields);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user