Skip to content
Snippets Groups Projects
Commit b278ab25 authored by Connor Brock's avatar Connor Brock
Browse files

Refactored QRScanner code, added a controller to direct to the QRScanner and...

Refactored QRScanner code, added a controller to direct to the QRScanner and created a JS button to send the user to the QR url.
parent ddbaf371
No related branches found
No related tags found
1 merge request!41Resolve "As a convenience enthusiast, I want a drop down menu to be able to quickly scan QR codes I find along my dragon trail so that I may continue on my adventure without disruption."
......@@ -3,9 +3,12 @@ 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.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
import java.util.Optional;
import static Team5.SmartTowns.dragonstale.DragonsTale.landmarksDragonstrail;
......@@ -13,15 +16,33 @@ import static Team5.SmartTowns.dragonstale.DragonsTale.landmarksDragonstrail;
@Controller
public class DragonsTaleController {
ModelAndView modelAndView;
@GetMapping("/dragonstale")
public ModelAndView getDragonsTale(){
List<Landmarks> landmarksList = landmarksDragonstrail;
ModelAndView modelAndView = new ModelAndView("/dragonstale/index");
modelAndView = new ModelAndView("/dragonstale/index");
modelAndView.addObject("landmarksList", landmarksList);
return modelAndView;
}
@RequestMapping ("/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("qrCodeScanner/qr-scanner");
//Can we extract the pathvariable in a JS function?
return modelAndView;
}
// @GetMapping("/{trailID}/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(@PathVariable Optional<Integer> trailID){
// ModelAndView modelAndView = new ModelAndView("/dragonstale/index");
// //Can we extract the pathvariable in a JS function?
// return modelAndView;
// }
// @GetMapping("dragonstale/{qrCode}/{id}")
// public String qrCodeCheck(@PathVariable Optional<String> qrCode, @PathVariable Optional<Integer> id){
// if (qrCode.isPresent()){
......
<!--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>
document.getElementById("qrCodeScanner").addEventListener("click", function (){
window.location.href = "http://localhost:8080/QRScan";
})
\ No newline at end of file
<!--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 class="container">
<h1>Scan location QR code</h1>
<div class="section">
<div id="qr-code-reader">
</div>
</div>
</div>
</body>
</html>
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