fetch possible values for gallery view
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Injectable, OnInit } from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
|
||||
@Injectable({
|
||||
@@ -39,12 +40,13 @@ export class PlotService {
|
||||
return this.http.get<Array<string>>('//'+window.location.hostname+':8080/fields');
|
||||
}
|
||||
|
||||
autocomplete(query: string, caretIndex: number): Observable<AutocompleteResult>
|
||||
autocomplete(query: string, caretIndex: number, resultMode: ResultMode): Observable<AutocompleteResult>
|
||||
{
|
||||
const options = {
|
||||
params: new HttpParams()
|
||||
.set('caretIndex', ""+caretIndex)
|
||||
.set('query', query)
|
||||
.set('query', query)
|
||||
.set('resultMode', resultMode)
|
||||
};
|
||||
return this.http.get<AutocompleteResult>('//'+window.location.hostname+':8080/autocomplete', options);
|
||||
}
|
||||
@@ -58,6 +60,16 @@ export class PlotService {
|
||||
getFilterDefaults(): Observable<FilterDefaults>{
|
||||
return this.http.get<FilterDefaults>('//'+window.location.hostname+':8080/filters/defaults')
|
||||
}
|
||||
|
||||
splitQuery(query: string, splitBy:string) : Observable<Array<string>>{
|
||||
|
||||
const q = "("+query+") and "+splitBy+"=";
|
||||
return this.autocomplete(q, q.length+1, ResultMode.FULL_VALUES).pipe(
|
||||
map(
|
||||
autocompleteResult => autocompleteResult.proposals.map(suggestion => suggestion.value)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -172,3 +184,8 @@ export class FilterDefaults {
|
||||
fields: Array<string>;
|
||||
splitBy: string;
|
||||
}
|
||||
|
||||
export enum ResultMode {
|
||||
CUT_AT_DOT = "CUT_AT_DOT",
|
||||
FULL_VALUES = "FULL_VALUES"
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import {FormControl} from '@angular/forms';
|
||||
import {Observable} from 'rxjs';
|
||||
import {startWith, map} from 'rxjs/operators';
|
||||
import {MatAutocompleteTrigger } from '@angular/material/autocomplete';
|
||||
import { PlotService, PlotType, AutocompleteResult, Suggestion } from '../plot.service';
|
||||
import { PlotService, PlotType, AutocompleteResult, Suggestion, ResultMode } from '../plot.service';
|
||||
|
||||
@Component({
|
||||
selector: 'pdb-query-autocomplete',
|
||||
@@ -64,7 +64,7 @@ export class QueryAutocompleteComponent implements OnInit {
|
||||
: this.queryField.value.newQuery;
|
||||
|
||||
this.plotService
|
||||
.autocomplete(query, caretIndex)
|
||||
.autocomplete(query, caretIndex, ResultMode.CUT_AT_DOT)
|
||||
.subscribe(
|
||||
(data: AutocompleteResult) => {// success path
|
||||
//console.log(JSON.stringify(data.proposals));
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
*ngIf="enableGallery"
|
||||
mat-button
|
||||
matTooltip="Create Gallery"
|
||||
(click)="plot()"
|
||||
(click)="gallery()"
|
||||
[disabled]="this.splitBy == null">
|
||||
<img src="assets/img/four-squares-line.svg" class="icon-inline" aria-hidden="true" title="Create Gallery (only active if 'Split' is set)" />
|
||||
Gallery
|
||||
|
||||
@@ -90,6 +90,18 @@ export class VisualizationPageComponent implements OnInit {
|
||||
dateRangeAsString() : string {
|
||||
return (<HTMLInputElement>document.getElementById("search-date-range")).value;
|
||||
}
|
||||
|
||||
gallery(){
|
||||
const that = this;
|
||||
this.plotService.splitQuery(this.query.query, this.splitBy.name).subscribe(function(valuesForSplitBy){
|
||||
console.log("valuesForSplitBy: " + JSON.stringify(valuesForSplitBy));
|
||||
that.plotView.errorMessage = '';
|
||||
},
|
||||
error => {
|
||||
that.plotView.imageUrl = '';
|
||||
that.plotView.errorMessage = error.error.message;
|
||||
});
|
||||
}
|
||||
|
||||
plot(){
|
||||
const that = this;
|
||||
|
||||
@@ -17,7 +17,7 @@ public class XAxisTimeTicks {
|
||||
|
||||
int widthInPx = settings.getWidth() - GnuplotSettings.GNUPLOT_LEFT_RIGHT_MARGIN;
|
||||
|
||||
final long maxLabels = widthInPx / (GnuplotSettings.TICKS_FONT_SIZE * 8);
|
||||
final long maxLabels = Math.max(1, widthInPx / (GnuplotSettings.TICKS_FONT_SIZE * 8));
|
||||
|
||||
final long tickIncrement = roundToTickIncrement(rangeInMs / maxLabels);
|
||||
|
||||
|
||||
@@ -225,13 +225,14 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
)
|
||||
@ResponseBody
|
||||
AutocompleteResponse autocomplete(@RequestParam(name = "query") final String query,
|
||||
@RequestParam(name = "caretIndex") final int caretIndex) {
|
||||
@RequestParam(name = "caretIndex") final int caretIndex,
|
||||
@RequestParam(name="resultMode", defaultValue = "CUT_AT_DOT") ResultMode resultMode) {
|
||||
|
||||
// TODO get date range from UI
|
||||
final DateTimeRange dateRange = DateTimeRange.max();
|
||||
final int zeroBasedCaretIndex = caretIndex - 1;
|
||||
final QueryWithCaretMarker q = new QueryWithCaretMarker(query, dateRange, zeroBasedCaretIndex,
|
||||
ResultMode.CUT_AT_DOT);
|
||||
resultMode);
|
||||
|
||||
final AutocompleteResponse result = new AutocompleteResponse();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user