group plots by a single field

This commit is contained in:
2016-12-30 18:45:01 +01:00
parent 62437f384f
commit c283568757
8 changed files with 125 additions and 24 deletions

View File

@@ -50,7 +50,7 @@ public class PdbController implements HardcodedValues, CollectionUtils {
final int width = request.getWidth();
System.out.println(query);
final File image = plotter.plot(query, height, width);
final File image = plotter.plot(query, height, width, request.getGroupBy());
final Path relativeImagePath = plotter.getOutputDir().relativize(image.toPath());
return new PlotResponse(WEB_IMAGE_OUTPUT_PATH + "/" + relativeImagePath.toString());
@@ -88,6 +88,26 @@ public class PdbController implements HardcodedValues, CollectionUtils {
}
}
@RequestMapping(path = "/fields", //
method = RequestMethod.GET, //
consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, //
produces = MediaType.APPLICATION_JSON_UTF8_VALUE //
)
@ResponseBody
List<String> fields() {
try {
final List<String> fields = db.getDb().getFields();
return fields;
} catch (final Exception e) {
e.printStackTrace();
throw new InternalServerError(e);
}
}
private List<AutocompleteProposal> toAutocompleteProposals(final List<Proposal> proposals) {
final List<AutocompleteProposal> result = new ArrayList<>();

View File

@@ -7,6 +7,8 @@ public class PlotRequest {
private int width;
private String groupBy;
public String getQuery() {
return query;
}
@@ -35,4 +37,12 @@ public class PlotRequest {
public String toString() {
return query + ":" + height + "x" + width;
}
public String getGroupBy() {
return groupBy;
}
public void setGroupBy(final String groupBy) {
this.groupBy = groupBy;
}
}

View File

@@ -20,6 +20,8 @@
<input id="search-input" data-autocomplete="autocomplete"
data-autocomplete-empty-message="nothing found" />
</div>
<div id="search-group-by">
</div>
<button id="search-submit"><i class="fa fa-search"> Search</i></button>
</div>
<div id="result-view">

View File

@@ -3,6 +3,8 @@ $(document).ready(function(){
$('#search-submit').click(plot);
initGroupBy();
AutoComplete({
HttpMethod: "GET",
Delay: 300,
@@ -27,6 +29,24 @@ $(document).ready(function(){
});
});
function initGroupBy()
{
var successCallback = function (response) {
response.forEach(function(item, index){
$('#search-group-by').append('<input type="radio" id="groupBy-'+index+'" name="groupBy" value="'+item+'" /><label for="groupBy-'+index+'">'+item+'</label>');
});
};
var errorCallback = function (){
$('#result-view').text("FAILED: " + JSON.stringify(e));
};
getJson("fields", {}, successCallback, errorCallback)
}
function showLoadingIcon()
{
$('#result-view').html("<div class='center'><div class='uil-cube-css' style='-webkit-transform:scale(0.41)'><div /><div></div><div></div><div></div></div></div>");
@@ -41,6 +61,7 @@ function plot(event){
request['query'] = $('#search-input').val();
request['height'] = $('#result-view').height()-10;
request['width'] = $('#result-view').width()-10;
request['groupBy'] = $('input[name=groupBy]:checked').val();
var success = function(response){
@@ -67,4 +88,15 @@ function postJson(url, requestData, successCallback, errorCallback) {
.fail(errorCallback);
}
function getJson(url, requestData, successCallback, errorCallback) {
$.ajax({
type: "GET",
url: url,
data: requestData,
contentType: 'application/json'
})
.done(successCallback)
.fail(errorCallback);
}