limit the number of plots
This commit is contained in:
@@ -7,6 +7,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.lucares.ludb.Proposal;
|
||||
import org.lucares.pdb.plot.api.PlotSettings;
|
||||
import org.lucares.pdbui.domain.AutocompleteProposal;
|
||||
import org.lucares.pdbui.domain.AutocompleteProposalByValue;
|
||||
import org.lucares.pdbui.domain.AutocompleteResponse;
|
||||
@@ -46,12 +47,10 @@ public class PdbController implements HardcodedValues, CollectionUtils {
|
||||
PlotResponse createPlot(@RequestBody final PlotRequest request) {
|
||||
|
||||
try {
|
||||
final String query = request.getQuery();
|
||||
final int height = request.getHeight();
|
||||
final int width = request.getWidth();
|
||||
|
||||
System.out.println(query);
|
||||
final File image = plotter.plot(query, height, width, request.getGroupBy());
|
||||
final PlotSettings plotSettings = PlotSettingsTransformer.toSettings(request);
|
||||
|
||||
final File image = plotter.plot(plotSettings);
|
||||
|
||||
final Path relativeImagePath = plotter.getOutputDir().relativize(image.toPath());
|
||||
return new PlotResponse(WEB_IMAGE_OUTPUT_PATH + "/" + relativeImagePath.toString());
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.lucares.pdbui;
|
||||
|
||||
import org.lucares.pdb.plot.api.Limit;
|
||||
import org.lucares.pdb.plot.api.PlotSettings;
|
||||
import org.lucares.pdbui.domain.LimitBy;
|
||||
import org.lucares.pdbui.domain.PlotRequest;
|
||||
|
||||
class PlotSettingsTransformer {
|
||||
static PlotSettings toSettings(final PlotRequest request) {
|
||||
|
||||
final PlotSettings result = new PlotSettings();
|
||||
|
||||
result.setQuery(request.getQuery());
|
||||
result.setGroupBy(request.getGroupBy());
|
||||
result.setHeight(request.getHeight());
|
||||
result.setWidth(request.getWidth());
|
||||
result.setLimit(request.getLimit());
|
||||
result.setLimitBy(toLimit(request.getLimitBy()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Limit toLimit(final LimitBy limitBy) {
|
||||
switch (limitBy) {
|
||||
case NO_LIMIT:
|
||||
return Limit.NO_LIMIT;
|
||||
case FEWEST_VALUES:
|
||||
return Limit.FEWEST_VALUES;
|
||||
case MOST_VALUES:
|
||||
return Limit.MOST_VALUES;
|
||||
default:
|
||||
throw new IllegalStateException("unhandled enum: " + limitBy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package org.lucares.pdbui.domain;
|
||||
|
||||
public enum LimitBy {
|
||||
NO_LIMIT, MOST_VALUES, FEWEST_VALUES
|
||||
}
|
||||
@@ -9,6 +9,10 @@ public class PlotRequest {
|
||||
|
||||
private String groupBy;
|
||||
|
||||
private LimitBy limitBy = LimitBy.NO_LIMIT;
|
||||
|
||||
private int limit = Integer.MAX_VALUE;
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
@@ -45,4 +49,20 @@ public class PlotRequest {
|
||||
public void setGroupBy(final String groupBy) {
|
||||
this.groupBy = groupBy;
|
||||
}
|
||||
|
||||
public LimitBy getLimitBy() {
|
||||
return limitBy;
|
||||
}
|
||||
|
||||
public void setLimitBy(final LimitBy limitBy) {
|
||||
this.limitBy = limitBy;
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public void setLimit(final int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
content: "\f1c5"
|
||||
}
|
||||
|
||||
.fa-area-chart:before {
|
||||
content: "\f1fe"
|
||||
}
|
||||
|
||||
.fa-icons:before {
|
||||
content: "\f002";
|
||||
}
|
||||
@@ -21,7 +21,15 @@
|
||||
data-autocomplete-empty-message="nothing found" />
|
||||
</div>
|
||||
<label for="search-group-by">Group By:</label> <select id="search-group-by"></select>
|
||||
<button id="search-submit"><i class="fa fa-file-image-o"> Plot</i></button>
|
||||
|
||||
<label for="search-limit-by">Limit By:</label>
|
||||
<select id="search-limit-by">
|
||||
<option value="NO_LIMIT" selected="selected">no limit</option>
|
||||
<option value="MOST_VALUES">most values</option>
|
||||
<option value="FEWEST_VALUES">fewest values</option>
|
||||
</select>
|
||||
<input type="number" id="search-limit-value" name="search-limit-value" min="1" max="1000000" value="10" style="display: none;"/>
|
||||
<button id="search-submit"><i class="fa fa-area-chart"> Plot</i></button>
|
||||
</div>
|
||||
<div id="result-view">
|
||||
</div>
|
||||
|
||||
@@ -5,6 +5,17 @@ $(document).ready(function(){
|
||||
|
||||
renderFields();
|
||||
|
||||
$('#search-limit-by').change(function () {
|
||||
var optionSelected = $(this).find("option:selected");
|
||||
var valueSelected = optionSelected.val();
|
||||
console.log(valueSelected);
|
||||
if (valueSelected == "NO_LIMIT"){
|
||||
$('#search-limit-value').hide();
|
||||
}else{
|
||||
$('#search-limit-value').show();
|
||||
}
|
||||
});
|
||||
|
||||
AutoComplete({
|
||||
HttpMethod: "GET",
|
||||
Delay: 300,
|
||||
@@ -69,9 +80,12 @@ function plot(event){
|
||||
showLoadingIcon();
|
||||
var request = {};
|
||||
request['query'] = $('#search-input').val();
|
||||
request['height'] = $('#result-view').height()-10;
|
||||
request['width'] = $('#result-view').width()-10;
|
||||
request['height'] = $('#result-view').height()-15;
|
||||
request['width'] = $('#result-view').width()-15;
|
||||
request['groupBy'] = $('#search-group-by').val();
|
||||
request['limitBy'] = $('#search-limit-by').val();
|
||||
request['limit'] = parseInt($('#search-limit-value').val());
|
||||
|
||||
|
||||
var success = function(response){
|
||||
|
||||
|
||||
Reference in New Issue
Block a user