Merge branch 'develop' of https://bitbucket-student.it.hs-heilbronn.de/scm/labswp19/labswp_2019_sose_geocaching into develop
This commit is contained in:
commit
88505fb038
@ -19,6 +19,7 @@
|
|||||||
<q-input class="col" dense stack-label filled v-model="tempCache.rankingPoints" label="Punktewert"
|
<q-input class="col" dense stack-label filled v-model="tempCache.rankingPoints" label="Punktewert"
|
||||||
@change="cacheToStore"/>
|
@change="cacheToStore"/>
|
||||||
<q-input
|
<q-input
|
||||||
|
disable
|
||||||
v-model="tempCache.reward"
|
v-model="tempCache.reward"
|
||||||
dense
|
dense
|
||||||
stack-label
|
stack-label
|
||||||
@ -52,7 +53,7 @@
|
|||||||
|
|
||||||
<q-item-section side>
|
<q-item-section side>
|
||||||
<div class="text-grey-8 q-gutter-xs">
|
<div class="text-grey-8 q-gutter-xs">
|
||||||
<q-btn disable @click="deleteStation" class="" color="" flat dense round icon="delete"/>
|
<q-btn @click="deleteStation(index)" class="" color="" flat dense round icon="delete"/>
|
||||||
<q-btn @click="editStation(index)" class="" color="" flat dense round icon="edit"/>
|
<q-btn @click="editStation(index)" class="" color="" flat dense round icon="edit"/>
|
||||||
</div>
|
</div>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
@ -94,7 +95,7 @@
|
|||||||
created: function () {
|
created: function () {
|
||||||
console.log("isNewCache: " + this.isNewCache);
|
console.log("isNewCache: " + this.isNewCache);
|
||||||
console.log("fetch Caches from Store");
|
console.log("fetch Caches from Store");
|
||||||
this.tempCache = JSON.parse(JSON.stringify(this.cache))
|
this.tempCache = JSON.parse(JSON.stringify(this.cache));
|
||||||
},
|
},
|
||||||
beforeMount: function () {
|
beforeMount: function () {
|
||||||
},
|
},
|
||||||
@ -137,15 +138,16 @@
|
|||||||
const station = this.cache.stationen[index];
|
const station = this.cache.stationen[index];
|
||||||
console.log(station)
|
console.log(station)
|
||||||
if (station.hasOwnProperty('id') ) {
|
if (station.hasOwnProperty('id') ) {
|
||||||
this.$router.push({ path: '/station/'+station.id});
|
//this.$router.push({ path: '/station/'+station.id});
|
||||||
} else {
|
} else {
|
||||||
// TODO Stationen bearbeitbar machen bevor sie abgeschickt werden. Am besten Station Objekt als Übergabe Parameter bei Router
|
// 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.$store.commit('cacheCollector/SET_TEMPSTATION', station);
|
||||||
this.$router.push({ path: `/station?local=${index}` }); // add parameter
|
this.$router.push({ path: `/station-l/${index}` }); // add parameter
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deleteStation() {
|
deleteStation(index) {
|
||||||
|
// TODO wenn Station id hat, mit Backend abgleichen
|
||||||
|
this.$store.commit('cacheCollector/REMOVE_STATION', index);
|
||||||
},
|
},
|
||||||
saveCache() {
|
saveCache() {
|
||||||
// commit to store, send to api, if success -> reset store
|
// commit to store, send to api, if success -> reset store
|
||||||
@ -155,6 +157,7 @@
|
|||||||
this.$axios.post('http://localhost:8080/api/createCache', this.cache)
|
this.$axios.post('http://localhost:8080/api/createCache', this.cache)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log("POST api/createCache: " + response.statusText);
|
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) => {
|
.catch((error) => {
|
||||||
|
|||||||
@ -1,48 +1,50 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="q-pa-md">
|
<div class="q-pa-md">
|
||||||
<form class="login" @submit.prevent="login">
|
<form class="login" @submit.prevent="login">
|
||||||
<div class="q-pa-md">
|
<div class="q-pa-md">
|
||||||
<div class="column q-gutter-lg" style="">
|
<div class="column q-gutter-lg" style="">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="">
|
<div class="">
|
||||||
<div class="" style="max-width: 440px">
|
<div class="" style="max-width: 440px">
|
||||||
<q-input outlined filled stack-label v-model="user.username" type="text" label="Benutzername" autocomplete="username"/>
|
<q-input outlined filled stack-label v-model="user.username" type="text" label="Benutzername"
|
||||||
</div>
|
autocomplete="username"/>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="">
|
|
||||||
<div class="" style="max-width: 440px">
|
|
||||||
<q-input outlined filled stack-label v-model="user.password" type="password" label="Passwort" autocomplete="current-password"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="">
|
|
||||||
<div class="" style="max-width: 440px">
|
|
||||||
<q-btn
|
|
||||||
:outline="userAuthenticated"
|
|
||||||
:disabled="userAuthenticated"
|
|
||||||
label="Login"
|
|
||||||
color="primary"
|
|
||||||
class="full-width"
|
|
||||||
type="submit"
|
|
||||||
unelevated
|
|
||||||
/>
|
|
||||||
<q-btn
|
|
||||||
:outline="!userAuthenticated"
|
|
||||||
:disabled="!userAuthenticated"
|
|
||||||
label="Logout"
|
|
||||||
color="red"
|
|
||||||
class="full-width q-mt-md"
|
|
||||||
unelevated
|
|
||||||
@click="logout"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<div class="">
|
||||||
|
<div class="" style="max-width: 440px">
|
||||||
|
<q-input outlined filled stack-label v-model="user.password" type="password" label="Passwort"
|
||||||
|
autocomplete="current-password"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<div class="">
|
||||||
|
<div class="" style="max-width: 440px">
|
||||||
|
<q-btn
|
||||||
|
:outline="userAuthenticated"
|
||||||
|
:disabled="userAuthenticated"
|
||||||
|
label="Login"
|
||||||
|
color="primary"
|
||||||
|
class="full-width"
|
||||||
|
type="submit"
|
||||||
|
unelevated
|
||||||
|
/>
|
||||||
|
<q-btn
|
||||||
|
:outline="!userAuthenticated"
|
||||||
|
:disabled="!userAuthenticated"
|
||||||
|
label="Logout"
|
||||||
|
color="red"
|
||||||
|
class="full-width q-mt-md"
|
||||||
|
unelevated
|
||||||
|
@click="logout"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<q-dialog v-model="credentialsDialog" persistent transition-show="scale" transition-hide="scale">
|
<q-dialog v-model="credentialsDialog" persistent transition-show="scale" transition-hide="scale">
|
||||||
<q-card class="bg-red-9 text-white" style="">
|
<q-card class="bg-red-9 text-white" style="">
|
||||||
@ -55,10 +57,11 @@
|
|||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
||||||
<q-card-actions align="right" class="bg-white text-teal">
|
<q-card-actions align="right" class="bg-white text-teal">
|
||||||
<q-btn flat label="OK" color="red-9" v-close-popup />
|
<q-btn flat label="OK" color="red-9" v-close-popup/>
|
||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-dialog> </div>
|
</q-dialog>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -80,17 +83,21 @@
|
|||||||
// console.log("initiated");
|
// console.log("initiated");
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
created () {
|
created() {
|
||||||
this.evalAuthentication();
|
this.evalAuthentication();
|
||||||
console.log("created: initiated");
|
console.log("created: initiated");
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
userAuthenticated() {
|
userAuthenticated() {
|
||||||
return this.$store.state.auth.userAuthenticated.isAuthenticated
|
console.log("login: userAuthenticated()")
|
||||||
|
// console.log(this.$store.getters['auth/IS_AUTHENTICATED']);
|
||||||
|
// return this.$store.getters['auth/IS_AUTHENTICATED']
|
||||||
|
return this.$store.state.auth.isAuthenticated;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
login: function () {
|
login: function () {
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
username: this.user.username,
|
username: this.user.username,
|
||||||
password: this.user.password
|
password: this.user.password
|
||||||
@ -107,25 +114,26 @@
|
|||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log("error: " + error);
|
console.log("error: " + error);
|
||||||
this.credentialsDialog=true;
|
this.credentialsDialog = true;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
evalAuthentication: function () {
|
evalAuthentication: function () {
|
||||||
this.$store.commit('auth/SET_AUTHENTICATED');
|
this.$store.commit('auth/SET_AUTHENTICATED');
|
||||||
|
this.$store.commit('auth/SET_USER');
|
||||||
},
|
},
|
||||||
logout: function () {
|
logout: function () {
|
||||||
console.log("logout()");
|
console.log("logout()");
|
||||||
console.log(JSON.parse(localStorage.getItem('userToken')));
|
console.log(JSON.parse(localStorage.getItem('userToken')));
|
||||||
this.$axios.get('http://localhost:8080/api/logout', {
|
// this.$axios.get('http://localhost:8080/api/logout', {
|
||||||
params: {
|
// params: {
|
||||||
token: JSON.parse(localStorage.getItem('userToken'))
|
// token: JSON.parse(localStorage.getItem('userToken'))
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
.then((response) => {
|
// .then((response) => {
|
||||||
console.log("GET/POST http://localhost:8080/api/logout/ - response: " + response.data);
|
// console.log("GET/POST http://localhost:8080/api/logout/ - response: " + response.data);
|
||||||
})
|
// })
|
||||||
.catch((error) => {
|
// .catch((error) => {
|
||||||
});
|
// });
|
||||||
localStorage.removeItem('userToken');
|
localStorage.removeItem('userToken');
|
||||||
this.evalAuthentication();
|
this.evalAuthentication();
|
||||||
},
|
},
|
||||||
|
|||||||
@ -24,35 +24,39 @@
|
|||||||
|
|
||||||
<q-list>
|
<q-list>
|
||||||
<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-icon-toggle
|
||||||
expand-separator
|
expand-separator
|
||||||
icon="location_on"
|
icon="location_on"
|
||||||
:label="cache.name"
|
:label="cache.name"
|
||||||
:caption="cache.rankingPoints+' Punkte / Size '+cache.stationen.length"
|
:caption="cache.rankingPoints+' Punkte / Size '+cache.stationen.length"
|
||||||
>
|
>
|
||||||
<q-item>
|
<q-item>
|
||||||
<q-item-section top avatar class="self-center">
|
<q-item-section top avatar class="self-center">
|
||||||
<!--<q-icon rounded color="cyan-14" name="location_on" size="3rem"/>-->
|
<!--<q-icon rounded color="cyan-14" name="location_on" size="3rem"/>-->
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
<q-item-section>
|
<q-item-section>
|
||||||
<q-item-label caption>{{ cache.description }}</q-item-label>
|
<q-item-label caption>{{ cache.description }}</q-item-label>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
|
|
||||||
<q-item-section side top class="self-center" >
|
<q-item-section side top class="self-center">
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item class="q-pr-sm reverse q-gutter-x-sm">
|
<q-item class="q-pr-sm reverse q-gutter-x-sm">
|
||||||
<q-btn @click="startCache(cache.id)" unelevated color="positive" stack icon="arrow_forward" label="Starten" size="sm"/>
|
<q-btn @click="startCache(cache.id)" unelevated color="positive" stack icon="arrow_forward"
|
||||||
<q-btn v-if="hasAdminState" @click="editCache(cache.id)" unelevated color="amber" stack icon="edit" label="Bearbeiten" size="sm"/>
|
label="Starten" size="sm"/>
|
||||||
<q-btn v-if="hasAdminState" @click="deleteCache(cache.id)" unelevated color="negative" stack icon="delete" label="Löschen" size="sm"/>
|
<q-btn disable v-if="hasAdminState" @click="editCache(cache.id)" unelevated color="amber" stack
|
||||||
</q-item>
|
icon="edit" label="Bearbeiten" size="sm"/>
|
||||||
</q-expansion-item>
|
<q-btn v-if="hasAdminState" @click="deleteCache(cache.id)" unelevated color="negative" stack
|
||||||
|
icon="delete" label="Löschen" size="sm"/>
|
||||||
|
</q-item>
|
||||||
|
</q-expansion-item>
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-list>
|
</q-list>
|
||||||
<div v-if="hasAdminState" class="row">
|
<div v-if="hasAdminState" class="row">
|
||||||
<q-btn @click="addCache" unelevated color="primary" stack icon="add" label="Neuer Cache" class="full-width"/>
|
<q-btn @click="addCache" unelevated color="primary" stack icon="add" label="Neuer Cache"
|
||||||
|
class="full-width"/>
|
||||||
</div>
|
</div>
|
||||||
</q-tab-panel>
|
</q-tab-panel>
|
||||||
|
|
||||||
@ -60,7 +64,9 @@
|
|||||||
<q-tab-panel name="map" class="q-pa-none fit">
|
<q-tab-panel name="map" class="q-pa-none fit">
|
||||||
<!--<div class="full-width full-height absolute-full" style="background: url('statics/osm_mock.png'); background-size: cover">-->
|
<!--<div class="full-width full-height absolute-full" style="background: url('statics/osm_mock.png'); background-size: cover">-->
|
||||||
<!--</div>-->
|
<!--</div>-->
|
||||||
<q-img src="https://www.buga2019.de/we-bilder/3.Gartenausstellung/Gelaendeplan/190320_Gelaendeplan-quadratisch.jpg" transition="fade" class="absolute-full">
|
<q-img
|
||||||
|
src="https://www.buga2019.de/we-bilder/3.Gartenausstellung/Gelaendeplan/190320_Gelaendeplan-quadratisch.jpg"
|
||||||
|
transition="fade" class="absolute-full">
|
||||||
<template v-slot:loading>
|
<template v-slot:loading>
|
||||||
<q-spinner-puff color="cyan-14" size="4em"/>
|
<q-spinner-puff color="cyan-14" size="4em"/>
|
||||||
</template>
|
</template>
|
||||||
@ -68,40 +74,59 @@
|
|||||||
</q-tab-panel>
|
</q-tab-panel>
|
||||||
|
|
||||||
</q-tab-panels>
|
</q-tab-panels>
|
||||||
|
<q-dialog v-model="dialog" persistent transition-show="scale" transition-hide="scale">
|
||||||
|
<q-card class="bg-red-9 text-white" style="">
|
||||||
|
<q-card-section>
|
||||||
|
<div class="text-h6">Fehler</div>
|
||||||
|
</q-card-section>
|
||||||
|
|
||||||
|
<q-card-section>
|
||||||
|
{{ dialogMsg }}
|
||||||
|
</q-card-section>
|
||||||
|
|
||||||
|
<q-card-actions align="right" class="bg-white text-teal">
|
||||||
|
<q-btn flat label="OK" color="red-9" v-close-popup/>
|
||||||
|
</q-card-actions>
|
||||||
|
</q-card>
|
||||||
|
</q-dialog>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</q-page>
|
</q-page>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/*
|
/*
|
||||||
.my-list-card-item
|
.my-list-card-item
|
||||||
padding-left: 8px
|
padding-left: 8px
|
||||||
*/
|
*/
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
//import {dom} from 'quasar'
|
|
||||||
//const {height, width} = dom
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
tab: 'list',
|
tab: 'list',
|
||||||
// hheight: 71.0,
|
|
||||||
// fheight: 36.0, //37
|
|
||||||
//header: {h: '0px', w: 0}
|
|
||||||
caches: [],
|
caches: [],
|
||||||
|
dialog: false,
|
||||||
|
dialogMsg: "",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
// ...mapGetters([
|
||||||
|
// 'auth/GET_ADMINSTATE'
|
||||||
|
// ]),
|
||||||
|
|
||||||
hasAdminState() {
|
hasAdminState() {
|
||||||
return this.$store.state.auth.userAuthenticated.isAdmin
|
return this.$store.getters['auth/GET_ADMINSTATE'];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function() {
|
created: function () {
|
||||||
console.log("created(): " + this.caches);
|
console.log("created(): " + this.caches);
|
||||||
this.fetchAllCaches();
|
this.fetchAllCaches();
|
||||||
|
this.$store.commit('auth/SET_AUTHENTICATED');
|
||||||
|
this.$store.commit('auth/SET_USER');
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchAllCaches() {
|
fetchAllCaches() {
|
||||||
@ -112,27 +137,33 @@
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
addCache() {
|
addCache() {
|
||||||
this.$router.push({ path: `/cache` })
|
this.$router.push({path: `/cache`})
|
||||||
},
|
},
|
||||||
editCache() {
|
editCache() {
|
||||||
},
|
},
|
||||||
removeCache() {
|
deleteCache(id) {
|
||||||
|
console.log('delete cache: ' + id)
|
||||||
|
this.$axios.delete('http://localhost:8080/api/deleteCache', {params: {cacheID: id}})
|
||||||
|
.then((response) => {
|
||||||
|
this.fetchAllCaches()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
startCache(cacheID) {
|
startCache(cacheID) {
|
||||||
const userToken = JSON.parse(localStorage.getItem('userToken'));
|
const userToken = JSON.parse(localStorage.getItem('userToken'));
|
||||||
let params = { cacheID: cacheID };
|
let params = {cacheID: cacheID};
|
||||||
if (userToken != null) {
|
if (userToken != null) {
|
||||||
params.token = userToken;
|
params.token = userToken;
|
||||||
}
|
}
|
||||||
console.log(params);
|
console.log(params);
|
||||||
|
|
||||||
this.$axios.get('http://localhost:8080/api/startCache', { params })
|
this.$axios.get('http://localhost:8080/api/startCache', {params})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(response.data);
|
console.log(response.data);
|
||||||
// let stationID = response.data.stationen[0].id;
|
// TODO wenn cache angefangen, dann suche die letzte gefundene Station
|
||||||
let stationID = this.caches.find(x => x.id === cacheID).stationen[0].id;
|
let stationID = this.caches.find(x => x.id === cacheID).stationen[0].id;
|
||||||
console.log(stationID);
|
console.log(stationID);
|
||||||
this.$router.push({ path: `/station/${stationID}` })
|
//this.$router.push({path: `/station/${stationID}`})
|
||||||
|
this.$router.push({path: `/station/${cacheID}/${stationID}`})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<p class="text-h6 q-mt-md">Lösung</p>
|
<p class="text-h6 q-mt-md">Lösung</p>
|
||||||
<q-input class="col" dense stack-label filled v-model="station.solution" label="Lösung" />
|
<q-input class="col" dense stack-label filled v-model="station.solution" label="Lösung" />
|
||||||
<q-input class="col q-mt-md" dense stack-label filled v-model="station.code" label="Code" readonly/>
|
<!-- <q-input class="col q-mt-md" dense stack-label filled v-model="station.code" label="Code" readonly/>-->
|
||||||
<div class="row reverse q-mt-md q-gutter-x-md">
|
<div class="row reverse q-mt-md q-gutter-x-md">
|
||||||
<q-btn @click="saveStation" unelevated color="primary" label="Speichern" icon-right="add"/>
|
<q-btn @click="saveStation" unelevated color="primary" label="Speichern" icon-right="add"/>
|
||||||
<q-btn @click="dismiss" unelevated color="negative" label="verwerfen" icon-right="delete"/>
|
<q-btn @click="dismiss" unelevated color="negative" label="verwerfen" icon-right="delete"/>
|
||||||
@ -45,11 +45,11 @@
|
|||||||
description: "Rätsel, Aufgabe und Informationen zur Station.",
|
description: "Rätsel, Aufgabe und Informationen zur Station.",
|
||||||
latlang: "",
|
latlang: "",
|
||||||
station: {
|
station: {
|
||||||
description: "description",
|
description: "Beschreibung",
|
||||||
lattitude: 0.06470,
|
lattitude: "0.000",
|
||||||
longitude: 0.05551,
|
longitude: "0.000",
|
||||||
solution: "solution",
|
solution: "",
|
||||||
code: 357547
|
code: ""
|
||||||
},
|
},
|
||||||
isNewStation: true,
|
isNewStation: true,
|
||||||
// stationObject: null,
|
// stationObject: null,
|
||||||
@ -57,15 +57,19 @@
|
|||||||
},
|
},
|
||||||
// props: [ 'stationObject' ],
|
// props: [ 'stationObject' ],
|
||||||
created: function() {
|
created: function() {
|
||||||
this.station = this.tempStation;
|
this.isNewStation = (this.$route.params.pos === undefined);
|
||||||
|
console.log("neu: "+this.isNewStation);
|
||||||
|
console.log("pos: "+this.$route.params.pos);
|
||||||
|
console.log(this.$route);
|
||||||
|
console.log(this.station);
|
||||||
|
if (!this.isNewStation) {
|
||||||
|
this.station = JSON.parse(JSON.stringify(this.tempStation));
|
||||||
|
}
|
||||||
console.log(this.station);
|
console.log(this.station);
|
||||||
},
|
},
|
||||||
beforeMount: function() {
|
beforeMount: function() {
|
||||||
},
|
},
|
||||||
mounted: function() {
|
mounted: function() {
|
||||||
this.isNewStation = this.$route.params.pos === undefined;
|
|
||||||
console.log("neu: "+this.isNewStation);
|
|
||||||
console.log("pos: "+this.$route.params.pos);
|
|
||||||
this.concatLatlang();
|
this.concatLatlang();
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -87,20 +91,19 @@
|
|||||||
this.latlang = this.station.lattitude+", "+this.station.longitude;
|
this.latlang = this.station.lattitude+", "+this.station.longitude;
|
||||||
},
|
},
|
||||||
saveStation() {
|
saveStation() {
|
||||||
//this.$parent.swapComponent(null);
|
|
||||||
// this.$emit('q-tb');
|
|
||||||
console.log("saveStation(): ");
|
console.log("saveStation(): ");
|
||||||
if (isNewStation) {
|
console.log(this.station);
|
||||||
|
if (this.isNewStation) {
|
||||||
this.$store.commit('cacheCollector/ADD_STATION', this.station);
|
this.$store.commit('cacheCollector/ADD_STATION', this.station);
|
||||||
} else {
|
} else {
|
||||||
this.$store.commit('cacheCollector/EDIT_STATION', this.$route.params.pos, this.station);
|
this.$store.commit('cacheCollector/EDIT_STATION', { index: this.$route.params.pos, station: this.station });
|
||||||
this.$store.commit('cacheCollector/SET_TEMPSTATION', null);
|
this.$store.commit('cacheCollector/SET_TEMPSTATION', null);
|
||||||
}
|
}
|
||||||
this.$router.push({ path: `/cache` });
|
this.$router.push({ path: `/cache` });
|
||||||
console.log("station saved..");
|
console.log("station saved..");
|
||||||
},
|
},
|
||||||
dismiss() {
|
dismiss() {
|
||||||
this.$emit('q-tb');
|
this.$store.commit('cacheCollector/SET_TEMPSTATION', null);
|
||||||
this.$router.push({ path: `/cache` });
|
this.$router.push({ path: `/cache` });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,8 @@
|
|||||||
></q-img>
|
></q-img>
|
||||||
<div class="q-ma-md">
|
<div class="q-ma-md">
|
||||||
<p class="text-h4">{{ data.cacheName }}</p>
|
<p class="text-h4">{{ data.cacheName }}</p>
|
||||||
<p class="text-h5">Station {{ data.station.position }}</p>
|
<p class="text-h5">Station {{ showCacheProgress }}</p>
|
||||||
|
<!-- <p class="text-h5">Station {{ data.station.position }}</p>-->
|
||||||
<p>{{ data.station.description }}</p>
|
<p>{{ data.station.description }}</p>
|
||||||
<!--<q-input-->
|
<!--<q-input-->
|
||||||
<!--v-model="description"-->
|
<!--v-model="description"-->
|
||||||
@ -32,12 +33,11 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
code: "",
|
code: "",
|
||||||
|
cache: null,
|
||||||
data: {
|
data: {
|
||||||
cacheId: 22,
|
cacheId: 22,
|
||||||
cacheName: "Wasserfall Cache",
|
cacheName: "Wasserfall Cache",
|
||||||
nextStationId: 44,
|
|
||||||
station: {
|
station: {
|
||||||
position: 1,
|
|
||||||
id: 22,
|
id: 22,
|
||||||
description: "Ein kleines winterliches Schlaginstrument. Welche Blume ist damit gemeint?",
|
description: "Ein kleines winterliches Schlaginstrument. Welche Blume ist damit gemeint?",
|
||||||
longitude: 9.206628,
|
longitude: 9.206628,
|
||||||
@ -49,14 +49,46 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
|
console.log("StationView: ")
|
||||||
|
console.log("'id' from url: " + this.$route.params.id)
|
||||||
|
console.log("'cache' from url: " + this.$route.params.cache)
|
||||||
|
this.fetchData();
|
||||||
},
|
},
|
||||||
beforeMount: function () {
|
beforeMount: function () {
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
console.log("'id' from url: " + this.$route.params.id)
|
|
||||||
},
|
},
|
||||||
computed: {},
|
computed: {
|
||||||
methods: {}
|
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}`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
fetchData() {
|
||||||
|
this.$axios.get('http://localhost:8080/api/allCaches')
|
||||||
|
.then((response) => {
|
||||||
|
console.log("http://localhost:8080/api/allCaches");
|
||||||
|
console.log(JSON.stringify(this.data));
|
||||||
|
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('http://localhost:8080/api/getAllStations')
|
||||||
|
.then((response) => {
|
||||||
|
console.log("http://localhost:8080/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;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -15,17 +15,23 @@ const routes = [
|
|||||||
component: () => import("layouts/MyLayout.vue"),
|
component: () => import("layouts/MyLayout.vue"),
|
||||||
children: [{ path: "", component: () => import("pages/Cache.vue") }]
|
children: [{ path: "", component: () => import("pages/Cache.vue") }]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/cache/:id",
|
||||||
|
component: () => import("layouts/MyLayout.vue"),
|
||||||
|
children: [{ path: "", component: () => import("pages/Cache.vue") }]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/station/",
|
path: "/station/",
|
||||||
component: () => import("layouts/MyLayout.vue"),
|
component: () => import("layouts/MyLayout.vue"),
|
||||||
children: [{ path: "", component: () => import("pages/StationEdit.vue") }]
|
children: [{ path: "", component: () => import("pages/StationEdit.vue") }]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/station/:id",
|
path: "/station/:cache/:id",
|
||||||
component: () => import("layouts/MyLayout.vue"),
|
component: () => import("layouts/MyLayout.vue"),
|
||||||
children: [{ path: "", component: () => import("pages/StationView.vue") }]
|
children: [{ path: "", component: () => import("pages/StationView.vue") }]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
path: "/station-l/:pos",
|
||||||
path: "/ranking/",
|
path: "/ranking/",
|
||||||
component: () => import("layouts/MyLayout.vue"),
|
component: () => import("layouts/MyLayout.vue"),
|
||||||
children: [{path: "", component: () => import("pages/ranking.vue")}]
|
children: [{path: "", component: () => import("pages/ranking.vue")}]
|
||||||
@ -33,15 +39,9 @@ const routes = [
|
|||||||
{
|
{
|
||||||
path: "/station/",
|
path: "/station/",
|
||||||
component: () => import("layouts/MyLayout.vue"),
|
component: () => import("layouts/MyLayout.vue"),
|
||||||
// props: true,
|
children: [{ path: "", component: () => import("pages/StationEdit.vue") }]
|
||||||
children: [{
|
},
|
||||||
path: "",
|
{
|
||||||
component: () => import("pages/StationEdit.vue"),
|
|
||||||
// props: true
|
|
||||||
//props: ['stationObject']
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/login/",
|
path: "/login/",
|
||||||
component: () => import("layouts/MyLayout.vue"),
|
component: () => import("layouts/MyLayout.vue"),
|
||||||
children: [{ path: "", component: () => import("pages/Login.vue") }]
|
children: [{ path: "", component: () => import("pages/Login.vue") }]
|
||||||
|
|||||||
@ -1,4 +1,24 @@
|
|||||||
/*
|
/**
|
||||||
export function someGetter (state) {
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
export function GET_ADMINSTATE(state) {
|
||||||
|
console.log("GET_ADMINSTATE()");
|
||||||
|
if (state.userAuthenticated !== null) {
|
||||||
|
console.log(state.userAuthenticated.roles.find(x => x.name === "admin") != null);
|
||||||
|
return state.userAuthenticated.roles.find(x => x.name === "admin") != null;
|
||||||
|
} else {
|
||||||
|
console.log(state.userAuthenticated);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
// /**
|
||||||
|
// * @return {boolean}
|
||||||
|
// */
|
||||||
|
// export function IS_AUTHENTICATED(state) {
|
||||||
|
// console.log("IS_AUTHENTICATED()");
|
||||||
|
// console.log(JSON.parse(localStorage.getItem('userToken')));
|
||||||
|
// console.log(!(JSON.parse(localStorage.getItem('userToken')) === null));
|
||||||
|
// console.log(!(localStorage.getItem('userToken') === null));
|
||||||
|
// return !(localStorage.getItem('userToken') === null);
|
||||||
|
// }
|
||||||
|
|||||||
@ -1,17 +1,43 @@
|
|||||||
|
import axios from 'axios'
|
||||||
export const SET_AUTHENTICATED = (state) => {
|
export const SET_AUTHENTICATED = (state) => {
|
||||||
console.log("SET_AUTHENTICATED()");
|
console.log("SET_AUTHENTICATED()");
|
||||||
console.log(JSON.parse(localStorage.getItem('userToken')));
|
console.log(JSON.parse(localStorage.getItem('userToken')));
|
||||||
if (localStorage.getItem('userToken')) {
|
if (localStorage.getItem('userToken')) {
|
||||||
state.userAuthenticated.isAuthenticated = true;
|
state.isAuthenticated = true;
|
||||||
} else {
|
} else {
|
||||||
state.userAuthenticated.isAuthenticated = false;
|
state.isAuthenticated = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export const SET_USER_PROPERTIES = (state, user) => {
|
|
||||||
console.log("SET_USER_PROPERTIES()");
|
|
||||||
console.log("still todo!");
|
|
||||||
};
|
|
||||||
export const SET_LOGOUT = (state) => {
|
export const SET_LOGOUT = (state) => {
|
||||||
console.log("SET_LOGOUT()");
|
console.log("SET_LOGOUT()");
|
||||||
|
localStorage.removeItem('userToken');
|
||||||
state.userAuthenticated = null;
|
state.userAuthenticated = null;
|
||||||
|
state.isAuthenticated = false;
|
||||||
|
console.log(localStorage.getItem('userToken'));
|
||||||
};
|
};
|
||||||
|
export const SET_USER = (state) => {
|
||||||
|
console.log("SET_USER()");
|
||||||
|
if (localStorage.getItem('userToken')) {
|
||||||
|
axios.get('http://localhost:8080/api/getUser', {
|
||||||
|
params: {
|
||||||
|
token: JSON.parse(localStorage.getItem('userToken'))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
console.log("GET/POST http://localhost:8080/api/getUser - response: ");
|
||||||
|
console.log(response.data);
|
||||||
|
state.userAuthenticated = response.data;
|
||||||
|
state.isAuthenticated = true;
|
||||||
|
if (state.userAuthenticated.hasOwnProperty('password')) delete state.userAuthenticated.password;
|
||||||
|
console.log(state.userAuthenticated);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log("Catch Block: ")
|
||||||
|
console.log(error)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
state.isAuthenticated = false;
|
||||||
|
state.userAuthenticated = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,19 @@
|
|||||||
export default {
|
export default {
|
||||||
userAuthenticated: {
|
isAuthenticated: false,
|
||||||
id: 1,
|
userAuthenticated: null,
|
||||||
firstname: "t",
|
// userAuthenticated: {
|
||||||
lastname: "v",
|
// id: 1,
|
||||||
username: "mo",
|
// firstname: "Timo",
|
||||||
email: "test@user.com",
|
// lastname: "Volkmann",
|
||||||
rankingPointsSum: 345,
|
// username: "moximoti",
|
||||||
isAuthenticated: false,
|
// rankingPointsSum: 0,
|
||||||
isAdmin: true,
|
// email: "test@user.com",
|
||||||
},
|
// password: "$2a$10$c3Fo5nuUG.nlwXP94qc7qO01/UC1OL2DebEm.5zYlisKJGRhXMnqq",
|
||||||
|
// roles: [
|
||||||
|
// {
|
||||||
|
// id: 0,
|
||||||
|
// name: "admin"
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// },
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,17 +10,20 @@ export const ADD_STATION = (state, station) => {
|
|||||||
console.log("ADD_STATION: add new station to cache: "+station);
|
console.log("ADD_STATION: add new station to cache: "+station);
|
||||||
state.newCache.stationen.push(station);
|
state.newCache.stationen.push(station);
|
||||||
};
|
};
|
||||||
export const EDIT_STATION = (state, index, station) => {
|
export const EDIT_STATION = (state, indexStation) => {
|
||||||
console.log("ADD_STATION: add new station to cache: "+station);
|
let index, station;
|
||||||
|
index = indexStation.index;
|
||||||
|
station = indexStation.station;
|
||||||
|
console.log("EDIT_STATION: "+index+" "+station);
|
||||||
|
|
||||||
state.newCache.stationen[index] = station;
|
state.newCache.stationen[index] = station;
|
||||||
};
|
};
|
||||||
export const REMOVE_STATION = (state, index) => {
|
export const REMOVE_STATION = (state, index) => {
|
||||||
console.log("ADD_STATION: add new station to cache: "+station);
|
console.log("REMOVE_STATION: "+index);
|
||||||
state.newCache.stationen.splice(index,1);
|
state.newCache.stationen.splice(index,1);
|
||||||
};
|
};
|
||||||
export const RESET_NEW_CACHE = (state) => {
|
export const RESET_NEW_CACHE = (state) => {
|
||||||
state.newCache = {
|
state.newCache = {
|
||||||
id: null,
|
|
||||||
name: "",
|
name: "",
|
||||||
description: "",
|
description: "",
|
||||||
rankingPoints: 0,
|
rankingPoints: 0,
|
||||||
|
|||||||
@ -1,38 +1,44 @@
|
|||||||
export default {
|
export default {
|
||||||
newCache: {
|
newCache: {
|
||||||
name: "Blumencache",
|
name: "",
|
||||||
description: "Dieser Cache umfasst 4 Stationen mit Rätseln rund um das Thema Blumen",
|
description: "",
|
||||||
rankingPoints: 100,
|
rankingPoints: 0,
|
||||||
stationen: [
|
stationen: []
|
||||||
{
|
|
||||||
description: "Ein kleines winterliches Schlaginstrument. Welche Blume ist damit gemeint?",
|
|
||||||
longitude: 9.206628,
|
|
||||||
lattitude: 49.147734,
|
|
||||||
code: 213812,
|
|
||||||
solution: "Schneeglöckchen"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "Ein blühendes Federvieh. Welche Blume ist damit gemeint?",
|
|
||||||
longitude: 9.206806,
|
|
||||||
lattitude: 49.147318,
|
|
||||||
code: 237823,
|
|
||||||
solution: "Gänseblümchen"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "Eine wertvolle Farbe. Welche Blume ist damit gemeint?",
|
|
||||||
longitude: 9.207844,
|
|
||||||
lattitude: 49.148032,
|
|
||||||
code: 899423,
|
|
||||||
solution: "Edelweiß"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "Ein Zerkleinerungsgerät in der Brüllöffnung eines Raubtieres. Welche Blume ist damit gemeint?",
|
|
||||||
longitude: 9.207649,
|
|
||||||
lattitude: 49.150142,
|
|
||||||
code: 347923,
|
|
||||||
solution: "Löwenzahn"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
|
// newCache: {
|
||||||
|
// name: "Blumencache",
|
||||||
|
// description: "Dieser Cache umfasst 4 Stationen mit Rätseln rund um das Thema Blumen",
|
||||||
|
// rankingPoints: 100,
|
||||||
|
// stationen: [
|
||||||
|
// {
|
||||||
|
// description: "Ein kleines winterliches Schlaginstrument. Welche Blume ist damit gemeint?",
|
||||||
|
// longitude: 9.206628,
|
||||||
|
// lattitude: 49.147734,
|
||||||
|
// code: 213812,
|
||||||
|
// solution: "Schneeglöckchen"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// description: "Ein blühendes Federvieh. Welche Blume ist damit gemeint?",
|
||||||
|
// longitude: 9.206806,
|
||||||
|
// lattitude: 49.147318,
|
||||||
|
// code: 237823,
|
||||||
|
// solution: "Gänseblümchen"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// description: "Eine wertvolle Farbe. Welche Blume ist damit gemeint?",
|
||||||
|
// longitude: 9.207844,
|
||||||
|
// lattitude: 49.148032,
|
||||||
|
// code: 899423,
|
||||||
|
// solution: "Edelweiß"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// description: "Ein Zerkleinerungsgerät in der Brüllöffnung eines Raubtieres. Welche Blume ist damit gemeint?",
|
||||||
|
// longitude: 9.207649,
|
||||||
|
// lattitude: 49.150142,
|
||||||
|
// code: 347923,
|
||||||
|
// solution: "Löwenzahn"
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// },
|
||||||
tempStation: {},
|
tempStation: {},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,8 @@ export default function (/* { ssrContext } */) {
|
|||||||
|
|
||||||
// enable strict mode (adds overhead!)
|
// enable strict mode (adds overhead!)
|
||||||
// for dev mode only
|
// for dev mode only
|
||||||
strict: process.env.DEV
|
//strict: process.env.DEV
|
||||||
|
strict: false
|
||||||
})
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.xml.bind.DatatypeConverter;
|
import javax.xml.bind.DatatypeConverter;
|
||||||
|
import java.lang.reflect.Array;
|
||||||
import java.security.Key;
|
import java.security.Key;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -126,7 +127,6 @@ public class Controller {
|
|||||||
.setSigningKey(key)
|
.setSigningKey(key)
|
||||||
.parseClaimsJws(token).getBody();
|
.parseClaimsJws(token).getBody();
|
||||||
|
|
||||||
|
|
||||||
User user = userRepository.findByUsername(claims.getSubject());
|
User user = userRepository.findByUsername(claims.getSubject());
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return ResponseEntity.status(404).body("User was not found");
|
return ResponseEntity.status(404).body("User was not found");
|
||||||
@ -136,29 +136,35 @@ public class Controller {
|
|||||||
Optional<Cache> cacheOptional = cacheRepository.findById(Integer.valueOf(cacheID));
|
Optional<Cache> cacheOptional = cacheRepository.findById(Integer.valueOf(cacheID));
|
||||||
if (cacheOptional.isPresent()) {
|
if (cacheOptional.isPresent()) {
|
||||||
Cache cache = cacheOptional.get();
|
Cache cache = cacheOptional.get();
|
||||||
|
|
||||||
|
if (bearbeitetRepository.findByUserAndCache(user, cache) != null) {
|
||||||
|
Bearbeitet bearbeitet1 = bearbeitetRepository.findByUserAndCache(user, cache);
|
||||||
|
return ResponseEntity.status(200).body(bearbeitet1);
|
||||||
|
}
|
||||||
|
|
||||||
bearbeitet.setCache(cache);
|
bearbeitet.setCache(cache);
|
||||||
|
|
||||||
Station startStation = cache.getStationen().get(0);
|
Station startStation = cache.getStationen().get(0);
|
||||||
bearbeitet.setAktuelleStation(startStation);
|
bearbeitet.setAktuelleStation(startStation);
|
||||||
} else {
|
} else {
|
||||||
return ResponseEntity.status(404).body("Couldnt find Cache " + cacheID);
|
return ResponseEntity.status(404).body("Couldnt find Cache " + cacheID);
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<CacheAccesDefinition> cacheAccesDefinitionOptional =
|
Optional<CacheAccesDefinition> cacheAccesDefinitionOptional =
|
||||||
cacheAccesDefinitionRepository.findById(0); // angefangen
|
cacheAccesDefinitionRepository.findById(0); // angefangen
|
||||||
if (cacheAccesDefinitionOptional.isPresent()) {
|
if (cacheAccesDefinitionOptional.isPresent()) {
|
||||||
CacheAccesDefinition cacheAccesDefinition = cacheAccesDefinitionOptional.get();
|
CacheAccesDefinition cacheAccesDefinition = cacheAccesDefinitionOptional.get();
|
||||||
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
|
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
|
||||||
} else {
|
} else {
|
||||||
return ResponseEntity.status(404).body("There is no cacheAccesDefinition with the ID " + 0);
|
return ResponseEntity.status(404).body("There is no cacheAccesDefinition with the ID " + 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bearbeitetRepository.save(bearbeitet);
|
bearbeitetRepository.save(bearbeitet);
|
||||||
|
|
||||||
return ResponseEntity.status(200).body(new Gson().toJson(bearbeitet));
|
return ResponseEntity.status(201).body(new Gson().toJson(bearbeitet));
|
||||||
} catch (ExpiredJwtException e) {
|
} catch (ExpiredJwtException e) {
|
||||||
return ResponseEntity.status(400).body("JWT Token expired");
|
return ResponseEntity.status(400).body("JWT Token expired");
|
||||||
} catch (Exception e){
|
} catch (Exception e) {
|
||||||
return ResponseEntity.status(400).body("JWT Token invalid");
|
return ResponseEntity.status(400).body("JWT Token invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +200,9 @@ public class Controller {
|
|||||||
@RequestMapping("/api/createCache")
|
@RequestMapping("/api/createCache")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity createCache(@RequestBody Cache cache) {
|
public ResponseEntity createCache(@RequestBody Cache cache) {
|
||||||
|
System.out.println(cache.getName());
|
||||||
|
System.out.println(cache.getStationen().size());
|
||||||
|
// System.out.println(cache.getStationen().get(0).getId());
|
||||||
// Stationen werden in die Datenbank eingetragen
|
// Stationen werden in die Datenbank eingetragen
|
||||||
for (Station station : cache.getStationen()) {
|
for (Station station : cache.getStationen()) {
|
||||||
ResponseEntity response = createStation(station);
|
ResponseEntity response = createStation(station);
|
||||||
@ -203,9 +211,9 @@ public class Controller {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("Stationen eingetragen!");
|
||||||
// Caches werden in die Datenbank eingetragen
|
// Caches werden in die Datenbank eingetragen
|
||||||
if (cache.getDescription().length() == 0 || cache.getName().length() == 0 || cache.getRankingPoints() == 0.0 || cache.getStationen().size() == 0) {
|
if (cache.getDescription().length() == 0 || cache.getName().length() == 0 || cache.getRankingPoints() == 0.0 || cache.getStationen().size() < 2) {
|
||||||
deleteStationen(cache);
|
deleteStationen(cache);
|
||||||
return ResponseEntity.status(400).body("cache fields can´t be empty");
|
return ResponseEntity.status(400).body("cache fields can´t be empty");
|
||||||
}
|
}
|
||||||
@ -229,7 +237,7 @@ public class Controller {
|
|||||||
|
|
||||||
public ResponseEntity createStation(Station station) {
|
public ResponseEntity createStation(Station station) {
|
||||||
|
|
||||||
if (station.getDescription().length() == 0 || station.getLattitude() == 0.0 || station.getLongitude() == 0.0 || station.getSolution().length() == 0) {
|
if (station.getDescription().length() == 0 || station.getLattitude() == 0.0 || station.getLongitude() == 0.0 /*|| station.getSolution().length() == 0*/) {
|
||||||
return ResponseEntity.status(400).body("station fields can´t be empty");
|
return ResponseEntity.status(400).body("station fields can´t be empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,9 +293,9 @@ public class Controller {
|
|||||||
.parseClaimsJws(token).getBody();
|
.parseClaimsJws(token).getBody();
|
||||||
|
|
||||||
return ResponseEntity.status(200).body(claims.get("admin"));
|
return ResponseEntity.status(200).body(claims.get("admin"));
|
||||||
}catch (ExpiredJwtException e) {
|
} catch (ExpiredJwtException e) {
|
||||||
return ResponseEntity.status(400).body("JWT Token expired");
|
return ResponseEntity.status(400).body("JWT Token expired");
|
||||||
} catch (Exception e){
|
} catch (Exception e) {
|
||||||
return ResponseEntity.status(400).body("JWT Token invalid");
|
return ResponseEntity.status(400).body("JWT Token invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,8 +336,18 @@ public class Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArrayList<Station> stationen = new ArrayList<>();
|
||||||
|
for (Station station : cache.getStationen()) {
|
||||||
|
stationen.add(stationRepository.findById(station.getId()).get());
|
||||||
|
}
|
||||||
|
|
||||||
cacheRepository.delete(cache);
|
cacheRepository.delete(cache);
|
||||||
|
|
||||||
|
for (Station station : stationen) {
|
||||||
|
stationRepository.delete(station);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return ResponseEntity.status(200).body(new Gson().toJson(true));
|
return ResponseEntity.status(200).body(new Gson().toJson(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,7 +378,7 @@ public class Controller {
|
|||||||
}
|
}
|
||||||
} catch (ExpiredJwtException e) {
|
} catch (ExpiredJwtException e) {
|
||||||
return ResponseEntity.status(400).body("JWT Token expired");
|
return ResponseEntity.status(400).body("JWT Token expired");
|
||||||
} catch (Exception e){
|
} catch (Exception e) {
|
||||||
return ResponseEntity.status(400).body("JWT Token invalid");
|
return ResponseEntity.status(400).body("JWT Token invalid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -401,7 +419,7 @@ public class Controller {
|
|||||||
}
|
}
|
||||||
} catch (ExpiredJwtException e) {
|
} catch (ExpiredJwtException e) {
|
||||||
return ResponseEntity.status(400).body("JWT Token expired");
|
return ResponseEntity.status(400).body("JWT Token expired");
|
||||||
} catch (Exception e){
|
} catch (Exception e) {
|
||||||
return ResponseEntity.status(400).body("JWT Token invalid");
|
return ResponseEntity.status(400).body("JWT Token invalid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
package hhn.labsw.bugageocaching.repositories;
|
package hhn.labsw.bugageocaching.repositories;
|
||||||
|
|
||||||
import hhn.labsw.bugageocaching.entities.Bearbeitet;
|
import hhn.labsw.bugageocaching.entities.Bearbeitet;
|
||||||
|
import hhn.labsw.bugageocaching.entities.Cache;
|
||||||
|
import hhn.labsw.bugageocaching.entities.User;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
public interface BearbeitetRepository extends JpaRepository<Bearbeitet, Integer> {
|
public interface BearbeitetRepository extends JpaRepository<Bearbeitet, Integer> {
|
||||||
|
Bearbeitet findByUserAndCache(User user, Cache cache);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user