fixed cache process

This commit is contained in:
Timo Volkmann 2019-04-29 21:34:26 +02:00
parent 65d3e77558
commit 33ed2e32b9
4 changed files with 43 additions and 77 deletions

View File

@ -2,7 +2,7 @@ import axios from "axios";
const axiosInstance = axios.create({ const axiosInstance = axios.create({
baseURL: process.env.API, baseURL: process.env.API,
timeout: 3000 timeout: 6000
}); });
console.log("process.env.DEV: "+process.env.DEV); console.log("process.env.DEV: "+process.env.DEV);
console.log("process.env.API: "+process.env.API); console.log("process.env.API: "+process.env.API);

View File

@ -126,8 +126,14 @@
this.$axios.get('/api/checkStation', {params}) this.$axios.get('/api/checkStation', {params})
.then((response) => { .then((response) => {
console.log("resolve(true)"); console.log("resolve(true)");
console.log("cache access definition");
console.log(response.data.cacheAccesDefinition);
resolve(true); 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) => { }).catch((error) => {
console.log("resolve(false)"); console.log("resolve(false)");
// Error // Error

View File

@ -52,6 +52,8 @@
data() { data() {
return { return {
//code: "", //code: "",
cacheID: "",
cacheName: "",
cache: null, cache: null,
data: { data: {
cacheId: 22, cacheId: 22,
@ -91,9 +93,13 @@
}, },
computed: { computed: {
showCacheProgress() { showCacheProgress() {
let stationCount = this.cache.stationen.length; if (this.cache !== null) {
let stationPos = 1 + this.cache.stationen.findIndex(station => station.id === Number(this.$route.params.id)); let stationCount = this.cache.stationen.length;
return `${stationPos} von ${stationCount}`; let stationPos = 1 + this.cache.stationen.findIndex(station => station.id === Number(this.$route.params.id));
return `${stationPos} von ${stationCount}`;
} else {
return "";
}
} }
}, },
methods: { methods: {
@ -105,61 +111,10 @@
console.log(this.data); console.log(this.data);
console.log(response.data); console.log(response.data);
const cache = response.data.find(cache => cache.id === Number(this.$route.params.cache)); 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; this.cache = cache;
console.log(JSON.stringify(this.data)); this.cacheName = cache.name;
this.$axios.get('/api/getAllStations') this.cacheID = this.$route.params.cache;
.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, });
})
}, },
setParams() { setParams() {
@ -197,10 +152,12 @@
this.$axios.get('/api/checkStation', {params}) this.$axios.get('/api/checkStation', {params})
.then((response) => { .then((response) => {
console.log("resolve(true)"); console.log("resolve(true)");
console.log("cache access definition");
console.log(response.data.cacheAccesDefinition);
resolve(true); 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}`}); 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}`}); this.$router.push({path: `/CacheEnd/${params.cacheID}`});
} }
}).catch((error) => { }).catch((error) => {

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div >
<div v-if="askForPermission"> <div class="q-ma-md" v-if="askForPermission">
<p>Um den QR-Code scannen zu können, müssen Sie den Zugriff auf Ihre Kamera erlauben.</p> <p>Um den QR-Code scannen zu können, müssen Sie den Zugriff auf Ihre Kamera erlauben.</p>
<q-btn @click="toggleCamera(!activateCamera)" :loading="loading" unelevated color="positive" stack <q-btn @click="toggleCamera(!activateCamera)" :loading="loading" unelevated color="positive" stack
@ -61,12 +61,18 @@
validate() { validate() {
return new Promise(resolve => { return new Promise(resolve => {
this.setParams(0); let params = this.setParams();
let params = this.params;
this.$axios.get('/api/checkStation', {params}) this.$axios.get('/api/checkStation', {params})
.then((response) => { .then((response) => {
console.log("resolve(true)"); console.log("resolve(true)");
resolve(true) console.log("cache access definition");
console.log(response.data.cacheAccesDefinition);
resolve(true);
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) => { }).catch((error) => {
console.log("resolve(false)"); console.log("resolve(false)");
// Error // Error
@ -96,20 +102,17 @@
}) })
}, },
setParams(cacheID) { setParams() {
console.log("setParams: "); console.log("setParams: ");
let resCacheID = this.result.split('/')[0]; let params = {};
let resStationID = this.result.split('/')[1]; params.cacheID = this.result.split('/')[0];
console.log(resCacheID + " und " + resStationID); params.stationID = this.result.split('/')[1];
this.params = { params.durchgefuehrterCacheID = params.cacheID;
token: null, console.log(params.cacheID + " und " + params.stationID);
cacheID: resCacheID,
stationID: resStationID,
durchgefuehrterCacheID: cacheID
};
if (localStorage.getItem('userToken')) { if (localStorage.getItem('userToken')) {
this.params.token = JSON.parse(localStorage.getItem('userToken')).token; params.token = JSON.parse(localStorage.getItem('userToken')).token;
} }
return params;
}, },
pauseCamera() { pauseCamera() {