From 33ed2e32b9489a3bf81866e59a76837fa8e2f0e8 Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Mon, 29 Apr 2019 21:34:26 +0200 Subject: [PATCH] fixed cache process --- frontend/src/boot/axios.js | 2 +- frontend/src/pages/CacheStart.vue | 8 +++- frontend/src/pages/StationView.vue | 75 +++++++----------------------- frontend/src/pages/qr-scanner.vue | 35 +++++++------- 4 files changed, 43 insertions(+), 77 deletions(-) diff --git a/frontend/src/boot/axios.js b/frontend/src/boot/axios.js index ea842da..88a12cd 100644 --- a/frontend/src/boot/axios.js +++ b/frontend/src/boot/axios.js @@ -2,7 +2,7 @@ import axios from "axios"; const axiosInstance = axios.create({ baseURL: process.env.API, - timeout: 3000 + timeout: 6000 }); console.log("process.env.DEV: "+process.env.DEV); console.log("process.env.API: "+process.env.API); diff --git a/frontend/src/pages/CacheStart.vue b/frontend/src/pages/CacheStart.vue index 2cc51de..fadcfb1 100644 --- a/frontend/src/pages/CacheStart.vue +++ b/frontend/src/pages/CacheStart.vue @@ -126,8 +126,14 @@ this.$axios.get('/api/checkStation', {params}) .then((response) => { console.log("resolve(true)"); + console.log("cache access definition"); + console.log(response.data.cacheAccesDefinition); resolve(true); - this.$router.push({path: `/station/${params.cacheID}/${params.stationID}`}); + if (Number(response.data.cacheAccesDefinition.id) === 0) { + this.$router.push({path: `/station/${params.cacheID}/${params.stationID}`}); + } else if (Number(response.data.cacheAccesDefinition.id) === 1) { + this.$router.push({path: `/CacheEnd/${params.cacheID}`}); + } }).catch((error) => { console.log("resolve(false)"); // Error diff --git a/frontend/src/pages/StationView.vue b/frontend/src/pages/StationView.vue index 1a19b9c..450e925 100644 --- a/frontend/src/pages/StationView.vue +++ b/frontend/src/pages/StationView.vue @@ -52,6 +52,8 @@ data() { return { //code: "", + cacheID: "", + cacheName: "", cache: null, data: { cacheId: 22, @@ -91,9 +93,13 @@ }, computed: { showCacheProgress() { - let stationCount = this.cache.stationen.length; - let stationPos = 1 + this.cache.stationen.findIndex(station => station.id === Number(this.$route.params.id)); - return `${stationPos} von ${stationCount}`; + if (this.cache !== null) { + let stationCount = this.cache.stationen.length; + let stationPos = 1 + this.cache.stationen.findIndex(station => station.id === Number(this.$route.params.id)); + return `${stationPos} von ${stationCount}`; + } else { + return ""; + } } }, methods: { @@ -105,61 +111,10 @@ console.log(this.data); console.log(response.data); const cache = response.data.find(cache => cache.id === Number(this.$route.params.cache)); - this.data.cacheId = cache.id; - this.data.cacheName = cache.name; this.cache = cache; - console.log(JSON.stringify(this.data)); - this.$axios.get('/api/getAllStations') - .then((response) => { - console.log("/api/getAllStations"); - console.log(response.data); - const stationView = response.data.find(station => station.id === Number(this.$route.params.id)); - console.log(JSON.stringify(stationView)); - this.data.station = stationView; - }).catch((error) => { - // Error - let msg; - let title; - if (error.response) { - // The request was made and the server responded with a status code - title = "Problem with response!"; - 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); - } - console.log(error.config); - this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, }); - }) - }).catch((error) => { - // Error - let msg; - let title; - if (error.response) { - // The request was made and the server responded with a status code - title = "Problem with response!"; - 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); - } - console.log(error.config); - this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, }); - }) + this.cacheName = cache.name; + this.cacheID = this.$route.params.cache; + }) }, setParams() { @@ -197,10 +152,12 @@ this.$axios.get('/api/checkStation', {params}) .then((response) => { console.log("resolve(true)"); + console.log("cache access definition"); + console.log(response.data.cacheAccesDefinition); resolve(true); - if (response.data.cache_acces_definition === 0) { + if (Number(response.data.cacheAccesDefinition.id) === 0) { this.$router.push({path: `/station/${params.cacheID}/${params.stationID}`}); - } else if (response.data.cache_acces_definition === 1) { + } else if (Number(response.data.cacheAccesDefinition.id) === 1) { this.$router.push({path: `/CacheEnd/${params.cacheID}`}); } }).catch((error) => { diff --git a/frontend/src/pages/qr-scanner.vue b/frontend/src/pages/qr-scanner.vue index 087cb71..e111c73 100644 --- a/frontend/src/pages/qr-scanner.vue +++ b/frontend/src/pages/qr-scanner.vue @@ -1,6 +1,6 @@