Last result: {{ result }}
-Validating: {{ validating }}
-is Valid: {{ isValid }}
diff --git a/frontend/src/router/routes.js b/frontend/src/router/routes.js index 2d2b3fc..79fa81c 100644 --- a/frontend/src/router/routes.js +++ b/frontend/src/router/routes.js @@ -16,9 +16,9 @@ const routes = [ children: [{ path: "", component: () => import("pages/Cache.vue") }] }, { - path: "/qr-code-test/", + path: "/qr-scanner/", component: () => import("layouts/MyLayout.vue"), - children: [{ path: "", component: () => import("pages/qr-code-test.vue") }] + children: [{ path: "", component: () => import("pages/qr-scanner.vue") }] }, { path: "/cache/:id", @@ -31,10 +31,20 @@ const routes = [ children: [{ path: "", component: () => import("pages/StationEdit.vue") }] }, { - path: "/station-l/:pos", + path: "/endstation/", + component: () => import("layouts/MyLayout.vue"), + children: [{ path: "", component: () => import("pages/StationEndEdit.vue") }] + }, + { + path: "/tempstation/:pos", component: () => import("layouts/MyLayout.vue"), children: [{path: "", component: () => import("pages/StationEdit.vue")}] }, + { + path: "/tempendstation/", + component: () => import("layouts/MyLayout.vue"), + children: [{path: "", component: () => import("pages/StationEndEdit.vue")}] + }, { path: "/station/:cache/:id", component: () => import("layouts/MyLayout.vue"), @@ -55,6 +65,11 @@ const routes = [ component: () => import("layouts/MyLayout.vue"), children: [{ path: "", component: () => import("pages/CacheStart.vue") }] }, + { + path: "/CacheEnd/:cache/", + component: () => import("layouts/MyLayout.vue"), + children: [{ path: "", component: () => import("pages/CacheEnd.vue") }] + }, { path: "/profile/", component: () => import("layouts/MyLayout.vue"), diff --git a/frontend/src/store/cacheCollector/getters.js b/frontend/src/store/cacheCollector/getters.js index b2b2dbe..d2bea70 100644 --- a/frontend/src/store/cacheCollector/getters.js +++ b/frontend/src/store/cacheCollector/getters.js @@ -6,3 +6,7 @@ export const GET_TEMPSTATION = (state) => { console.log("GET_TEMPSTATION: retrieve cache from store. "); return state.tempStation; }; +export const GET_ENDSTATION = (state) => { + console.log("GET_ENDSTATION: retrieve cache from store. "); + return state.endStation; +}; diff --git a/frontend/src/store/cacheCollector/mutations.js b/frontend/src/store/cacheCollector/mutations.js index 383330d..72f58e1 100644 --- a/frontend/src/store/cacheCollector/mutations.js +++ b/frontend/src/store/cacheCollector/mutations.js @@ -6,6 +6,10 @@ export const SET_TEMPSTATION = (state, station) => { console.log("SET_TEMPSTATION: add new station to cache: "+station); state.tempStation = station; }; +export const SET_ENDSTATION = (state, station) => { + console.log("SET_ENDSTATION: "+station); + state.endStation = station; +}; export const ADD_STATION = (state, station) => { console.log("ADD_STATION: add new station to cache: "+station); state.newCache.stationen.push(station); @@ -29,6 +33,11 @@ export const RESET_NEW_CACHE = (state) => { rankingPoints: 0, stationen: [] }; + state.endStation = { + description: "Endstation", + longitude: 0.0001, + lattitude: 0.0001, + }; console.log("resetted new Cache"); }; export const LOAD_REMOTE_CACHE = (state, id) => { diff --git a/frontend/src/store/cacheCollector/state.js b/frontend/src/store/cacheCollector/state.js index 7087a3a..0f32de1 100644 --- a/frontend/src/store/cacheCollector/state.js +++ b/frontend/src/store/cacheCollector/state.js @@ -3,6 +3,7 @@ export default { name: "", description: "", rankingPoints: 0, + reward: "", stationen: [] }, // newCache: { @@ -41,4 +42,9 @@ export default { // ] // }, tempStation: {}, + endStation: { + description: "Endstation", + longitude: 9.206628, + lattitude: 49.147734, + }, } diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index 6cbad26..ac8fd0e 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -61,87 +61,88 @@ public class Controller { return ResponseEntity.status(200).body(new Gson().toJson(cacheRepository.findAll())); } - @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose - @RequestMapping("/api/startCache") - @ResponseBody - public ResponseEntity startCache(@RequestParam(value = "token", defaultValue = "-1") String token, - @RequestParam String cacheID) { - - if (!token.equals("-1")) { // ein angemeldeter user startet den cache(es werden zwei parameter übergeben) - - Bearbeitet bearbeitet = new Bearbeitet(); - - - //---------------------- - //Verify token - ResponseEntity tokenVerification = VerificationUtil.verifyToken(token); - - //Error in token verification - if (tokenVerification.getStatusCodeValue() != 200) { - return tokenVerification; - } - - Claims claims = (Claims) tokenVerification.getBody(); - - ResponseEntity getUser = FinderUtil.findUserFromClaim(claims); - - if (getUser.getStatusCodeValue() != 200) { - return getUser; - } - - User user = (User) getUser.getBody(); - - bearbeitet.setUser(user); - - //---------------------- - //Get Cache - ResponseEntity getCache = FinderUtil.findCacheById(cacheID); - - if (getCache.getStatusCodeValue() != 200) { - return getCache; - } - - Cache cache = (Cache) getCache.getBody(); - //---------------------- - - if (bearbeitetRepository.findByUserAndCache(user, cache) != null) { - Bearbeitet bearbeitet1 = bearbeitetRepository.findByUserAndCache(user, cache); - return ResponseEntity.status(200).body(bearbeitet1); - } - - bearbeitet.setCache(cache); - - Station startStation = cache.getStationen().get(0); - bearbeitet.setAktuelleStation(startStation); - - //Get CacheAccesDefinition - ResponseEntity getCacheAccesDefinition = FinderUtil.findCacheAccesDefinitionById("0"); - - if (getCacheAccesDefinition.getStatusCodeValue() != 200) { - return getCacheAccesDefinition; - } - - CacheAccesDefinition cacheAccesDefinition = (CacheAccesDefinition) getCacheAccesDefinition.getBody(); - //---------------------- - bearbeitet.setCacheAccesDefinition(cacheAccesDefinition); - - bearbeitetRepository.save(bearbeitet); - - return ResponseEntity.status(201).body(new Gson().toJson(bearbeitet)); - - } else { // kein angemeldeter User startet den cache(es wird nur der cache als parameter übergeben) - - ResponseEntity getCache = FinderUtil.findCacheById(cacheID); - - if (getCache.getStatusCodeValue() != 200) { - return getCache; - } - - Cache cache = (Cache) getCache.getBody(); - - return ResponseEntity.status(200).body(new Gson().toJson(cache)); - } - } + // alte startCache-methode +// @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose +// @RequestMapping("/api/startCache") +// @ResponseBody +// public ResponseEntity startCache(@RequestParam(value = "token", defaultValue = "-1") String token, +// @RequestParam String cacheID) { +// +// if (!token.equals("-1")) { // ein angemeldeter user startet den cache(es werden zwei parameter übergeben) +// +// Bearbeitet bearbeitet = new Bearbeitet(); +// +// +// //---------------------- +// //Verify token +// ResponseEntity tokenVerification = VerificationUtil.verifyToken(token); +// +// //Error in token verification +// if (tokenVerification.getStatusCodeValue() != 200) { +// return tokenVerification; +// } +// +// Claims claims = (Claims) tokenVerification.getBody(); +// +// ResponseEntity getUser = FinderUtil.findUserFromClaim(claims); +// +// if (getUser.getStatusCodeValue() != 200) { +// return getUser; +// } +// +// User user = (User) getUser.getBody(); +// +// bearbeitet.setUser(user); +// +// //---------------------- +// //Get Cache +// ResponseEntity getCache = FinderUtil.findCacheById(cacheID); +// +// if (getCache.getStatusCodeValue() != 200) { +// return getCache; +// } +// +// Cache cache = (Cache) getCache.getBody(); +// //---------------------- +// +// if (bearbeitetRepository.findByUserAndCache(user, cache) != null) { +// Bearbeitet bearbeitet1 = bearbeitetRepository.findByUserAndCache(user, cache); +// return ResponseEntity.status(200).body(bearbeitet1); +// } +// +// bearbeitet.setCache(cache); +// +// Station startStation = cache.getStationen().get(0); +// bearbeitet.setAktuelleStation(startStation); +// +// //Get CacheAccesDefinition +// ResponseEntity getCacheAccesDefinition = FinderUtil.findCacheAccesDefinitionById("0"); +// +// if (getCacheAccesDefinition.getStatusCodeValue() != 200) { +// return getCacheAccesDefinition; +// } +// +// CacheAccesDefinition cacheAccesDefinition = (CacheAccesDefinition) getCacheAccesDefinition.getBody(); +// //---------------------- +// bearbeitet.setCacheAccesDefinition(cacheAccesDefinition); +// +// bearbeitetRepository.save(bearbeitet); +// +// return ResponseEntity.status(201).body(new Gson().toJson(bearbeitet)); +// +// } else { // kein angemeldeter User startet den cache(es wird nur der cache als parameter übergeben) +// +// ResponseEntity getCache = FinderUtil.findCacheById(cacheID); +// +// if (getCache.getStatusCodeValue() != 200) { +// return getCache; +// } +// +// Cache cache = (Cache) getCache.getBody(); +// +// return ResponseEntity.status(200).body(new Gson().toJson(cache)); +// } +// } @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose @RequestMapping("/api/checkStation") @@ -208,12 +209,39 @@ public class Controller { return ResponseEntity.status(400).body("The scanned station isn´t the correct following station"); } + if (!cache.getStationen().contains(station)) { + return ResponseEntity.status(400).body("The scanned station isnt a part of the cache"); + } + //---------------------- //Get Bearbeitet entry ResponseEntity getBearbeitet = FinderUtil.findBearbeitetByUserAndCache(user, cache); if (getBearbeitet.getStatusCodeValue() != 200) { - return getBearbeitet; + if (cache.getStationen().get(0).equals(station)) { + // start Cache + Bearbeitet bearbeitet = new Bearbeitet(); + bearbeitet.setUser(user); + bearbeitet.setCache(cache); + bearbeitet.setAktuelleStation(station); + + //Get CacheAccesDefinition + ResponseEntity getCacheAccesDefinition = FinderUtil.findCacheAccesDefinitionById("0"); + + if (getCacheAccesDefinition.getStatusCodeValue() != 200) { + return getCacheAccesDefinition; + } + + CacheAccesDefinition cacheAccesDefinition = (CacheAccesDefinition) getCacheAccesDefinition.getBody(); + //---------------------- + bearbeitet.setCacheAccesDefinition(cacheAccesDefinition); + + bearbeitetRepository.save(bearbeitet); + + return ResponseEntity.status(201).body(new Gson().toJson(bearbeitet)); + } else { + return getBearbeitet; + } } Bearbeitet bearbeitet = (Bearbeitet) getBearbeitet.getBody(); @@ -225,10 +253,6 @@ public class Controller { return ResponseEntity.status(400).body("Database Error"); } - if (!cache.getStationen().contains(station)) { - return ResponseEntity.status(400).body("The scanned station isnt a part of the cache"); - } - int i = cache.getStationen().indexOf(station); if (i == 0) {