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

@@ -9,18 +9,10 @@ import { Observable } from 'rxjs/Observable';
export class PlotService {
plotTypes: Array<PlotType>;
tagFields: Array<TagField>;
constructor(private http: HttpClient) {
this.plotTypes = new Array<PlotType>();
this.plotTypes.push(new PlotType(
"SCATTER",
"Scatter",
"scatter-chart2",
true,
DataType.Time,
DataType.Duration));
this.plotTypes.push(new PlotType("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("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));
@@ -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("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.tagFields = new Array<TagField>();
}
ngOnInit() {
@@ -45,16 +35,8 @@ export class PlotService {
return this.plotTypes.filter(plotType => plotType.active);
}
getTagFields(): Array<TagField> {
const that = this;
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;
getTagFields(): Observable<Array<string>> {
return this.http.get<Array<string>>('//'+window.location.hostname+':8080/fields');
}
autocomplete(query: string, caretIndex: number): Observable<AutocompleteResult>
@@ -72,6 +54,10 @@ export class PlotService {
console.log("send plot request: "+ JSON.stringify(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;
}
export class FilterDefaults {
groupBy: Array<string>;
fields: Array<string>;
}