make it possible to specify the time in the range
This commit is contained in:
@@ -2,9 +2,13 @@ package org.lucares.pdbui;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.lucares.ludb.FieldNotExistsException;
|
||||
import org.lucares.ludb.Proposal;
|
||||
@@ -23,12 +27,14 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
@Controller
|
||||
@EnableAutoConfiguration
|
||||
@@ -36,6 +42,9 @@ public class PdbController implements HardcodedValues, CollectionUtils {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PdbController.class);
|
||||
|
||||
private static final DateTimeFormatter DATE_FORMAT_BEGIN = DateTimeFormatter.ofPattern("yyyy-MM-dd 00:00:00");
|
||||
private static final DateTimeFormatter DATE_FORMAT_END = DateTimeFormatter.ofPattern("yyyy-MM-dd 23:59:59");
|
||||
|
||||
private final Plotter plotter;
|
||||
private final PdbRepository db;
|
||||
|
||||
@@ -44,6 +53,15 @@ public class PdbController implements HardcodedValues, CollectionUtils {
|
||||
this.plotter = plotter;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public ModelAndView index() {
|
||||
final String view = "main";
|
||||
final Map<String, Object> model = new HashMap<>();
|
||||
model.put("oldestValue", LocalDateTime.now().minusYears(1).format(DATE_FORMAT_BEGIN));
|
||||
model.put("latestValue", LocalDateTime.now().format(DATE_FORMAT_END));
|
||||
return new ModelAndView(view, model);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/plots", //
|
||||
method = RequestMethod.POST, //
|
||||
consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, //
|
||||
|
||||
@@ -66,7 +66,7 @@ function renderGroupBy()
|
||||
|
||||
};
|
||||
var error = function(e) {
|
||||
$('#result-view').text("FAILED: " + JSON.stringify(e));
|
||||
$('#result-view').text("FAILED: " + JSON.parse(e.responseText).message);
|
||||
};
|
||||
|
||||
|
||||
@@ -78,7 +78,6 @@ 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>");
|
||||
}
|
||||
|
||||
|
||||
function plot(event){
|
||||
event.preventDefault(); // prevent submit of form which would reload the page
|
||||
|
||||
@@ -104,11 +103,10 @@ function plot(event){
|
||||
$('#result-view').text("No data points found.");
|
||||
}
|
||||
else{
|
||||
$('#result-view').text("FAILED: " + JSON.stringify(e));
|
||||
$('#result-view').text("FAILED: " + JSON.parse(e.responseText).message);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
postJson("plots", request, success, error);
|
||||
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
<input type="number" id="search-limit-value" name="search-limit-value" min="1" max="1000" value="10"/>
|
||||
|
||||
<label for="search-date-from">From Date:</label>
|
||||
<input id="search-date-from" class="input_date" type="date">
|
||||
<input id="search-date-from" class="input_date" type="text" value="{{oldestValue}}">
|
||||
|
||||
<label for="search-date-to">To Date:</label>
|
||||
<input id="search-date-to" class="input_date" type="date">
|
||||
<input id="search-date-to" class="input_date" type="text" value="{{latestValue}}">
|
||||
|
||||
<button id="search-submit"><i class="fa fa-area-chart"> Plot</i></button>
|
||||
</div>
|
||||
Reference in New Issue
Block a user