Skip to content
Snippets Groups Projects
Commit b1ad6c24 authored by Rhys Evans's avatar Rhys Evans
Browse files

Further work on trails webpage, links added to individual loation page

parent 98d03e94
No related branches found
No related tags found
1 merge request!40Resolve "As a user I would like to see a map containing all landmarks for a trail and a suggested path between them, so that I can easily follow the trail"
......@@ -11,7 +11,7 @@ public class Location {
private String locationEmail;
private String locationDescription;
private String locationPlace;
private int locationTrailID;
private String locationTrailID;
private boolean locationApproved;
......@@ -47,7 +47,7 @@ public class Location {
return locationPlace;
}
public int getLocationTrailID() {
public String getLocationTrailID() {
return locationTrailID;
}
......
......@@ -33,7 +33,7 @@ public class LocationRepositoryJDBC implements LocationRepository {
rs.getString("locationEmail"),
rs.getString("locationDescription"),
rs.getString("locationPlace"),
rs.getInt("locationTrailID"),
rs.getString("locationTrailID"),
rs.getBoolean("locationApproved")
);
}
......@@ -56,7 +56,7 @@ public class LocationRepositoryJDBC implements LocationRepository {
public void addLocation(Location loc) {
String sql = "insert into locations( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) values (?,?,?,?,?,?)";
jdbc.update(sql,loc.getLocationName(),loc.getLocationEmail(),loc.getLocationDescription(),loc.getLocationPlace(),loc.getLocationTrailID());
jdbc.update(sql,loc.getLocationName(),loc.getLocationEmail(),loc.getLocationDescription(),loc.getLocationPlace(),loc.getLocationTrailID(), false);
}
@Override
......
......@@ -18,7 +18,7 @@ public class TrailsRepositoryJDBC implements TrailsRepository {
private void settrailsMapper(){
trailMapper = (rs, i) -> new Trail(
rs.getString("trailID"),
rs.getString("name"),
rs.getString("trailName"),
rs.getString("trailNumber")
);
}
......
......@@ -20,7 +20,7 @@ public class Landmarks {
new Landmarks( 1, "A scent of...Dragon", "The Dragon has been spotted near by, find the QR code to continue" , "Start your discovery, at the sweet shop."),
new Landmarks( 2, "They've been found!", "Don't let them escape, find the next QR code to continue!", "Location test")
);
private Integer trailID;
private String trailID;
private int landmarkID;
@NotEmpty(message = "You must type in a username.")
private String landmarkName;
......
......@@ -2,6 +2,8 @@ package Team5.SmartTowns.placeswithcoordinates;
import Team5.SmartTowns.data.Location;
import Team5.SmartTowns.data.LocationRepository;
import Team5.SmartTowns.data.Trail;
import Team5.SmartTowns.data.TrailsRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
......@@ -22,7 +24,8 @@ public class PlacesController {
@Autowired
private LocationRepository locationRepo;
@Autowired
private TrailsRepository trailsRepo;
@GetMapping("/checkpoints")
......@@ -78,4 +81,28 @@ public class PlacesController {
/// Trail webpage mapping
@GetMapping("/trails")
public ModelAndView getTrailsPage(){
ModelAndView modelAndView = new ModelAndView("landmarks/trailsPage.html");
List<Trail> trailslocations = trailsRepo.getAllTrails();
List<Location> locations = locationRepo.getAllLocation();
List<LocationsCoordinates> locCoords = placeRepo.getAllLocationCoords();
List<Integer> locationIDIndex = new ArrayList<Integer>();
List<Location> locationCoordsWorkaround = new ArrayList<Location>();
for (LocationsCoordinates coord: locCoords){
locationIDIndex.add(coord.getLocationID()-1);
locationCoordsWorkaround.add(locations.get(coord.getLocationID()-1));
}
modelAndView.addObject("trails", trailslocations);
modelAndView.addObject("locations", locationCoordsWorkaround);
modelAndView.addObject("locationCoords", locCoords);
return modelAndView;
}
}
......@@ -42,7 +42,7 @@
<select th:field="*{trailID}">
<option value=0 hidden="true">Select Trail</option>
<option value=0 disabled selected>Select Trail</option>
<option value=0101>(Caerphilly) Castle Trail</option>
<option value=101>(Caerphilly) Castle Trail</option>
<option value=0102>(Caerphilly) Pub Trail</option>
<option value=0103>(Caerphilly) Heritage Trail</option>
<option value=0201>(Risca) Heritage and Culture Trail</option>
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Trails</title>
</head>
<body>
<main>
<div th:each="trail, indexValue:${trails}">
<H1 th:text="*{trail.getTrailName()}"></H1>
<div th:each="locationCoord, indexValue2:${locationCoords}" >
<div th:if="${locations[indexValue2.index].getLocationTrailID()==trail.getTrailsId()}">
<a th:href="'/checkpoints/'+${locations[indexValue2.index].getLocationName().replace(' ', '-')}" th:text="${locations[indexValue2.index].getLocationName()}"></a>
<p th:text="${locationCoord.getLocationCoordsLong()}"></p></div>
<!-- <div th:each="coord, indexValue:${locationCoords}">-->
<!-- <p th:text="*{coord.getLocationID()}"></p>-->
<!-- &lt;!&ndash; <p th:text="${locations[indexValue.index]}"></p>&ndash;&gt;-->
<!-- <H1 th:text="${location[indexValue.index].getLocationName()}"> </H1>-->
<!-- <H4 th:text="${location[indexValue.index].getLocationPlace()}"> </H4>-->
<!-- <p th:text="${location[indexValue.index].getLocationDescription()}"></p>-->
<!-- <div th:each="trail, indexValue:${trails}">-->
<!-- <H1 th:text="*{trail.getTrailName()}"></H1>-->
<!-- <div th:each="location, indexValue2:${locations}" th:each="locationCoord, indexValue3:${locationCoords}" th:if="!${location.getLocationTrailID()==trail.getTrailsId()}" >-->
<!-- <p th:text="${location.getLocationPlace()}">A</p>-->
<!-- <p th:text="${location[indexValue3.index].getLocationPlace()}">A</p>-->
<!-- <p th:text="${locationCoord.getLocationCoordsLong()}"></p>-->
</div>
</div>
</main>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment