Skip to content

Commit c497bba

Browse files
committed
Fixes #5
1 parent 4d2b02c commit c497bba

File tree

7 files changed

+20
-17
lines changed

7 files changed

+20
-17
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>de.rwth.idsg</groupId>
55
<artifactId>steve</artifactId>
6-
<version>1.0.6</version>
6+
<version>1.0.7</version>
77
<packaging>jar</packaging>
88

99
<developers>

src/main/java/de/rwth/idsg/steve/web/controller/AjaxCallController.java

+14-11
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import org.springframework.beans.factory.annotation.Autowired;
88
import org.springframework.http.MediaType;
99
import org.springframework.stereotype.Controller;
10+
import org.springframework.web.bind.annotation.PathVariable;
1011
import org.springframework.web.bind.annotation.RequestMapping;
1112
import org.springframework.web.bind.annotation.RequestMethod;
12-
import org.springframework.web.bind.annotation.RequestParam;
1313
import org.springframework.web.bind.annotation.ResponseBody;
1414

1515
import java.util.List;
@@ -20,7 +20,10 @@
2020
*/
2121
@Controller
2222
@ResponseBody
23-
@RequestMapping(value = "/manager/ajax", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
23+
@RequestMapping(
24+
value = "/manager/ajax/{chargeBoxId}",
25+
method = RequestMethod.GET,
26+
produces = MediaType.APPLICATION_JSON_VALUE)
2427
public class AjaxCallController {
2528

2629
@Autowired private ChargePointRepository chargePointRepository;
@@ -31,32 +34,32 @@ public class AjaxCallController {
3134
// Paths
3235
// -------------------------------------------------------------------------
3336

34-
private static final String CP_DETAILS_PATH = "/getCPDetails";
35-
private static final String CONNECTOR_IDS_PATH = "/getConnectorIds";
36-
private static final String TRANSACTION_IDS_PATH = "/getTransactionIds";
37-
private static final String RESERVATION_IDS_PATH = "/getReservationIds";
37+
private static final String DETAILS_PATH = "/details";
38+
private static final String CONNECTOR_IDS_PATH = "/connectorIds";
39+
private static final String TRANSACTION_IDS_PATH = "/transactionIds";
40+
private static final String RESERVATION_IDS_PATH = "/reservationIds";
3841

3942
// -------------------------------------------------------------------------
4043
// HTTP methods
4144
// -------------------------------------------------------------------------
4245

43-
@RequestMapping(value = CP_DETAILS_PATH)
44-
public ChargePoint getCPDetails(@RequestParam String chargeBoxId) {
46+
@RequestMapping(value = DETAILS_PATH)
47+
public ChargePoint getDetails(@PathVariable("chargeBoxId") String chargeBoxId) {
4548
return chargePointRepository.getChargePointDetails(chargeBoxId);
4649
}
4750

4851
@RequestMapping(value = CONNECTOR_IDS_PATH)
49-
public List<Integer> getConnectorIds(@RequestParam String chargeBoxId) {
52+
public List<Integer> getConnectorIds(@PathVariable("chargeBoxId") String chargeBoxId) {
5053
return chargePointRepository.getConnectorIds(chargeBoxId);
5154
}
5255

5356
@RequestMapping(value = TRANSACTION_IDS_PATH)
54-
public List<Integer> getTransactionIds(@RequestParam String chargeBoxId) {
57+
public List<Integer> getTransactionIds(@PathVariable("chargeBoxId") String chargeBoxId) {
5558
return transactionRepository.getActiveTransactionIds(chargeBoxId);
5659
}
5760

5861
@RequestMapping(value = RESERVATION_IDS_PATH)
59-
public List<Integer> getReservationIds(@RequestParam String chargeBoxId) {
62+
public List<Integer> getReservationIds(@PathVariable("chargeBoxId") String chargeBoxId) {
6063
return reservationRepository.getActiveReservationIds(chargeBoxId);
6164
}
6265

src/main/resources/webapp/static/js/snippets/getCPDetails.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ $(document).ready(function() {
22
$("#gdb").click(function() {
33
var ddiv = $("#details-div");
44
ddiv.html("<br>Loading...");
5-
$.getJSON("/steve/manager/ajax/getCPDetails?chargeBoxId=" + $("#cbi").val(), function(data) {
5+
$.getJSON("/steve/manager/ajax/" + $("#cbi").val() + "/details", function(data) {
66
ddiv.html("<table id='details' class='cpd'><thead><tr><th>Charge Point Details</th><th></th></tr></thead></table>");
77
var table = $("#details");
88
$.each(data, function(key, val) {

src/main/resources/webapp/static/js/snippets/getConnectorIds.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
$("#chargePointSelectList").change(function() {
22
var cp = $(this).find("option:selected").text();
3-
$.getJSON("/steve/manager/ajax/getConnectorIds?chargeBoxId=" + cp, function(data) {
3+
$.getJSON("/steve/manager/ajax/" + cp + "/connectorIds", function(data) {
44
var options = "";
55
$.each(data, function() {
66
options += "<option value='" + this + "'>" + this + "</option>";

src/main/resources/webapp/static/js/snippets/getConnectorIdsZeroAllowed.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
$("#chargePointSelectList").change(function() {
22
var cp = $(this).find("option:selected").text();
3-
$.getJSON("/steve/manager/ajax/getConnectorIds?chargeBoxId=" + cp, function(data) {
3+
$.getJSON("/steve/manager/ajax/" + cp + "/connectorIds", function(data) {
44
var options = "<option value='0'>Not for a specific connector</option>";
55
$.each(data, function() {
66
options += "<option value='" + this + "'>" + this + "</option>";

src/main/resources/webapp/static/js/snippets/getReservationIds.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
$("#chargePointSelectList").change(function() {
22
var cp = $(this).find("option:selected").text();
3-
$.getJSON("/steve/manager/ajax/getReservationIds?chargeBoxId=" + cp, function(data) {
3+
$.getJSON("/steve/manager/ajax/" + cp + "/reservationIds", function(data) {
44
var options = "";
55
$.each(data, function() {
66
options += "<option value='" + this + "'>" + this + "</option>";

src/main/resources/webapp/static/js/snippets/getTransactionIds.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
$("#chargePointSelectList").change(function() {
22
var cp = $(this).find("option:selected").text();
3-
$.getJSON("/steve/manager/ajax/getTransactionIds?chargeBoxId=" + cp, function(data) {
3+
$.getJSON("/steve/manager/ajax/" + cp + "/transactionIds", function(data) {
44
var options = "";
55
$.each(data, function() {
66
options += "<option value='" + this + "'>" + this + "</option>";

0 commit comments

Comments
 (0)