From 6f6fa8a0b091bc4be2d1e9bbdcb4a1119b84b60a Mon Sep 17 00:00:00 2001 From: Katharina Will Date: Tue, 23 Apr 2019 21:02:02 +0200 Subject: [PATCH 1/3] 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 582edef0205e35678ba70a2f7eccbcec288689fc Mon Sep 17 00:00:00 2001 From: Katharina Will Date: Wed, 24 Apr 2019 10:10:02 +0200 Subject: [PATCH 2/3] Minor changes to CacheEnd --- frontend/src/pages/CacheEnd.vue | 13 ++++++++++--- frontend/src/router/routes.js | 5 +++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/CacheEnd.vue b/frontend/src/pages/CacheEnd.vue index dc4e641..ff85b30 100644 --- a/frontend/src/pages/CacheEnd.vue +++ b/frontend/src/pages/CacheEnd.vue @@ -25,6 +25,9 @@ data() { return { reward: false, + cacheID: "", + cacheName: "", + rankingPoints: "", end1: "Gut gemacht, Du hast alle Stationen dieses Cache gefunden. Dir wurden ", end2: " Punkte gutgeschrieben." //TODO Punkte wirklich gutschreiben, ggf. Cache auf erledigt setzen } @@ -34,6 +37,9 @@ return localStorage.getItem('userToken'); //TODO Methode umschreiben --> funktioniert das? } }, + created() { + this.fetchData(); + }, methods: { fetchData() { this.$axios.get('/api/allCaches') @@ -43,10 +49,11 @@ console.log(this.data); console.log(response.data); const cache = response.data.find(cache => cache.id === Number(this.$route.params.cache)); - this.data.cacheName = cache.name; - this.data.cachePoints = cache.rankingPoints; + this.cacheName = cache.name; + this.rankingPoints = cache.rankingPoints; + this.cacheID = this.$route.params.cache; }) + }, } - } } 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 3/3] 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.
- +