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"
|
||||
@change="cacheToStore"/>
|
||||
<q-input
|
||||
disable
|
||||
v-model="tempCache.reward"
|
||||
dense
|
||||
stack-label
|
||||
@ -52,7 +53,7 @@
|
||||
|
||||
<q-item-section side>
|
||||
<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"/>
|
||||
</div>
|
||||
</q-item-section>
|
||||
@ -94,7 +95,7 @@
|
||||
created: function () {
|
||||
console.log("isNewCache: " + this.isNewCache);
|
||||
console.log("fetch Caches from Store");
|
||||
this.tempCache = JSON.parse(JSON.stringify(this.cache))
|
||||
this.tempCache = JSON.parse(JSON.stringify(this.cache));
|
||||
},
|
||||
beforeMount: function () {
|
||||
},
|
||||
@ -137,15 +138,16 @@
|
||||
const station = this.cache.stationen[index];
|
||||
console.log(station)
|
||||
if (station.hasOwnProperty('id') ) {
|
||||
this.$router.push({ path: '/station/'+station.id});
|
||||
//this.$router.push({ path: '/station/'+station.id});
|
||||
} else {
|
||||
// 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.$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() {
|
||||
// commit to store, send to api, if success -> reset store
|
||||
@ -155,6 +157,7 @@
|
||||
this.$axios.post('http://localhost:8080/api/createCache', this.cache)
|
||||
.then((response) => {
|
||||
console.log("POST api/createCache: " + response.statusText);
|
||||
this.$store.commit('cacheCollector/RESET_NEW_CACHE');
|
||||
this.$router.push({ path: '/overview' });
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
@ -1,48 +1,50 @@
|
||||
<template>
|
||||
<div class="q-pa-md">
|
||||
<form class="login" @submit.prevent="login">
|
||||
<div class="q-pa-md">
|
||||
<div class="column q-gutter-lg" style="">
|
||||
<div class="col">
|
||||
<div class="">
|
||||
<div class="" style="max-width: 440px">
|
||||
<q-input outlined filled stack-label v-model="user.username" type="text" label="Benutzername" autocomplete="username"/>
|
||||
</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 class="q-pa-md">
|
||||
<div class="column q-gutter-lg" style="">
|
||||
<div class="col">
|
||||
<div class="">
|
||||
<div class="" style="max-width: 440px">
|
||||
<q-input outlined filled stack-label v-model="user.username" type="text" label="Benutzername"
|
||||
autocomplete="username"/>
|
||||
</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>
|
||||
<q-dialog v-model="credentialsDialog" persistent transition-show="scale" transition-hide="scale">
|
||||
<q-card class="bg-red-9 text-white" style="">
|
||||
@ -55,10 +57,11 @@
|
||||
</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-btn flat label="OK" color="red-9" v-close-popup/>
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-dialog> </div>
|
||||
</q-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@ -80,17 +83,21 @@
|
||||
// console.log("initiated");
|
||||
// }
|
||||
// },
|
||||
created () {
|
||||
created() {
|
||||
this.evalAuthentication();
|
||||
console.log("created: initiated");
|
||||
},
|
||||
computed: {
|
||||
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: {
|
||||
login: function () {
|
||||
|
||||
const data = {
|
||||
username: this.user.username,
|
||||
password: this.user.password
|
||||
@ -107,25 +114,26 @@
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("error: " + error);
|
||||
this.credentialsDialog=true;
|
||||
this.credentialsDialog = true;
|
||||
})
|
||||
},
|
||||
evalAuthentication: function () {
|
||||
this.$store.commit('auth/SET_AUTHENTICATED');
|
||||
this.$store.commit('auth/SET_USER');
|
||||
},
|
||||
logout: function () {
|
||||
console.log("logout()");
|
||||
console.log(JSON.parse(localStorage.getItem('userToken')));
|
||||
this.$axios.get('http://localhost:8080/api/logout', {
|
||||
params: {
|
||||
token: JSON.parse(localStorage.getItem('userToken'))
|
||||
}
|
||||
})
|
||||
.then((response) => {
|
||||
console.log("GET/POST http://localhost:8080/api/logout/ - response: " + response.data);
|
||||
})
|
||||
.catch((error) => {
|
||||
});
|
||||
// this.$axios.get('http://localhost:8080/api/logout', {
|
||||
// params: {
|
||||
// token: JSON.parse(localStorage.getItem('userToken'))
|
||||
// }
|
||||
// })
|
||||
// .then((response) => {
|
||||
// console.log("GET/POST http://localhost:8080/api/logout/ - response: " + response.data);
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// });
|
||||
localStorage.removeItem('userToken');
|
||||
this.evalAuthentication();
|
||||
},
|
||||
|
||||
@ -24,35 +24,39 @@
|
||||
|
||||
<q-list>
|
||||
<q-card class="q-mb-md" v-for="cache in caches" :key="cache.id">
|
||||
<q-expansion-item
|
||||
class=""
|
||||
expand-icon-toggle
|
||||
expand-separator
|
||||
icon="location_on"
|
||||
:label="cache.name"
|
||||
:caption="cache.rankingPoints+' Punkte / Size '+cache.stationen.length"
|
||||
>
|
||||
<q-item>
|
||||
<q-item-section top avatar class="self-center">
|
||||
<!--<q-icon rounded color="cyan-14" name="location_on" size="3rem"/>-->
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-item-label caption>{{ cache.description }}</q-item-label>
|
||||
</q-item-section>
|
||||
<q-expansion-item
|
||||
class=""
|
||||
expand-icon-toggle
|
||||
expand-separator
|
||||
icon="location_on"
|
||||
:label="cache.name"
|
||||
:caption="cache.rankingPoints+' Punkte / Size '+cache.stationen.length"
|
||||
>
|
||||
<q-item>
|
||||
<q-item-section top avatar class="self-center">
|
||||
<!--<q-icon rounded color="cyan-14" name="location_on" size="3rem"/>-->
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-item-label caption>{{ cache.description }}</q-item-label>
|
||||
</q-item-section>
|
||||
|
||||
<q-item-section side top class="self-center" >
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<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 v-if="hasAdminState" @click="editCache(cache.id)" unelevated color="amber" stack icon="edit" label="Bearbeiten" size="sm"/>
|
||||
<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-item-section side top class="self-center">
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<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 disable v-if="hasAdminState" @click="editCache(cache.id)" unelevated color="amber" stack
|
||||
icon="edit" label="Bearbeiten" size="sm"/>
|
||||
<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-list>
|
||||
<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>
|
||||
</q-tab-panel>
|
||||
|
||||
@ -60,7 +64,9 @@
|
||||
<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>-->
|
||||
<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>
|
||||
<q-spinner-puff color="cyan-14" size="4em"/>
|
||||
</template>
|
||||
@ -68,40 +74,59 @@
|
||||
</q-tab-panel>
|
||||
|
||||
</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>
|
||||
</q-page>
|
||||
|
||||
</template>
|
||||
|
||||
<style>
|
||||
/*
|
||||
.my-list-card-item
|
||||
padding-left: 8px
|
||||
*/
|
||||
/*
|
||||
.my-list-card-item
|
||||
padding-left: 8px
|
||||
*/
|
||||
</style>
|
||||
<script>
|
||||
//import {dom} from 'quasar'
|
||||
//const {height, width} = dom
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
tab: 'list',
|
||||
// hheight: 71.0,
|
||||
// fheight: 36.0, //37
|
||||
//header: {h: '0px', w: 0}
|
||||
caches: [],
|
||||
dialog: false,
|
||||
dialogMsg: "",
|
||||
}
|
||||
},
|
||||
mounted: function () {
|
||||
},
|
||||
computed: {
|
||||
// ...mapGetters([
|
||||
// 'auth/GET_ADMINSTATE'
|
||||
// ]),
|
||||
|
||||
hasAdminState() {
|
||||
return this.$store.state.auth.userAuthenticated.isAdmin
|
||||
return this.$store.getters['auth/GET_ADMINSTATE'];
|
||||
}
|
||||
},
|
||||
created: function() {
|
||||
created: function () {
|
||||
console.log("created(): " + this.caches);
|
||||
this.fetchAllCaches();
|
||||
this.$store.commit('auth/SET_AUTHENTICATED');
|
||||
this.$store.commit('auth/SET_USER');
|
||||
},
|
||||
methods: {
|
||||
fetchAllCaches() {
|
||||
@ -112,27 +137,33 @@
|
||||
})
|
||||
},
|
||||
addCache() {
|
||||
this.$router.push({ path: `/cache` })
|
||||
this.$router.push({path: `/cache`})
|
||||
},
|
||||
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) {
|
||||
const userToken = JSON.parse(localStorage.getItem('userToken'));
|
||||
let params = { cacheID: cacheID };
|
||||
let params = {cacheID: cacheID};
|
||||
if (userToken != null) {
|
||||
params.token = userToken;
|
||||
}
|
||||
console.log(params);
|
||||
|
||||
this.$axios.get('http://localhost:8080/api/startCache', { params })
|
||||
this.$axios.get('http://localhost:8080/api/startCache', {params})
|
||||
.then((response) => {
|
||||
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;
|
||||
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>
|
||||
<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 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">
|
||||
<q-btn @click="saveStation" unelevated color="primary" label="Speichern" icon-right="add"/>
|
||||
<q-btn @click="dismiss" unelevated color="negative" label="verwerfen" icon-right="delete"/>
|
||||
@ -45,11 +45,11 @@
|
||||
description: "Rätsel, Aufgabe und Informationen zur Station.",
|
||||
latlang: "",
|
||||
station: {
|
||||
description: "description",
|
||||
lattitude: 0.06470,
|
||||
longitude: 0.05551,
|
||||
solution: "solution",
|
||||
code: 357547
|
||||
description: "Beschreibung",
|
||||
lattitude: "0.000",
|
||||
longitude: "0.000",
|
||||
solution: "",
|
||||
code: ""
|
||||
},
|
||||
isNewStation: true,
|
||||
// stationObject: null,
|
||||
@ -57,15 +57,19 @@
|
||||
},
|
||||
// props: [ 'stationObject' ],
|
||||
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);
|
||||
},
|
||||
beforeMount: function() {
|
||||
},
|
||||
mounted: function() {
|
||||
this.isNewStation = this.$route.params.pos === undefined;
|
||||
console.log("neu: "+this.isNewStation);
|
||||
console.log("pos: "+this.$route.params.pos);
|
||||
this.concatLatlang();
|
||||
},
|
||||
computed: {
|
||||
@ -87,20 +91,19 @@
|
||||
this.latlang = this.station.lattitude+", "+this.station.longitude;
|
||||
},
|
||||
saveStation() {
|
||||
//this.$parent.swapComponent(null);
|
||||
// this.$emit('q-tb');
|
||||
console.log("saveStation(): ");
|
||||
if (isNewStation) {
|
||||
console.log(this.station);
|
||||
if (this.isNewStation) {
|
||||
this.$store.commit('cacheCollector/ADD_STATION', this.station);
|
||||
} 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.$router.push({ path: `/cache` });
|
||||
console.log("station saved..");
|
||||
},
|
||||
dismiss() {
|
||||
this.$emit('q-tb');
|
||||
this.$store.commit('cacheCollector/SET_TEMPSTATION', null);
|
||||
this.$router.push({ path: `/cache` });
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,8 @@
|
||||
></q-img>
|
||||
<div class="q-ma-md">
|
||||
<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>
|
||||
<!--<q-input-->
|
||||
<!--v-model="description"-->
|
||||
@ -32,12 +33,11 @@
|
||||
data() {
|
||||
return {
|
||||
code: "",
|
||||
cache: null,
|
||||
data: {
|
||||
cacheId: 22,
|
||||
cacheName: "Wasserfall Cache",
|
||||
nextStationId: 44,
|
||||
station: {
|
||||
position: 1,
|
||||
id: 22,
|
||||
description: "Ein kleines winterliches Schlaginstrument. Welche Blume ist damit gemeint?",
|
||||
longitude: 9.206628,
|
||||
@ -49,14 +49,46 @@
|
||||
}
|
||||
},
|
||||
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 () {
|
||||
},
|
||||
mounted: function () {
|
||||
console.log("'id' from url: " + this.$route.params.id)
|
||||
},
|
||||
computed: {},
|
||||
methods: {}
|
||||
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}`;
|
||||
}
|
||||
},
|
||||
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>
|
||||
|
||||
|
||||
@ -15,17 +15,23 @@ const routes = [
|
||||
component: () => import("layouts/MyLayout.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/",
|
||||
component: () => import("layouts/MyLayout.vue"),
|
||||
children: [{ path: "", component: () => import("pages/StationEdit.vue") }]
|
||||
},
|
||||
{
|
||||
path: "/station/:id",
|
||||
path: "/station/:cache/:id",
|
||||
component: () => import("layouts/MyLayout.vue"),
|
||||
children: [{ path: "", component: () => import("pages/StationView.vue") }]
|
||||
},
|
||||
{
|
||||
path: "/station-l/:pos",
|
||||
path: "/ranking/",
|
||||
component: () => import("layouts/MyLayout.vue"),
|
||||
children: [{path: "", component: () => import("pages/ranking.vue")}]
|
||||
@ -33,15 +39,9 @@ const routes = [
|
||||
{
|
||||
path: "/station/",
|
||||
component: () => import("layouts/MyLayout.vue"),
|
||||
// props: true,
|
||||
children: [{
|
||||
path: "",
|
||||
component: () => import("pages/StationEdit.vue"),
|
||||
// props: true
|
||||
//props: ['stationObject']
|
||||
}]
|
||||
},
|
||||
{
|
||||
children: [{ path: "", component: () => import("pages/StationEdit.vue") }]
|
||||
},
|
||||
{
|
||||
path: "/login/",
|
||||
component: () => import("layouts/MyLayout.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) => {
|
||||
console.log("SET_AUTHENTICATED()");
|
||||
console.log(JSON.parse(localStorage.getItem('userToken')));
|
||||
if (localStorage.getItem('userToken')) {
|
||||
state.userAuthenticated.isAuthenticated = true;
|
||||
state.isAuthenticated = true;
|
||||
} 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) => {
|
||||
console.log("SET_LOGOUT()");
|
||||
localStorage.removeItem('userToken');
|
||||
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 {
|
||||
userAuthenticated: {
|
||||
id: 1,
|
||||
firstname: "t",
|
||||
lastname: "v",
|
||||
username: "mo",
|
||||
email: "test@user.com",
|
||||
rankingPointsSum: 345,
|
||||
isAuthenticated: false,
|
||||
isAdmin: true,
|
||||
},
|
||||
isAuthenticated: false,
|
||||
userAuthenticated: null,
|
||||
// userAuthenticated: {
|
||||
// id: 1,
|
||||
// firstname: "Timo",
|
||||
// lastname: "Volkmann",
|
||||
// username: "moximoti",
|
||||
// rankingPointsSum: 0,
|
||||
// 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);
|
||||
state.newCache.stationen.push(station);
|
||||
};
|
||||
export const EDIT_STATION = (state, index, station) => {
|
||||
console.log("ADD_STATION: add new station to cache: "+station);
|
||||
export const EDIT_STATION = (state, indexStation) => {
|
||||
let index, station;
|
||||
index = indexStation.index;
|
||||
station = indexStation.station;
|
||||
console.log("EDIT_STATION: "+index+" "+station);
|
||||
|
||||
state.newCache.stationen[index] = station;
|
||||
};
|
||||
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);
|
||||
};
|
||||
export const RESET_NEW_CACHE = (state) => {
|
||||
state.newCache = {
|
||||
id: null,
|
||||
name: "",
|
||||
description: "",
|
||||
rankingPoints: 0,
|
||||
|
||||
@ -1,38 +1,44 @@
|
||||
export default {
|
||||
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"
|
||||
}
|
||||
]
|
||||
name: "",
|
||||
description: "",
|
||||
rankingPoints: 0,
|
||||
stationen: []
|
||||
},
|
||||
// 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: {},
|
||||
}
|
||||
|
||||
@ -22,7 +22,8 @@ export default function (/* { ssrContext } */) {
|
||||
|
||||
// enable strict mode (adds overhead!)
|
||||
// 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.xml.bind.DatatypeConverter;
|
||||
import java.lang.reflect.Array;
|
||||
import java.security.Key;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.*;
|
||||
@ -126,7 +127,6 @@ public class Controller {
|
||||
.setSigningKey(key)
|
||||
.parseClaimsJws(token).getBody();
|
||||
|
||||
|
||||
User user = userRepository.findByUsername(claims.getSubject());
|
||||
if (user == null) {
|
||||
return ResponseEntity.status(404).body("User was not found");
|
||||
@ -136,29 +136,35 @@ public class Controller {
|
||||
Optional<Cache> cacheOptional = cacheRepository.findById(Integer.valueOf(cacheID));
|
||||
if (cacheOptional.isPresent()) {
|
||||
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);
|
||||
|
||||
Station startStation = cache.getStationen().get(0);
|
||||
bearbeitet.setAktuelleStation(startStation);
|
||||
} else {
|
||||
return ResponseEntity.status(404).body("Couldnt find Cache " + cacheID);
|
||||
}
|
||||
Station startStation = cache.getStationen().get(0);
|
||||
bearbeitet.setAktuelleStation(startStation);
|
||||
} else {
|
||||
return ResponseEntity.status(404).body("Couldnt find Cache " + cacheID);
|
||||
}
|
||||
|
||||
Optional<CacheAccesDefinition> cacheAccesDefinitionOptional =
|
||||
cacheAccesDefinitionRepository.findById(0); // angefangen
|
||||
if (cacheAccesDefinitionOptional.isPresent()) {
|
||||
CacheAccesDefinition cacheAccesDefinition = cacheAccesDefinitionOptional.get();
|
||||
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
|
||||
} else {
|
||||
return ResponseEntity.status(404).body("There is no cacheAccesDefinition with the ID " + 0);
|
||||
}
|
||||
Optional<CacheAccesDefinition> cacheAccesDefinitionOptional =
|
||||
cacheAccesDefinitionRepository.findById(0); // angefangen
|
||||
if (cacheAccesDefinitionOptional.isPresent()) {
|
||||
CacheAccesDefinition cacheAccesDefinition = cacheAccesDefinitionOptional.get();
|
||||
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
|
||||
} else {
|
||||
return ResponseEntity.status(404).body("There is no cacheAccesDefinition with the ID " + 0);
|
||||
}
|
||||
|
||||
bearbeitetRepository.save(bearbeitet);
|
||||
|
||||
return ResponseEntity.status(200).body(new Gson().toJson(bearbeitet));
|
||||
return ResponseEntity.status(201).body(new Gson().toJson(bearbeitet));
|
||||
} catch (ExpiredJwtException e) {
|
||||
return ResponseEntity.status(400).body("JWT Token expired");
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(400).body("JWT Token invalid");
|
||||
}
|
||||
|
||||
@ -194,7 +200,9 @@ public class Controller {
|
||||
@RequestMapping("/api/createCache")
|
||||
@ResponseBody
|
||||
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
|
||||
for (Station station : cache.getStationen()) {
|
||||
ResponseEntity response = createStation(station);
|
||||
@ -203,9 +211,9 @@ public class Controller {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Stationen 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);
|
||||
return ResponseEntity.status(400).body("cache fields can´t be empty");
|
||||
}
|
||||
@ -229,7 +237,7 @@ public class Controller {
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
@ -285,9 +293,9 @@ public class Controller {
|
||||
.parseClaimsJws(token).getBody();
|
||||
|
||||
return ResponseEntity.status(200).body(claims.get("admin"));
|
||||
}catch (ExpiredJwtException e) {
|
||||
} catch (ExpiredJwtException e) {
|
||||
return ResponseEntity.status(400).body("JWT Token expired");
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
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);
|
||||
|
||||
for (Station station : stationen) {
|
||||
stationRepository.delete(station);
|
||||
}
|
||||
|
||||
|
||||
return ResponseEntity.status(200).body(new Gson().toJson(true));
|
||||
}
|
||||
|
||||
@ -360,7 +378,7 @@ public class Controller {
|
||||
}
|
||||
} catch (ExpiredJwtException e) {
|
||||
return ResponseEntity.status(400).body("JWT Token expired");
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(400).body("JWT Token invalid");
|
||||
}
|
||||
}
|
||||
@ -401,7 +419,7 @@ public class Controller {
|
||||
}
|
||||
} catch (ExpiredJwtException e) {
|
||||
return ResponseEntity.status(400).body("JWT Token expired");
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(400).body("JWT Token invalid");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
package hhn.labsw.bugageocaching.repositories;
|
||||
|
||||
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.repository.CrudRepository;
|
||||
|
||||
public interface BearbeitetRepository extends JpaRepository<Bearbeitet, Integer> {
|
||||
Bearbeitet findByUserAndCache(User user, Cache cache);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user