From 6f6fa8a0b091bc4be2d1e9bbdcb4a1119b84b60a Mon Sep 17 00:00:00 2001 From: Katharina Will Date: Tue, 23 Apr 2019 21:02:02 +0200 Subject: [PATCH 1/9] Added error handling to CacheStart and implemented qr scanner as own page --- frontend/src/layouts/MyLayout.vue | 13 ++++++++++++ frontend/src/pages/CacheEnd.vue | 2 +- frontend/src/pages/CacheStart.vue | 20 +++++++++++++++++-- .../{qr-code-test.vue => qr-scanner.vue} | 3 --- frontend/src/router/routes.js | 4 ++-- 5 files changed, 34 insertions(+), 8 deletions(-) rename frontend/src/pages/{qr-code-test.vue => qr-scanner.vue} (95%) diff --git a/frontend/src/layouts/MyLayout.vue b/frontend/src/layouts/MyLayout.vue index 6bc4eb9..7c07278 100644 --- a/frontend/src/layouts/MyLayout.vue +++ b/frontend/src/layouts/MyLayout.vue @@ -43,6 +43,19 @@ Startseite + + + + + + QR-Code Scanner + funktioniert das? } }, methods: { diff --git a/frontend/src/pages/CacheStart.vue b/frontend/src/pages/CacheStart.vue index 2ee2846..faef40b 100644 --- a/frontend/src/pages/CacheStart.vue +++ b/frontend/src/pages/CacheStart.vue @@ -52,8 +52,24 @@ console.log("Anfrage erfolgreich"); }) .catch((error) => { - console.log(error); - console.log("Anfrage fehlgeschlagen"); + let msg; + let title; + if (error.response) { + // The request was made and the server responded with a status code + title = "Seite konnte nicht gefunden werden!"; + msg = error.response; + } else if (error.request) { + // The request was made but no response was received + title = "Problem with request!"; + msg = "Error occured due to wrong server request!" + console.log(error.request); + } else { + // Something happened in setting up the request that triggered an Error + title = "Error"; + msg = error.message; + console.log('Error', error.message); + } + this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { title: title, message: msg}) }) this.$router.push({path: `/station/${params.cacheID}/${params.stationID}`}) }, diff --git a/frontend/src/pages/qr-code-test.vue b/frontend/src/pages/qr-scanner.vue similarity index 95% rename from frontend/src/pages/qr-code-test.vue rename to frontend/src/pages/qr-scanner.vue index 7bf52e7..087cb71 100644 --- a/frontend/src/pages/qr-code-test.vue +++ b/frontend/src/pages/qr-scanner.vue @@ -23,9 +23,6 @@ -

Last result: {{ result }}

-

Validating: {{ validating }}

-

is Valid: {{ isValid }}

diff --git a/frontend/src/router/routes.js b/frontend/src/router/routes.js index 03e0d36..63e5a11 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", From 73cd87765fa28763c31daf1072f6014b6617a2bd Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 23 Apr 2019 22:53:21 +0200 Subject: [PATCH 2/9] checkStation is a god now --- .../bugageocaching/controller/Controller.java | 196 ++++++++++-------- 1 file changed, 110 insertions(+), 86 deletions(-) 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) { From e412d4a797d342486ca6bd200d293458b6b7e56e Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Wed, 24 Apr 2019 09:31:12 +0200 Subject: [PATCH 3/9] updated frontend caching logic --- frontend/src/boot/axios.js | 3 +- frontend/src/pages/Cache.vue | 203 +++++++++++------- frontend/src/pages/CacheStart.vue | 2 +- frontend/src/pages/Login.vue | 31 ++- frontend/src/pages/StationEdit.vue | 46 ++-- frontend/src/router/routes.js | 2 +- frontend/src/store/cacheCollector/getters.js | 4 + .../src/store/cacheCollector/mutations.js | 9 + frontend/src/store/cacheCollector/state.js | 6 + 9 files changed, 186 insertions(+), 120 deletions(-) diff --git a/frontend/src/boot/axios.js b/frontend/src/boot/axios.js index 8523d48..ea842da 100644 --- a/frontend/src/boot/axios.js +++ b/frontend/src/boot/axios.js @@ -1,7 +1,8 @@ import axios from "axios"; const axiosInstance = axios.create({ - baseURL: process.env.API + baseURL: process.env.API, + timeout: 3000 }); console.log("process.env.DEV: "+process.env.DEV); console.log("process.env.API: "+process.env.API); diff --git a/frontend/src/pages/Cache.vue b/frontend/src/pages/Cache.vue index e3126cf..5409e0a 100644 --- a/frontend/src/pages/Cache.vue +++ b/frontend/src/pages/Cache.vue @@ -1,75 +1,108 @@ @@ -81,7 +114,7 @@ name: "Cache", data() { return { - // stationComponent: null, + //endStation: {}, scrolldown: false, isNewCache: this.$route.params.id === undefined, tempCache: {}, @@ -122,6 +155,19 @@ // swapComponent: function (component) { // this.stationComponent = component; // }, + editEndStation() { + console.log("editEndStation()"); + const station = this.cache.endStation; + console.log(station); + if (station.hasOwnProperty('id')) { + //this.$router.push({ path: '/station/'+station.id}); + } else { + // TODO Stationen bearbeitbar machen bevor sie abgeschickt werden. Am besten Station Objekt als Übergabe Parameter bei Router + this.$store.commit('cacheCollector/SET_TEMPSTATION', station); + this.$router.push({path: `/tempstation/${index}`}); // add parameter + } + + }, cacheToStore() { // push tempCache to Store console.log("set Cache"); @@ -129,20 +175,20 @@ // this.SET_CACHE(JSON.parse(JSON.stringify(this.tempCache))); }, addStation() { - this.$router.push({ path: '/station' }); + this.$router.push({path: '/station'}); //this.swapComponent(station); // create Station and add it to array tempCache.stationen }, editStation(index) { - console.log("editStation("+index+")"); + console.log("editStation(" + index + ")"); const station = this.cache.stationen[index]; - console.log(station) - if (station.hasOwnProperty('id') ) { + console.log(station); + if (station.hasOwnProperty('id')) { //this.$router.push({ path: '/station/'+station.id}); } else { // TODO Stationen bearbeitbar machen bevor sie abgeschickt werden. Am besten Station Objekt als Übergabe Parameter bei Router this.$store.commit('cacheCollector/SET_TEMPSTATION', station); - this.$router.push({ path: `/station-l/${index}` }); // add parameter + this.$router.push({path: `/tempstation/${index}`}); // add parameter } }, deleteStation(index) { @@ -153,12 +199,14 @@ // commit to store, send to api, if success -> reset store if (this.isNewCache) { console.log(this.cache); - console.log(JSON.stringify(this.cache)); + let cache = this.cache; + cache.stationen.push(this.endStation); + this.$axios.post('/api/createCache', this.cache) .then((response) => { console.log("POST api/createCache: " + response.statusText); this.$store.commit('cacheCollector/RESET_NEW_CACHE'); - this.$router.push({ path: '/overview' }); + this.$router.push({path: '/overview'}); }).catch((error) => { // Error let msg; @@ -179,16 +227,17 @@ console.log('Error', error.message); } console.log(error.config); - this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, }); + this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,}); }) - } else { + } else { // TODO update existing Cache } - }, + }, }, computed: { ...mapGetters({ - cache: 'cacheCollector/GET_CACHE' + cache: 'cacheCollector/GET_CACHE', + endStation: 'cacheCollector/GET_ENDSTATION' }), // computedCache: { // set(value) { diff --git a/frontend/src/pages/CacheStart.vue b/frontend/src/pages/CacheStart.vue index 2ee2846..ec4394b 100644 --- a/frontend/src/pages/CacheStart.vue +++ b/frontend/src/pages/CacheStart.vue @@ -23,7 +23,7 @@ return { //TODO Lageplan einbinden cacheID: "", cacheName: "", - code: "8/6", + code: "8/7", instruction: "Bitte begib Dich zu der auf der Karte angezeigten Position. An dieser Position wirst Du einen QR-Code finden. Wenn du ihn gefunden hast, drücke den Knopf zum Starten des QR-Scanners und gib uns die Berechtigung, Deine Kamera zu öffnen. Nachdem Du den QR-Code gescannt hast, erhältst du ein Rätsel zur Position der nächsten Station. Die Lösung zu dem Rätsel ist also das Versteck des nächsten QR-Codes." } }, diff --git a/frontend/src/pages/Login.vue b/frontend/src/pages/Login.vue index 649de1c..881b3d7 100644 --- a/frontend/src/pages/Login.vue +++ b/frontend/src/pages/Login.vue @@ -25,12 +25,18 @@ + > + + - - - -
Fehler
-
- - - Es konnten keine übereinstimmenden Zugangsdaten in der Datenbank gefunden werden. - - - - - -
-
@@ -68,13 +59,13 @@ export default { data() { return { + loading: false, user: { email: "volkmann@geocaching.de", password: "0123456789", //token: "", // evalAuthentication: false }, - credentialsDialog: false, }; }, // beforeMount: { @@ -97,7 +88,7 @@ }, methods: { login: function () { - + this.loading = true; const data = { email: this.user.email, password: this.user.password @@ -135,7 +126,9 @@ } console.log(error.config); this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: message, title: header, }); - }) + }).finally(() => { + this.loading = false; + }) }, evalAuthentication: function () { this.$store.commit('auth/SET_AUTHENTICATED'); diff --git a/frontend/src/pages/StationEdit.vue b/frontend/src/pages/StationEdit.vue index f51add4..78b29a4 100644 --- a/frontend/src/pages/StationEdit.vue +++ b/frontend/src/pages/StationEdit.vue @@ -3,14 +3,16 @@

Neue Station

+ ['bold', 'italic', 'strike', 'underline'], + ['undo', 'redo'], + ['hr', 'link'], + ['fullscreen'], + ]" + v-model="station.description" min-height="10rem"/> - - - + + +

Location

- +

Lösung

- - + +
@@ -37,6 +40,7 @@ diff --git a/frontend/src/router/routes.js b/frontend/src/router/routes.js index 63e5a11..158b079 100644 --- a/frontend/src/router/routes.js +++ b/frontend/src/router/routes.js @@ -55,6 +55,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"), From 11e84effa17671713f234e80546e3070e738f35b Mon Sep 17 00:00:00 2001 From: Katharina Will Date: Wed, 24 Apr 2019 11:00:20 +0200 Subject: [PATCH 5/9] Added missing end-tags --- frontend/src/layouts/MyLayout.vue | 1 + frontend/src/pages/CacheEnd.vue | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/layouts/MyLayout.vue b/frontend/src/layouts/MyLayout.vue index 7c07278..002fb32 100644 --- a/frontend/src/layouts/MyLayout.vue +++ b/frontend/src/layouts/MyLayout.vue @@ -56,6 +56,7 @@ QR-Code Scanner + - +
Jetzt ist eine gute Zeit, etwas Neues zu beginnen.
- +
From 3ed9a1bf2104047bfd1b4a75191301f444db91cf Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Thu, 25 Apr 2019 10:22:28 +0200 Subject: [PATCH 6/9] implemented qr-code scanner in caching process --- frontend/src/pages/Cache.vue | 12 +- frontend/src/pages/CacheStart.vue | 175 ++++++++++++++++++++++++----- frontend/src/pages/StationView.vue | 142 +++++++++++++++++++++-- 3 files changed, 282 insertions(+), 47 deletions(-) diff --git a/frontend/src/pages/Cache.vue b/frontend/src/pages/Cache.vue index 5409e0a..ef3f49a 100644 --- a/frontend/src/pages/Cache.vue +++ b/frontend/src/pages/Cache.vue @@ -145,16 +145,6 @@ //this.scrollToBottom(); }, methods: { - // ...mapMutations([ - // 'cacheCollector/SET_CACHE', - // 'cacheCollector/ADD_STATION', - // 'cacheCollector/REMOVE_STATION', - // 'cacheCollector/RESET_NEW_CACHE', - // 'cacheCollector/LOAD_REMOTE_CACHE' - // ]), - // swapComponent: function (component) { - // this.stationComponent = component; - // }, editEndStation() { console.log("editEndStation()"); const station = this.cache.endStation; @@ -202,7 +192,7 @@ let cache = this.cache; cache.stationen.push(this.endStation); - this.$axios.post('/api/createCache', this.cache) + this.$axios.post('/api/createCache', cache) .then((response) => { console.log("POST api/createCache: " + response.statusText); this.$store.commit('cacheCollector/RESET_NEW_CACHE'); diff --git a/frontend/src/pages/CacheStart.vue b/frontend/src/pages/CacheStart.vue index ec4394b..4619554 100644 --- a/frontend/src/pages/CacheStart.vue +++ b/frontend/src/pages/CacheStart.vue @@ -1,17 +1,38 @@