fixed some bugs and created data-store for current cache
This commit is contained in:
parent
2cace929d0
commit
65d3e77558
@ -86,6 +86,7 @@
|
|||||||
</q-item-section>
|
</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item
|
<q-item
|
||||||
|
v-if="this.$store.state.auth.isAuthenticated"
|
||||||
clickable
|
clickable
|
||||||
class="text-primary"
|
class="text-primary"
|
||||||
v-ripple
|
v-ripple
|
||||||
@ -104,13 +105,13 @@
|
|||||||
class="text-primary"
|
class="text-primary"
|
||||||
v-ripple
|
v-ripple
|
||||||
tag="a"
|
tag="a"
|
||||||
to="/Login"
|
to="/Register"
|
||||||
>
|
>
|
||||||
<q-item-section avatar>
|
<q-item-section avatar>
|
||||||
<q-icon name="logout"/>
|
<q-icon name="assignment"/>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
<q-item-section>
|
<q-item-section>
|
||||||
<q-item-label>Login</q-item-label>
|
<q-item-label>Registrieren</q-item-label>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item
|
<q-item
|
||||||
@ -118,13 +119,13 @@
|
|||||||
class="text-primary"
|
class="text-primary"
|
||||||
v-ripple
|
v-ripple
|
||||||
tag="a"
|
tag="a"
|
||||||
to="/Register"
|
to="/Login"
|
||||||
>
|
>
|
||||||
<q-item-section avatar>
|
<q-item-section avatar>
|
||||||
<q-icon name="assignment"/>
|
<q-icon name="logout"/>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
<q-item-section>
|
<q-item-section>
|
||||||
<q-item-label>Register</q-item-label>
|
<q-item-label>{{ loginText }}</q-item-label>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
</q-list>
|
</q-list>
|
||||||
@ -172,37 +173,41 @@
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
loginText() {
|
||||||
|
let text = this.$store.state.auth.isAuthenticated ? "Logout" : "Login";
|
||||||
|
return text;
|
||||||
|
},
|
||||||
dialogShow: {
|
dialogShow: {
|
||||||
get() {
|
get() {
|
||||||
console.log("get dialogShow: "+this.$store.state.dialog.dialog.show)
|
// console.log("get dialogShow: "+this.$store.state.dialog.dialog.show)
|
||||||
return this.$store.state.dialog.dialog.show;
|
return this.$store.state.dialog.dialog.show;
|
||||||
},
|
},
|
||||||
set(val) {
|
set(val) {
|
||||||
console.log("set dialogShow: "+val)
|
// console.log("set dialogShow: "+val)
|
||||||
this.$store.state.dialog.dialog.show = val;
|
this.$store.state.dialog.dialog.show = val;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dialogMessage: {
|
dialogMessage: {
|
||||||
get() {
|
get() {
|
||||||
console.log("get dialogMessage: "+this.$store.state.dialog.dialog.message)
|
// console.log("get dialogMessage: "+this.$store.state.dialog.dialog.message)
|
||||||
return this.$store.state.dialog.dialog.message;
|
return this.$store.state.dialog.dialog.message;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
dialogTitle: {
|
dialogTitle: {
|
||||||
get() {
|
get() {
|
||||||
console.log("get dialogTitle: "+this.$store.state.dialog.dialog.title)
|
// console.log("get dialogTitle: "+this.$store.state.dialog.dialog.title)
|
||||||
return this.$store.state.dialog.dialog.title;
|
return this.$store.state.dialog.dialog.title;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
dialogColorBg: {
|
dialogColorBg: {
|
||||||
get() {
|
get() {
|
||||||
console.log("get dialogColorBg: " + this.$store.state.dialog.dialog.colorBackground)
|
// console.log("get dialogColorBg: " + this.$store.state.dialog.dialog.colorBackground)
|
||||||
return this.$store.state.dialog.dialog.colorBackground;
|
return this.$store.state.dialog.dialog.colorBackground;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
dialogColorBtn: {
|
dialogColorBtn: {
|
||||||
get() {
|
get() {
|
||||||
console.log("get dialogColorBtn: "+this.$store.state.dialog.dialog.colorButton)
|
// console.log("get dialogColorBtn: "+this.$store.state.dialog.dialog.colorButton)
|
||||||
return this.$store.state.dialog.dialog.colorButton;
|
return this.$store.state.dialog.dialog.colorButton;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,9 +23,9 @@
|
|||||||
<div class="">
|
<div class="">
|
||||||
<div class="" style="max-width: 440px">
|
<div class="" style="max-width: 440px">
|
||||||
<q-btn
|
<q-btn
|
||||||
|
:loading="loading"
|
||||||
:outline="userAuthenticated"
|
:outline="userAuthenticated"
|
||||||
:disabled="userAuthenticated"
|
:disabled="userAuthenticated"
|
||||||
:loading="loading"
|
|
||||||
label="Login"
|
label="Login"
|
||||||
color="primary"
|
color="primary"
|
||||||
class="full-width"
|
class="full-width"
|
||||||
@ -80,9 +80,8 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
userAuthenticated() {
|
userAuthenticated() {
|
||||||
console.log("login: userAuthenticated()")
|
console.log("login: userAuthenticated()");
|
||||||
// console.log(this.$store.getters['auth/IS_AUTHENTICATED']);
|
console.log(this.$store.state.auth.isAuthenticated);
|
||||||
// return this.$store.getters['auth/IS_AUTHENTICATED']
|
|
||||||
return this.$store.state.auth.isAuthenticated;
|
return this.$store.state.auth.isAuthenticated;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -103,13 +102,13 @@
|
|||||||
console.log("TOKEN");
|
console.log("TOKEN");
|
||||||
console.log(response.data.token);
|
console.log(response.data.token);
|
||||||
localStorage.setItem('userToken', JSON.stringify(response.data));
|
localStorage.setItem('userToken', JSON.stringify(response.data));
|
||||||
this.evalAuthentication();
|
this.$router.push({path: `/overview`})
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
let message;
|
let message;
|
||||||
let header = "Fehler: ";
|
let header = "Fehler: ";
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
console.log("ERROR RESPONSE")
|
console.log("ERROR RESPONSE");
|
||||||
// The request was made and the server responded with a status code
|
// The request was made and the server responded with a status code
|
||||||
// that falls out of the range of 2xx
|
// that falls out of the range of 2xx
|
||||||
message = error.response.data.error;
|
message = error.response.data.error;
|
||||||
@ -128,6 +127,7 @@
|
|||||||
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: message, title: header, });
|
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: message, title: header, });
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
this.evalAuthentication();
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
evalAuthentication: function () {
|
evalAuthentication: function () {
|
||||||
|
|||||||
@ -26,7 +26,6 @@
|
|||||||
<q-card class="q-mb-md" v-for="cache in caches" :key="cache.id">
|
<q-card class="q-mb-md" v-for="cache in caches" :key="cache.id">
|
||||||
<q-expansion-item
|
<q-expansion-item
|
||||||
class=""
|
class=""
|
||||||
expand-icon-toggle
|
|
||||||
expand-separator
|
expand-separator
|
||||||
icon="location_on"
|
icon="location_on"
|
||||||
:label="cache.name"
|
:label="cache.name"
|
||||||
@ -174,43 +173,17 @@
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
startCache(cacheID) {
|
startCache(cacheID) {
|
||||||
const userToken = JSON.parse(localStorage.getItem('userToken')).token;
|
console.log("startCache()");
|
||||||
let params = {cacheID: cacheID};
|
// const userToken = JSON.parse(localStorage.getItem('userToken')).token;
|
||||||
if (userToken != null) {
|
// let params = {cacheID: cacheID};
|
||||||
params.token = userToken;
|
// if (userToken != null) {
|
||||||
}
|
// params.token = userToken;
|
||||||
console.log(params);
|
// }
|
||||||
|
// console.log(params);
|
||||||
this.$axios.get('/api/startCache', {params})
|
this.$store.state.currentCache.cache = this.caches.find(cache => cache.id === Number(cacheID));
|
||||||
.then((response) => {
|
console.log(this.$store.state.currentCache.cache);
|
||||||
console.log(response.data);
|
this.$store.state.currentCache.currentCacheID = Number(cacheID);
|
||||||
// TODO wenn cache angefangen, dann suche die letzte gefundene Station
|
this.$router.push({path: `/CacheStart/${cacheID}`})
|
||||||
let stationID = this.caches.find(x => x.id === cacheID).stationen[0].id;
|
|
||||||
console.log(stationID);
|
|
||||||
//this.$router.push({path: `/station/${stationID}`})
|
|
||||||
this.$router.push({path: `/CacheStart/${cacheID}`})
|
|
||||||
}).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, });
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -267,7 +267,11 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchUserCaches: function () {
|
fetchUserCaches: function () {
|
||||||
const token = JSON.parse(localStorage.getItem('userToken')).token;
|
if (localStorage.getItem('userToken')) {
|
||||||
|
const token = JSON.parse(localStorage.getItem('userToken')).token;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.$axios.get('/api/getMyCaches', {params: {token}})
|
this.$axios.get('/api/getMyCaches', {params: {token}})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.startedCaches = response.data;
|
this.startedCaches = response.data;
|
||||||
@ -297,7 +301,7 @@
|
|||||||
continueCache(cacheID) {
|
continueCache(cacheID) {
|
||||||
},
|
},
|
||||||
validateEmail(email) {
|
validateEmail(email) {
|
||||||
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
let re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||||
return re.test(String(email).toLowerCase());
|
return re.test(String(email).toLowerCase());
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,7 +80,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
console.log("StationView: ")
|
console.log("StationView: ");
|
||||||
// console.log("'id' from url: " + this.$route.params.id)
|
// console.log("'id' from url: " + this.$route.params.id)
|
||||||
// console.log("'cache' from url: " + this.$route.params.cache)
|
// console.log("'cache' from url: " + this.$route.params.cache)
|
||||||
this.fetchData();
|
this.fetchData();
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
|
|
||||||
export function NEW_MESSAGE_DIALOG (state, messageObject) {
|
export function NEW_MESSAGE_DIALOG (state, messageObject) {
|
||||||
console.log("NEW_MESSAGE_DIALOG");
|
// console.log("NEW_MESSAGE_DIALOG");
|
||||||
console.log(messageObject);
|
// console.log(messageObject);
|
||||||
if (messageObject == null) {
|
if (messageObject == null) {
|
||||||
state.dialog.show = true;
|
state.dialog.show = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(messageObject);
|
// console.log(messageObject);
|
||||||
|
|
||||||
if (messageObject.hasOwnProperty('color')) {
|
if (messageObject.hasOwnProperty('color')) {
|
||||||
switch (messageObject.color) {
|
switch (messageObject.color) {
|
||||||
@ -39,7 +39,7 @@ export function NEW_MESSAGE_DIALOG (state, messageObject) {
|
|||||||
state.dialog.show = true;
|
state.dialog.show = true;
|
||||||
}
|
}
|
||||||
export function RESET_MESSAGE_DIALOG (state) {
|
export function RESET_MESSAGE_DIALOG (state) {
|
||||||
console.log("RESET_MESSAGE_DIALOG");
|
// console.log("RESET_MESSAGE_DIALOG");
|
||||||
state.dialog.colorBackground = "bg-red-9 text-white";
|
state.dialog.colorBackground = "bg-red-9 text-white";
|
||||||
state.dialog.colorButton = "red-9";
|
state.dialog.colorButton = "red-9";
|
||||||
state.dialog.message = "Ein unbekannter Fehler ist aufgetreten. Bitte versuchen Sie es noch einmal.";
|
state.dialog.message = "Ein unbekannter Fehler ist aufgetreten. Bitte versuchen Sie es noch einmal.";
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import Axios from "axios";
|
|||||||
import auth from "./auth"
|
import auth from "./auth"
|
||||||
import cacheCollector from "./cacheCollector"
|
import cacheCollector from "./cacheCollector"
|
||||||
import dialog from "./dialog"
|
import dialog from "./dialog"
|
||||||
|
import currentCache from "./currentCache"
|
||||||
|
|
||||||
// import example from './module-example'
|
// import example from './module-example'
|
||||||
|
|
||||||
@ -19,7 +20,8 @@ export default function (/* { ssrContext } */) {
|
|||||||
modules: {
|
modules: {
|
||||||
auth,
|
auth,
|
||||||
cacheCollector,
|
cacheCollector,
|
||||||
dialog
|
dialog,
|
||||||
|
currentCache
|
||||||
},
|
},
|
||||||
|
|
||||||
// enable strict mode (adds overhead!)
|
// enable strict mode (adds overhead!)
|
||||||
@ -42,11 +44,15 @@ export default function (/* { ssrContext } */) {
|
|||||||
module.hot.accept(['./cacheCollector'], () => {
|
module.hot.accept(['./cacheCollector'], () => {
|
||||||
const cacheCollector = require('./cacheCollector').default;
|
const cacheCollector = require('./cacheCollector').default;
|
||||||
store.hotUpdate({ modules: { cacheCollector: newCacheCollector } })
|
store.hotUpdate({ modules: { cacheCollector: newCacheCollector } })
|
||||||
})
|
});
|
||||||
module.hot.accept(['./dialog'], () => {
|
module.hot.accept(['./dialog'], () => {
|
||||||
const dialog = require('./dialog').default;
|
const dialog = require('./dialog').default;
|
||||||
store.hotUpdate({ modules: { dialog: newDialog } })
|
store.hotUpdate({ modules: { dialog: newDialog } })
|
||||||
})
|
});
|
||||||
|
module.hot.accept(['./currentCache'], () => {
|
||||||
|
const currentCache = require('./currentCache').default;
|
||||||
|
store.hotUpdate({ modules: { currentCache: newCurrentCache } })
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return Store
|
return Store
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user