diff --git a/src/main/java/Team5/SmartTowns/dragonstale/DragonsTale.java b/src/main/java/Team5/SmartTowns/dragonstale/DragonsTale.java new file mode 100644 index 0000000000000000000000000000000000000000..c83257f683812efd8633eeb2fdfc78dafe973777 --- /dev/null +++ b/src/main/java/Team5/SmartTowns/dragonstale/DragonsTale.java @@ -0,0 +1,19 @@ +package Team5.SmartTowns.dragonstale; + +import Team5.SmartTowns.landmarks.Landmarks; + +import java.util.List; + +public class DragonsTale { + Landmarks landmarks = new Landmarks(); + private int landmarkID = landmarks.getLandmarkID(); + private String landmarkName = landmarks.getLandmarkName(); + private String landmarkDescription = landmarks.getLandmarkDescription(); + public static List<Landmarks> landmarksDragonstrail = List.of( + 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") + ); + public static List<Landmarks> getLandmarksDragonstrail() { + return landmarksDragonstrail; + } +} diff --git a/src/main/java/Team5/SmartTowns/dragonstale/DragonsTaleController.java b/src/main/java/Team5/SmartTowns/dragonstale/DragonsTaleController.java new file mode 100644 index 0000000000000000000000000000000000000000..9066b1239a40d42aeaca7293c05a37529b5eaff5 --- /dev/null +++ b/src/main/java/Team5/SmartTowns/dragonstale/DragonsTaleController.java @@ -0,0 +1,60 @@ +package Team5.SmartTowns.dragonstale; + +import Team5.SmartTowns.landmarks.Landmarks; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.ModelAndView; + +import java.util.List; + +import static Team5.SmartTowns.dragonstale.DragonsTale.landmarksDragonstrail; + + + +@RestController + +public class DragonsTaleController { + ModelAndView modelAndView; + + @GetMapping("/dragonstale") + public ModelAndView getDragonsTale(){ + List<Landmarks> landmarksList = landmarksDragonstrail; + int landmarksListSize = landmarksDragonstrail.size(); + modelAndView = new ModelAndView("/dragonstale/index") + .addObject("landmarksList", landmarksList) + .addObject("getListSize", landmarksListSize); + return modelAndView; + } + + @GetMapping ("/QRScan") //In here, we could use trailID as a string variable and use it to track what trail the user clicked from. + public ModelAndView getQRScanner(){ + modelAndView = new ModelAndView("fragments/qr-scanner"); + //Can we extract the pathvariable in a JS function? + return modelAndView; + } + +// @GetMapping("/dragonstale/{landmarkID}") +// public Integer getDTLandmarkID(@RequestParam(value="landmarkID") int landmark){ +// Integer idCounter = 0; +// modelAndView = new ModelAndView("/dragonstale/{landmarkID}") +// .addObject() //All your doing is retrieving the information from the database giving it to a string variable. +// } + + //Create another controller that directs to the given DragonsTale..Trail.. and updates the users account accordingly. + +// This code is to be used +// @GetMapping("dragonstale/{qrCode}/{id}") +// public String qrCodeCheck(@PathVariable Optional<String> qrCode, @PathVariable Optional<Integer> id){ +// if (qrCode.isPresent()){ +// +// //Check if ID is present, if do this, if not dfo that. +// +// } +// } + + + +} diff --git a/src/main/java/Team5/SmartTowns/dragonstale/DragonsTaleJDBC.java b/src/main/java/Team5/SmartTowns/dragonstale/DragonsTaleJDBC.java new file mode 100644 index 0000000000000000000000000000000000000000..f87b13aa37b413b9bb284b7cb14b6924b0aad75c --- /dev/null +++ b/src/main/java/Team5/SmartTowns/dragonstale/DragonsTaleJDBC.java @@ -0,0 +1,30 @@ +package Team5.SmartTowns.dragonstale; + +import Team5.SmartTowns.users.User; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DragonsTaleJDBC implements DragonsTaleRepository{ + private JdbcTemplate jdbc; + + private RowMapper<User> userMapper; + +// @Override +// public Map<Long, Boolean> getDTCompletion(int landmarkID){ +// //Be conscious of sql injections here. +// String sql = "SELECT userid, trailID, completedOrNot FROM dtprogress WHERE landmarkID = ?"; +// int dtQuery = jdbc.query(sql, landmarkID); +// //Query it twice to extract the given parameters, then use these parameters in a loop to query the completion. +// List<Map<String, Integer>> query = jdbc.query(sql, id); +// +// Map<Long, Boolean> dtProgress = new HashMap<>(); +// for (Map<String, Object> result : dtQuery) { +// dtProgress.put((Long)result.get("stickerID"), (boolean)result.get("hasSticker")); +// } +// return dtProgress; +// } +} diff --git a/src/main/java/Team5/SmartTowns/dragonstale/DragonsTaleRepository.java b/src/main/java/Team5/SmartTowns/dragonstale/DragonsTaleRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..1439cfb9f4b389221c3c6e923b5b654fcb271421 --- /dev/null +++ b/src/main/java/Team5/SmartTowns/dragonstale/DragonsTaleRepository.java @@ -0,0 +1,4 @@ +package Team5.SmartTowns.dragonstale; + +public interface DragonsTaleRepository { +} diff --git a/src/main/java/Team5/SmartTowns/trails/TrailsController.java b/src/main/java/Team5/SmartTowns/trails/TrailsController.java index c6472019b4e17f3ff6aa4c60188ad524bfc10010..3b99af4fbf1b4dba80625e50525d6c70300fdaba 100644 --- a/src/main/java/Team5/SmartTowns/trails/TrailsController.java +++ b/src/main/java/Team5/SmartTowns/trails/TrailsController.java @@ -11,8 +11,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import static Team5.SmartTowns.landmarks.Landmarks.landmarksDragonstrail; - //import static Team5.SmartTowns.Landmarks.Landmarks.landmarksDragonstrail; @Controller @@ -38,24 +36,5 @@ public class TrailsController { return mv; } - @GetMapping("/dragonstale") - public ModelAndView getDragonsTale(){ - List<Landmarks> landmarksList = landmarksDragonstrail; - ModelAndView modelAndView = new ModelAndView("towns/trails/dragonstale/index"); - modelAndView.addObject("landmarksList", landmarksList); - return modelAndView; - } - - - // -// @GetMapping("dragonstale/{qrCode}/{id}") -// public String qrCodeCheck(@PathVariable Optional<String> qrCode, @PathVariable Optional<Integer> id){ -// if (qrCode.isPresent()){ -// -// //Check if ID is present, if do this, if not dfo that. -// -// } -// } - } diff --git a/src/main/resources/static/css/dragonstaless.css b/src/main/resources/static/css/dragonstaless.css index 2f456a23299e5296a53d8c37f48d93345fe84a9a..2a0ecb3566ffa4d3e5a839c51d051423ba63f132 100644 --- a/src/main/resources/static/css/dragonstaless.css +++ b/src/main/resources/static/css/dragonstaless.css @@ -1,4 +1,4 @@ -.centre{ +body{ display: flex; flex-direction: column; text-align: center; @@ -8,6 +8,36 @@ background-color: #927BB7; } +.dropdown button{ + background-color: coral; + color: white; + padding: 25px; + font-size: 16px; + border: none; + cursor: pointer; +} + + +.dropdown .content{ + display: none; + position: absolute; + background-color: #D3B69C; + min-width:100px; + box-shadow: white; + z-index: 1; +} + +.dropdown:hover .content{ + display: block; +} + + +.images{ + max-width:100%; + height:auto; +} + + .landmarkName{ font-weight: bold; text-align: left; diff --git a/src/main/resources/static/qr-scanner.html b/src/main/resources/static/qr-scanner.html deleted file mode 100644 index 2e93c18b5decfdb0f2b2f3e390e87dd9a8600661..0000000000000000000000000000000000000000 --- a/src/main/resources/static/qr-scanner.html +++ /dev/null @@ -1,29 +0,0 @@ -<!--setup html page for QR codes - R Nute--> -<!--Modified from (https://www.geeksforgeeks.org/create-a-qr-code-scanner-or-reader-in-html-css-javascript/)--> - -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8"> - <meta name="viewpoint" content="width-device-width, initial-scale=1.0"> - <link rel="stylesheet" href="css/templatingstyle.css"> - <link rel="stylesheet" href="css/qrstyle.css"> - <script src="https://unpkg.com/html5-qrcode"></script> - <script type="module" src="scripts/qr-script.js"></script> - <title>QR Code</title> -</head> - -<body> - <header th:insert="towns/Templating.html :: header"></header> - - <div class="container"> - <h1>Scan location QR code</h1> - <div class="section"> - <div id="qr-code-reader"> - </div> - </div> - </div> - - <div th:insert="towns/Templating.html :: footer"></div> -</body> -</html> diff --git a/src/main/resources/static/scripts/DTscript.js b/src/main/resources/static/scripts/DTscript.js new file mode 100644 index 0000000000000000000000000000000000000000..b791445e69d24655e244294b57dfd72d71ce15c6 --- /dev/null +++ b/src/main/resources/static/scripts/DTscript.js @@ -0,0 +1,9 @@ +var getQR = function (){ + // document.getElementById("qrCodeScanner").style.cursor = "pointer"; + window.location.href = "/QRScan"; +} + +function toggleDropDown(){ + var dropdownList = document.getElementById("dropdownList") + dropdownList.style.display = (dropdownList.style.display === "block") ? "none" : "block" +} \ No newline at end of file diff --git a/src/main/resources/static/scripts/qrCode.js b/src/main/resources/static/scripts/qrCode.js deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/main/resources/templates/dragonstale/index.html b/src/main/resources/templates/dragonstale/index.html new file mode 100644 index 0000000000000000000000000000000000000000..1745a9e2362b790850def159561e9b9d38a22c0f --- /dev/null +++ b/src/main/resources/templates/dragonstale/index.html @@ -0,0 +1,53 @@ +<!DOCTYPE html> +<html lang="en"> +<html xmlns:th="http://www.thymeleaf.org"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>A Dragon's Tale</title> + <link rel="stylesheet" th:href="@{/css/dragonstaless.css}"> + <link rel="stylesheet" th:href="@{/css/templatingstyle.css}"> + <script type="text/javascript" th:src="@{/scripts/DTscript.js}"></script> +</head> + <body> + <header th:insert="fragments/Templating.html :: header"></header> + <!-- As this predefined trail will be accessible from multiple different towns, this thymeleaf element will display the town the user is currently trying to access and display it accordingly. <span th:text="${townName}"> --> + <div> + <h1> Welcome, to a dragon's tale! </h1> + <img th:src="@{/images/trails/dragonstalehome.png}" alt="Image of a dragon" class="images"> + <h2> Discover the mystery of the dragon, track its location and follow it throughout the town of to discover a prize! </h2> + </div> + + <div> + <p> + Adventurers... embark through mystical historical landmarks to ultimately discover the lair of the dragon. + Legend has it that within this ominous lair, mighty dragons, guardians of ancient wisdom and treasures untold lay.... + </p> + </div> + + + <div class="dropdown"> + <button class="dropdownButton" onclick="toggleDropDown()" >There are <span th:text="${getListSize}"> Size of List </span> adventures in this journey! </button> + <ul id="dropdownList"> + <li class="content" th:each="item : ${landmarksList}"> + <a class="option" href="#landmarkTabLink" th:text="${item.landmarkName}"> Landmark Tab</a> + <button class="option" id="qrCodeScanner" onclick="getQR()">Click here to scan a QR code for: <span th:text="${item.landmarkName}">Landmark Name Here</span></button> + </li> + </ul> + </div> + + + <!-- Need to mark each element to an ID then loop through them. --> + <!-- <div id="listOfLandmarks">--> + <!-- <p th:each="item : ${landmarksList}">--> + <!-- <span th:text="${item.landmarkDescription}" class="landmarkDesc" id="landmarkTabLink"> Landmark Description</span>--> + <!-- </p>--> + <!-- </div>--> + + <div> + <h3> Begin or Continue your hunt!</h3> + <button type="button" id="begin">Click here!</button> + </div> + <div th:insert="fragments/Templating.html :: footer"></div> + </body> +</html> \ No newline at end of file diff --git a/src/main/resources/templates/fragments/qr-scanner.html b/src/main/resources/templates/fragments/qr-scanner.html new file mode 100644 index 0000000000000000000000000000000000000000..509c40efa6095d4f3e159fac6f0f60cea278a17f --- /dev/null +++ b/src/main/resources/templates/fragments/qr-scanner.html @@ -0,0 +1,27 @@ +<!--setup html page for QR codes - R Nute--> +<!--Modified from (https://www.geeksforgeeks.org/create-a-qr-code-scanner-or-reader-in-html-css-javascript/)--> + +<!DOCTYPE html> +<html lang="en"> +<html xmlns:th="http://www.thymeleaf.org"> + <head> + <meta charset="UTF-8"> + <meta name="viewpoint" content="width-device-width, initial-scale=1.0"> + <link rel="stylesheet" href="/css/templatingstyle.css"> + <link rel="stylesheet" href="/css/qrstyle.css"> + <script src="https://unpkg.com/html5-qrcode"></script> + <script type="module" src="/scripts/qr-script.js"></script> + <title>QR Code</title> + </head> + + <body> + <div th:fragment="qrCode" class="container"> + <h1>Scan location QR code</h1> + <div class="section"> + <div id="qr-code-reader"> + </div> + </div> + </div> + + </body> +</html> diff --git a/src/main/resources/templates/towns/trails/dragonstale/index.html b/src/main/resources/templates/towns/trails/dragonstale/index.html deleted file mode 100644 index 7cf5948e993116ac247cf9c8aaac3d1ece2e8762..0000000000000000000000000000000000000000 --- a/src/main/resources/templates/towns/trails/dragonstale/index.html +++ /dev/null @@ -1,62 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<html xmlns:th="http://www.thymeleaf.org"> - <meta charset="UTF-8"> - <title>A Dragon's Tale</title> - <link rel="stylesheet" th:href="@{/css/dragonstaless.css}"> - <link rel="stylesheet" th:href="@{/css/templatingstyle.css}"> - <script src="./node_modules/html5-qrcode/html5-qrcode.min.js"></script> -</head> - <body> - <header th:insert="fragments/Templating.html :: header"></header> - - <!-- As this predefined trail will be accessible from multiple different towns, this thymeleaf element will display the town the user is currently trying to access and display it accordingly. <span th:text="${townName}"> --> - <div class="centre"> - <h1> Welcome, to a dragon's tale! </h1> - <img th:src="@{/images/trails/dragonstalehome.png}" alt="Image of a dragon" id="homeimg"> - <h2> Discover the mystery of the dragon, track its location and follow it throughout the town of to discover a prize! </h2> - </div> - - <div class="centre"> - <p> - Adventurers... embark through mystical historical landmarks to ultimately discover the lair of the dragon. - Legend has it that within this ominous lair, mighty dragons, guardians of ancient wisdom and treasures untold lay.... - </p> - </div> - - - <!-- tabs --> - <div class="centre"> - <h2>There are <span th:text="${getListSize}"> Size of List </span> adventures in this journey! </h2> - <ul th:each="item : ${landmarksList}" id="tabBox"> - <li> - <a id="tabIdCounter" href="#landmarkTabLink" th:text="${item.landmarkName}"> Landmark Tab</a> - </li> - </ul> - </div> - - - <!-- Need to mark each element to an ID then loop through them. --> - <div class="centre" id="listOfLandmarks"> - <p th:each="item : ${landmarksList}"> - <span th:text="${item.landmarkDescription}" class="landmarkDesc" id="landmarkTabLink"> Landmark Description</span> - </p> - </div> - - <!-- If use is starting their journey, this will display begin. If not, they'll continue their journey. <span th:text="${beginOrContinue}"> --> - <div class="centre"> - <h3> Begin or Continue your hunt!</h3> - <button type="button" id="begin">Click here!</button> - </div> - - <div th:insert="fragments/Templating.html :: footer"></div> - - <script> - - document.getElementById("begin").addEventListener("click", function (){ - window.location.href = ("/dragonstale/landmarkone"); - }) - - </script> - </body> -</html> \ No newline at end of file diff --git a/src/main/resources/templates/towns/trails/dragonstale/script.js b/src/main/resources/templates/towns/trails/dragonstale/script.js deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000