Merge branch 'develop' into frontend/robin
This commit is contained in:
commit
0675bdc2a4
@ -93,9 +93,15 @@
|
|||||||
console.log(params);
|
console.log(params);
|
||||||
if (!params.cacheID || !params.stationID || !params.durchgefuehrterCacheID || !params.token) {
|
if (!params.cacheID || !params.stationID || !params.durchgefuehrterCacheID || !params.token) {
|
||||||
console.log("Mindestens 1 Parameter konnte nicht erkannt werden!");
|
console.log("Mindestens 1 Parameter konnte nicht erkannt werden!");
|
||||||
|
let header = "Fehler!";
|
||||||
|
let message = "Der erkannte QR-Code ist fehlerhaft oder gehört nicht zu BuGa Geocaching.";
|
||||||
|
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: message, title: header, });
|
||||||
resolve(false);
|
resolve(false);
|
||||||
} else if (isNaN(params.cacheID) || isNaN(params.stationID) || isNaN(params.durchgefuehrterCacheID)) {
|
} else if (isNaN(params.cacheID) || isNaN(params.stationID) || isNaN(params.durchgefuehrterCacheID)) {
|
||||||
console.log("Mindestens 1 Parameter ist fehlerhaft!");
|
console.log("Mindestens 1 Parameter ist fehlerhaft!");
|
||||||
|
let header = "Fehler!";
|
||||||
|
let message = "Der erkannte QR-Code ist fehlerhaft oder gehört nicht zu BuGa Geocaching.";
|
||||||
|
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: message, title: header, });
|
||||||
resolve(false);
|
resolve(false);
|
||||||
} else {
|
} else {
|
||||||
this.$axios.put('/api/checkStation', null, { params })
|
this.$axios.put('/api/checkStation', null, { params })
|
||||||
@ -162,12 +168,12 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
updateProps() {
|
updateProps() {
|
||||||
console.log("emit result!")
|
console.log("emit result!");
|
||||||
this.$emit('result', this.params)
|
this.$emit('result', this.params)
|
||||||
},
|
},
|
||||||
updateCameraState() {
|
updateCameraState() {
|
||||||
console.log("Camera State:")
|
console.log("Camera State:");
|
||||||
console.log(!this.askForPermission)
|
console.log(!this.askForPermission);
|
||||||
this.$emit('camera', !this.askForPermission)
|
this.$emit('camera', !this.askForPermission)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<q-layout view="hhh Lpr lFf">
|
<q-layout view="hhh Lpr lFf" @click.native="counter()">
|
||||||
<q-header id="qheader" class="bg-white text-grey-14" elevated>
|
<q-header id="qheader" class="bg-white text-grey-14" elevated>
|
||||||
<q-toolbar class="q-pa-md">
|
<q-toolbar class="q-pa-md">
|
||||||
<q-img src="statics/buga_logo.svg" style="max-width: 40px;" class="q-mr-sm"/>
|
<q-img src="statics/buga_logo.svg" style="max-width: 40px;" class="q-mr-sm"/>
|
||||||
@ -162,6 +162,17 @@
|
|||||||
<q-item-label>Login</q-item-label>
|
<q-item-label>Login</q-item-label>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
|
|
||||||
|
<!-- <q-item-->
|
||||||
|
<!-- disable-->
|
||||||
|
<!-- class="text-grey-5"-->
|
||||||
|
<!-- >-->
|
||||||
|
<!-- <q-item-section avatar>-->
|
||||||
|
<!-- </q-item-section>-->
|
||||||
|
<!-- <q-item-section>-->
|
||||||
|
<!-- <q-item-label>dev: {{ clickCounter }} clicks</q-item-label>-->
|
||||||
|
<!-- </q-item-section>-->
|
||||||
|
<!-- </q-item>-->
|
||||||
</q-list>
|
</q-list>
|
||||||
</q-drawer>
|
</q-drawer>
|
||||||
|
|
||||||
@ -196,6 +207,7 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
leftDrawerOpen: this.$q.platform.is.desktop,
|
leftDrawerOpen: this.$q.platform.is.desktop,
|
||||||
|
clickCounter: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -238,7 +250,10 @@
|
|||||||
//this.evalAuthentication();
|
//this.evalAuthentication();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
//openURL
|
counter() {
|
||||||
|
this.clickCounter++;
|
||||||
|
//console.log(this.clickCounter);
|
||||||
|
},
|
||||||
dialogClose() {
|
dialogClose() {
|
||||||
console.log("dialogClose(): ")
|
console.log("dialogClose(): ")
|
||||||
this.$store.commit('dialog/RESET_MESSAGE_DIALOG');
|
this.$store.commit('dialog/RESET_MESSAGE_DIALOG');
|
||||||
|
|||||||
@ -124,7 +124,7 @@
|
|||||||
created: function () {
|
created: function () {
|
||||||
console.log("isNewCache: " + this.isNewCache);
|
console.log("isNewCache: " + this.isNewCache);
|
||||||
console.log("Route Params: " + this.$route.params.id);
|
console.log("Route Params: " + this.$route.params.id);
|
||||||
if (!this.isNewCache) {
|
if (!this.isNewCache && !this.$store.getters['cacheCollector/GET_LOCK']) {
|
||||||
this.$axios.get('/api/allCaches')
|
this.$axios.get('/api/allCaches')
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log("/api/allCaches");
|
console.log("/api/allCaches");
|
||||||
@ -140,8 +140,8 @@
|
|||||||
this.$store.commit('cacheCollector/SET_STATIONS', stations);
|
this.$store.commit('cacheCollector/SET_STATIONS', stations);
|
||||||
this.$store.commit('cacheCollector/SET_ENDSTATION', endstation);
|
this.$store.commit('cacheCollector/SET_ENDSTATION', endstation);
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
this.$store.commit('cacheCollector/SET_LOCK', false);
|
||||||
},
|
},
|
||||||
beforeMount: function () {
|
beforeMount: function () {
|
||||||
},
|
},
|
||||||
@ -174,25 +174,22 @@
|
|||||||
console.log(this.$store.getters['cacheCollector/GET_STATIONS']);
|
console.log(this.$store.getters['cacheCollector/GET_STATIONS']);
|
||||||
const station = this.$store.getters['cacheCollector/GET_STATIONS'][index];
|
const station = this.$store.getters['cacheCollector/GET_STATIONS'][index];
|
||||||
console.log(station);
|
console.log(station);
|
||||||
if (station.hasOwnProperty('id')) {
|
this.$store.commit('cacheCollector/SET_TEMPSTATION', station);
|
||||||
//this.$router.push({ path: '/station/'+station.id});
|
this.$store.commit('cacheCollector/SET_LOCK', true);
|
||||||
} else {
|
this.$router.push({path: `/tempstation/${index}`}); // add parameter
|
||||||
// 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: `/tempstation/${index}`}); // add parameter
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
deleteStation(index) {
|
deleteStation(index) {
|
||||||
// TODO wenn Station id hat, mit Backend abgleichen
|
|
||||||
this.$store.commit('cacheCollector/REMOVE_STATION', index);
|
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
|
||||||
|
console.log("saveCache!");
|
||||||
let cache = JSON.parse(JSON.stringify(this.computedCache));
|
let cache = JSON.parse(JSON.stringify(this.computedCache));
|
||||||
console.log(cache);
|
console.log(cache);
|
||||||
cache.stationen.push(this.computedEndstation);
|
cache.stationen.push(this.computedEndstation);
|
||||||
|
console.log("isnewcache "+this.isNewCache)
|
||||||
if (this.isNewCache) {
|
if (this.isNewCache) {
|
||||||
|
console.log("CREATECACHE")
|
||||||
this.$axios.post('/api/createCache', cache)
|
this.$axios.post('/api/createCache', cache)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log("POST api/createCache: " + response.statusText);
|
console.log("POST api/createCache: " + response.statusText);
|
||||||
@ -217,6 +214,7 @@
|
|||||||
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
|
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
console.log("EDITCACHE")
|
||||||
this.$axios.put('/api/editCache', cache)
|
this.$axios.put('/api/editCache', cache)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log("POST api/editCache: " + response.statusText);
|
console.log("POST api/editCache: " + response.statusText);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="q-pa-md">
|
<div class="q-pa-md">
|
||||||
<form class="login">
|
<form class="login" @submit.prevent="login">
|
||||||
<div class="q-pa-md">
|
<div class="q-pa-md">
|
||||||
<p class="text-black text-h5"> Login </p>
|
<p class="text-black text-h5"> Login </p>
|
||||||
<div class="column q-gutter-lg" style="">
|
<div class="column q-gutter-lg" style="">
|
||||||
@ -24,14 +24,13 @@
|
|||||||
<div class="">
|
<div class="">
|
||||||
<div class="" style="max-width: 440px">
|
<div class="" style="max-width: 440px">
|
||||||
<q-btn
|
<q-btn
|
||||||
|
type="submit"
|
||||||
:outline="userAuthenticated"
|
:outline="userAuthenticated"
|
||||||
:disabled="!loginValidation"
|
:disabled="!loginValidation"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
label="Login"
|
label="Login"
|
||||||
color="primary"
|
color="primary"
|
||||||
class="full-width"
|
class="full-width"
|
||||||
@click="login"
|
|
||||||
@keyup.enter="login"
|
|
||||||
unelevated
|
unelevated
|
||||||
>
|
>
|
||||||
<template v-slot:loading>
|
<template v-slot:loading>
|
||||||
@ -114,7 +113,7 @@
|
|||||||
let title;
|
let title;
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
title = "Fehler!";
|
title = "Fehler!";
|
||||||
msg = error.response.data;
|
msg = "E-Mail oder Passwort ist falsch. Bitte überprüfe deine Eingaben!";
|
||||||
} else if (error.request) {
|
} else if (error.request) {
|
||||||
title = "Verbindungsfehler!";
|
title = "Verbindungsfehler!";
|
||||||
msg = "Es konnte keine Verbindung zum Server aufgebaut werden. Versuchen Sie es später noch einmal!"
|
msg = "Es konnte keine Verbindung zum Server aufgebaut werden. Versuchen Sie es später noch einmal!"
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
<q-tab-panels v-model="tab" animated swipeable class="col">
|
<q-tab-panels v-model="tab" animated swipeable class="col">
|
||||||
|
|
||||||
<q-tab-panel name="startedCaches" class=" fit">
|
<q-tab-panel name="startedCaches" class=" fit">
|
||||||
|
<p class="text-grey-4 text-h5 text-center" v-if="startedCaches.filter(cache => cache.cacheAccesDefinition.id === 0).length === 0">keine Einträge</p>
|
||||||
<q-list>
|
<q-list>
|
||||||
<q-card
|
<q-card
|
||||||
class="q-mb-md"
|
class="q-mb-md"
|
||||||
@ -55,6 +56,7 @@
|
|||||||
</q-tab-panel>
|
</q-tab-panel>
|
||||||
|
|
||||||
<q-tab-panel name="finishedCaches" class="fit">
|
<q-tab-panel name="finishedCaches" class="fit">
|
||||||
|
<p class="text-grey-4 text-h5 text-center" v-if="startedCaches.filter(cache => cache.cacheAccesDefinition.id === 1).length === 0">keine Einträge</p>
|
||||||
<q-list>
|
<q-list>
|
||||||
<q-card class="q-mb-md"
|
<q-card class="q-mb-md"
|
||||||
v-for="finishedCache in startedCaches.filter(cache => cache.cacheAccesDefinition.id === 1)"
|
v-for="finishedCache in startedCaches.filter(cache => cache.cacheAccesDefinition.id === 1)"
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
color="primary"
|
color="primary"
|
||||||
size="10em"
|
size="10em"
|
||||||
/>
|
/>
|
||||||
|
<p class="text-grey-4 text-h5 text-center" v-if="caches.length === 0">keine Einträge</p>
|
||||||
<q-list v-if="render">
|
<q-list v-if="render">
|
||||||
<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
|
||||||
@ -229,6 +230,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
addCache() {
|
addCache() {
|
||||||
|
this.$store.commit('cacheCollector/RESET_NEW_CACHE');
|
||||||
this.$router.push({path: `/cache`})
|
this.$router.push({path: `/cache`})
|
||||||
},
|
},
|
||||||
editCache(cacheID) {
|
editCache(cacheID) {
|
||||||
|
|||||||
@ -135,13 +135,17 @@
|
|||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
let message;
|
let message;
|
||||||
let header = "Unbekannter Fehler...";
|
let header = "Unbekannter Fehler!";
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
console.log(error.response)
|
console.log(error.response);
|
||||||
if (error.response.status === 409) {
|
if (error.response.status === 409) {
|
||||||
message = "Die E-Mail-Adresse wird bereits verwendet!";
|
message = "Die E-Mail-Adresse wird bereits verwendet!";
|
||||||
header = "Anmeldedaten überprüfen!";
|
header = "Anmeldedaten überprüfen!";
|
||||||
}
|
}
|
||||||
|
if (error.response.status === 500) {
|
||||||
|
message= "Der Anmeldeserver konnte die Daten nicht verarbeiten.";
|
||||||
|
header= "Fehler!";
|
||||||
|
}
|
||||||
} else if (error.request) {
|
} else if (error.request) {
|
||||||
console.log(error.request);
|
console.log(error.request);
|
||||||
header = "Anfrage fehlgeschlagen!";
|
header = "Anfrage fehlgeschlagen!";
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
></q-img>
|
></q-img>
|
||||||
<div class="row q-col-gutter-md">
|
<div class="row q-col-gutter-md">
|
||||||
<q-input class="col" dense stack-label filled v-model="latlang" @input="separateLatlang"
|
<q-input class="col" dense stack-label filled v-model="latlang" @input="separateLatlang"
|
||||||
label="Längengrad/Breitengrad"/>
|
label="Breitengrad/Längengrad"/>
|
||||||
<div class="col-shrink">
|
<div class="col-shrink">
|
||||||
<q-btn unelevated color="primary" class="full-height" icon="my_location"/>
|
<q-btn unelevated color="primary" class="full-height" icon="my_location"/>
|
||||||
</div>
|
</div>
|
||||||
@ -97,13 +97,20 @@
|
|||||||
saveStation() {
|
saveStation() {
|
||||||
console.log("saveStation(): ");
|
console.log("saveStation(): ");
|
||||||
console.log(this.station);
|
console.log(this.station);
|
||||||
|
console.log(this.isNewStation);
|
||||||
|
console.log(this.$route.params.pos);
|
||||||
if (this.isNewStation) {
|
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', {index: this.$route.params.pos, station: 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`});
|
let cache = this.$store.getters['cacheCollector/GET_CACHE'];
|
||||||
|
if (cache.hasOwnProperty('id')) {
|
||||||
|
this.$router.push({path: `/cache/${cache.id}`});
|
||||||
|
} else {
|
||||||
|
this.$router.push({path: `/cache`});
|
||||||
|
}
|
||||||
console.log("station saved..");
|
console.log("station saved..");
|
||||||
},
|
},
|
||||||
dismiss() {
|
dismiss() {
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
></q-img>
|
></q-img>
|
||||||
<div class="row q-col-gutter-md">
|
<div class="row q-col-gutter-md">
|
||||||
<q-input class="col" dense stack-label filled v-model="latlang" @input="separateLatlang"
|
<q-input class="col" dense stack-label filled v-model="latlang" @input="separateLatlang"
|
||||||
label="Längengrad/Breitengrad"/>
|
label="Breitengrad/Längengrad"/>
|
||||||
<div class="col-shrink">
|
<div class="col-shrink">
|
||||||
<q-btn unelevated color="primary" class="full-height" icon="my_location"/>
|
<q-btn unelevated color="primary" class="full-height" icon="my_location"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -2,6 +2,10 @@ export const GET_CACHE = (state) => {
|
|||||||
console.log("GET_CACHE: retrieve cache from store. ");
|
console.log("GET_CACHE: retrieve cache from store. ");
|
||||||
return state.newCache;
|
return state.newCache;
|
||||||
};
|
};
|
||||||
|
export const GET_LOCK = (state) => {
|
||||||
|
console.log("GET_LOCK: ");
|
||||||
|
return state.locked;
|
||||||
|
};
|
||||||
export const GET_TEMPSTATION = (state) => {
|
export const GET_TEMPSTATION = (state) => {
|
||||||
console.log("GET_TEMPSTATION: retrieve cache from store. ");
|
console.log("GET_TEMPSTATION: retrieve cache from store. ");
|
||||||
return state.tempStation;
|
return state.tempStation;
|
||||||
|
|||||||
@ -1,7 +1,11 @@
|
|||||||
export const SET_CACHE = (state, cache) => {
|
export const SET_CACHE = (state, cache) => {
|
||||||
console.log("SET_CACHE: save cache to store. ")
|
console.log("SET_CACHE: save cache to store. ");
|
||||||
state.newCache = cache;
|
state.newCache = cache;
|
||||||
};
|
};
|
||||||
|
export const SET_LOCK = (state, bool) => {
|
||||||
|
console.log("SET_LOCK: ");
|
||||||
|
state.locked = bool;
|
||||||
|
};
|
||||||
export const SET_TEMPSTATION = (state, station) => {
|
export const SET_TEMPSTATION = (state, station) => {
|
||||||
console.log("SET_TEMPSTATION: add new station to cache: "+station);
|
console.log("SET_TEMPSTATION: add new station to cache: "+station);
|
||||||
state.tempStation = station;
|
state.tempStation = station;
|
||||||
@ -25,6 +29,7 @@ export const EDIT_STATION = (state, indexStation) => {
|
|||||||
console.log("EDIT_STATION: "+index+" "+station);
|
console.log("EDIT_STATION: "+index+" "+station);
|
||||||
|
|
||||||
state.newCache.stationen[index] = station;
|
state.newCache.stationen[index] = station;
|
||||||
|
console.log("EDIT_STATION: "+JSON.stringify(state.newCache.stationen[index]));
|
||||||
};
|
};
|
||||||
export const REMOVE_STATION = (state, index) => {
|
export const REMOVE_STATION = (state, index) => {
|
||||||
console.log("REMOVE_STATION: "+index);
|
console.log("REMOVE_STATION: "+index);
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
export default {
|
export default {
|
||||||
|
locked: false,
|
||||||
newCache: {
|
newCache: {
|
||||||
name: "",
|
name: "",
|
||||||
description: "",
|
description: "",
|
||||||
|
|||||||
@ -72,98 +72,11 @@ public class Controller {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity getAllCaches() {
|
public ResponseEntity getAllCaches() {
|
||||||
logger.warn("API CALL: /api/allCaches");
|
logger.warn("API CALL: /api/allCaches");
|
||||||
|
logger.debug("/api/allCaches PARAMETERS: -");
|
||||||
return ResponseEntity.status(200).body(new Gson().toJson(cacheRepository.findAll()));
|
return ResponseEntity.status(200).body(new Gson().toJson(cacheRepository.findAll()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "Starts the given Cache for the given User")
|
|
||||||
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
|
|
||||||
@ApiResponses(value = {
|
|
||||||
@ApiResponse(code = 404, message = "Database error"),
|
|
||||||
@ApiResponse(code = 401, message = "JWT Token expired"),
|
|
||||||
@ApiResponse(code = 400, message = "Something went wrong at verification")
|
|
||||||
})
|
|
||||||
@RequestMapping(value = "/api/startCache", method = RequestMethod.POST, produces = "application/json")
|
|
||||||
@ResponseBody
|
|
||||||
public ResponseEntity startCache(@RequestParam(value = "token", defaultValue = "-1") String token,
|
|
||||||
@RequestParam String cacheID) {
|
|
||||||
|
|
||||||
if (!token.equals("-1")) { // ein angemeldeter user startet den cache(es werden zwei parameter übergeben)
|
|
||||||
|
|
||||||
Bearbeitet bearbeitet = new Bearbeitet();
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------
|
|
||||||
//Verify token
|
|
||||||
ResponseEntity tokenVerification = VerificationUtil.verifyToken(token);
|
|
||||||
|
|
||||||
//Error in token verification
|
|
||||||
if (tokenVerification.getStatusCodeValue() != 200) {
|
|
||||||
return tokenVerification;
|
|
||||||
}
|
|
||||||
|
|
||||||
Claims claims = (Claims) tokenVerification.getBody();
|
|
||||||
|
|
||||||
ResponseEntity getUser = FinderUtil.findUserFromClaim(claims);
|
|
||||||
|
|
||||||
if (getUser.getStatusCodeValue() != 200) {
|
|
||||||
return getUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
User user = (User) getUser.getBody();
|
|
||||||
|
|
||||||
bearbeitet.setUser(user);
|
|
||||||
|
|
||||||
//----------------------
|
|
||||||
//Get Cache
|
|
||||||
ResponseEntity getCache = FinderUtil.findCacheById(cacheID);
|
|
||||||
|
|
||||||
if (getCache.getStatusCodeValue() != 200) {
|
|
||||||
return getCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
Cache cache = (Cache) getCache.getBody();
|
|
||||||
//----------------------
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
//Get CacheAccesDefinition
|
|
||||||
ResponseEntity getCacheAccesDefinition = FinderUtil.findCacheAccesDefinitionById("0");
|
|
||||||
|
|
||||||
if (getCacheAccesDefinition.getStatusCodeValue() != 200) {
|
|
||||||
return getCacheAccesDefinition;
|
|
||||||
}
|
|
||||||
|
|
||||||
CacheAccesDefinition cacheAccesDefinition = (CacheAccesDefinition) getCacheAccesDefinition.getBody();
|
|
||||||
//----------------------
|
|
||||||
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
|
|
||||||
|
|
||||||
//bearbeitetRepository.save(bearbeitet);
|
|
||||||
|
|
||||||
return ResponseEntity.status(201).body(new Gson().toJson(bearbeitet));
|
|
||||||
|
|
||||||
} else { // kein angemeldeter User startet den cache(es wird nur der cache als parameter übergeben)
|
|
||||||
|
|
||||||
ResponseEntity getCache = FinderUtil.findCacheById(cacheID);
|
|
||||||
|
|
||||||
if (getCache.getStatusCodeValue() != 200) {
|
|
||||||
return getCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
Cache cache = (Cache) getCache.getBody();
|
|
||||||
|
|
||||||
return ResponseEntity.status(200).body(new Gson().toJson(cache));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "Checks if the given Station is the correct next Station in the Cache")
|
@ApiOperation(value = "Checks if the given Station is the correct next Station in the Cache")
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(code = 404, message = "Database error"),
|
@ApiResponse(code = 404, message = "Database error"),
|
||||||
@ -327,6 +240,8 @@ public class Controller {
|
|||||||
@RequestMapping(value = "/api/createCache", method = RequestMethod.POST, produces = "application/json")
|
@RequestMapping(value = "/api/createCache", method = RequestMethod.POST, produces = "application/json")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity createCache(@RequestBody Cache cache) {
|
public ResponseEntity createCache(@RequestBody Cache cache) {
|
||||||
|
logger.warn("API CALL: api/createCache");
|
||||||
|
logger.debug("/api/allCaches PARAMETERS:\ncache: " + cache.getName());
|
||||||
return createCacheUtil(cache);
|
return createCacheUtil(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,7 +255,8 @@ public class Controller {
|
|||||||
@RequestMapping(value = "/api/editCache", method = RequestMethod.PUT, produces = "application/json")
|
@RequestMapping(value = "/api/editCache", method = RequestMethod.PUT, produces = "application/json")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity editCache(@RequestBody Cache newCache) {
|
public ResponseEntity editCache(@RequestBody Cache newCache) {
|
||||||
|
logger.warn("API CALL: /api/editCache");
|
||||||
|
logger.debug("/api/editCache PARAMETERS:\nnewCache: " + newCache.getName());
|
||||||
return editCacheUtil(newCache);
|
return editCacheUtil(newCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,6 +307,7 @@ public class Controller {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity getAllStations() {
|
public ResponseEntity getAllStations() {
|
||||||
logger.warn("API CALL: /api/getAllStations");
|
logger.warn("API CALL: /api/getAllStations");
|
||||||
|
logger.debug("/api/getAllStations: PARAMETERS: -");
|
||||||
return ResponseEntity.status(200).body(new Gson().toJson(stationRepository.findAll()));
|
return ResponseEntity.status(200).body(new Gson().toJson(stationRepository.findAll()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,10 +316,11 @@ public class Controller {
|
|||||||
@ApiResponse(code = 404, message = "Database error")
|
@ApiResponse(code = 404, message = "Database error")
|
||||||
})
|
})
|
||||||
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
|
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
|
||||||
@RequestMapping(value = "/api/deleteCache", method = {RequestMethod.DELETE, RequestMethod.GET}, produces = "application/json")
|
@RequestMapping(value = "/api/deleteCache", method = {RequestMethod.DELETE}, produces = "application/json")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity deleteCache(@RequestParam String cacheID) {
|
public ResponseEntity deleteCache(@RequestParam String cacheID) {
|
||||||
logger.warn("API CALL: /api/deleteCache");
|
logger.warn("API CALL: /api/deleteCache");
|
||||||
|
logger.debug("/api/deleteCache: PARAMETERS:\ncacheID: " + cacheID);
|
||||||
return deleteCacheUtil(cacheID);
|
return deleteCacheUtil(cacheID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,6 +336,7 @@ public class Controller {
|
|||||||
public ResponseEntity getMyCaches(@RequestParam String token) {
|
public ResponseEntity getMyCaches(@RequestParam String token) {
|
||||||
|
|
||||||
logger.warn("API CALL: /api/getMyCaches");
|
logger.warn("API CALL: /api/getMyCaches");
|
||||||
|
logger.debug("/api/getMyCaches: PARAMETERS:\ntoken: " + token);
|
||||||
|
|
||||||
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
||||||
|
|
||||||
@ -448,7 +367,7 @@ public class Controller {
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
List<Bearbeitet> bearbeitetList = bearbeitetRepository.findByUser(user);
|
List<Bearbeitet> bearbeitetList = bearbeitetRepository.findByUser(user);
|
||||||
logger.debug("/api/getMyCaches Got all bearbeitet entreis of user: " +user.getEmail());
|
logger.debug("/api/getMyCaches Got all bearbeitet entreis of user: " + user.getEmail());
|
||||||
return ResponseEntity.status(200).body(new Gson().toJson(bearbeitetList));
|
return ResponseEntity.status(200).body(new Gson().toJson(bearbeitetList));
|
||||||
} else {
|
} else {
|
||||||
return ResponseEntity.status(404).body("Es gab einen Fehler. Bitte versuche es erneut oder kontaktiere einen Admin!");
|
return ResponseEntity.status(404).body("Es gab einen Fehler. Bitte versuche es erneut oder kontaktiere einen Admin!");
|
||||||
@ -465,6 +384,7 @@ public class Controller {
|
|||||||
public ResponseEntity getRankingList() {
|
public ResponseEntity getRankingList() {
|
||||||
|
|
||||||
logger.warn("API CALL: /api/getRankingList");
|
logger.warn("API CALL: /api/getRankingList");
|
||||||
|
logger.debug("/api/getRankingList: PARAMETERS: -");
|
||||||
|
|
||||||
List<RankingListHelper> sendBackUsers = new LinkedList<>();
|
List<RankingListHelper> sendBackUsers = new LinkedList<>();
|
||||||
|
|
||||||
@ -489,14 +409,21 @@ public class Controller {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity getTeamRankingList() {
|
public ResponseEntity getTeamRankingList() {
|
||||||
|
|
||||||
|
logger.warn("API CALL: /api/getTeamRankingList");
|
||||||
|
logger.debug("/api/getTeamRankingList: PARAMETERS: -");
|
||||||
|
|
||||||
List<TeamRankingListHelper> sendBackTeams = new LinkedList<>();
|
List<TeamRankingListHelper> sendBackTeams = new LinkedList<>();
|
||||||
|
logger.debug("/api/getTeamRankingList Created List sendBackTeams");
|
||||||
List<Object[]> rankingTeams = userRepository.getTeamRankingList();
|
List<Object[]> rankingTeams = userRepository.getTeamRankingList();
|
||||||
|
logger.debug("/api/getTeamRankingList Got Rankinglist in Format Object[]");
|
||||||
|
logger.debug("/api/getTeamRankingList Convert Object to TeamRankingListHelper");
|
||||||
for (Object[] obj : rankingTeams) {
|
for (Object[] obj : rankingTeams) {
|
||||||
BigDecimal i = (BigDecimal) obj[1];
|
BigDecimal i = (BigDecimal) obj[1];
|
||||||
TeamRankingListHelper tmp = new TeamRankingListHelper((String) obj[0], i.intValue());
|
TeamRankingListHelper tmp = new TeamRankingListHelper((String) obj[0], i.intValue());
|
||||||
System.out.println(tmp);
|
System.out.println(tmp);
|
||||||
sendBackTeams.add(tmp);
|
sendBackTeams.add(tmp);
|
||||||
}
|
}
|
||||||
|
logger.debug("/api/getTeamRankingList Send RankingList to Frontend");
|
||||||
return ResponseEntity.status(200).body(new Gson().toJson(sendBackTeams));
|
return ResponseEntity.status(200).body(new Gson().toJson(sendBackTeams));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,25 +438,37 @@ public class Controller {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity getUser(@RequestParam String token) {
|
public ResponseEntity getUser(@RequestParam String token) {
|
||||||
|
|
||||||
|
logger.warn("API CALL: /api/getUser");
|
||||||
|
logger.debug("/api/getUser: PARAMETERS:\ntoken: " + token);
|
||||||
|
logger.debug("/api/getUser Trying to verify Token: " + token);
|
||||||
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
||||||
|
|
||||||
if (verifyToken.getStatusCodeValue() != 200) {
|
if (verifyToken.getStatusCodeValue() != 200) {
|
||||||
|
logger.debug("/api/getUser Error in Verification of Token: " + token);
|
||||||
return verifyToken;
|
return verifyToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.debug("/api/getUser Trying to get User");
|
||||||
Claims claims = (Claims) verifyToken.getBody();
|
Claims claims = (Claims) verifyToken.getBody();
|
||||||
|
logger.debug("/api/getUser Got Claim: " + new GsonBuilder().setPrettyPrinting().create().toJson(claims));
|
||||||
|
|
||||||
ResponseEntity getUser = FinderUtil.findUserFromClaim(claims);
|
ResponseEntity getUser = FinderUtil.findUserFromClaim(claims);
|
||||||
|
|
||||||
|
|
||||||
if (getUser.getStatusCodeValue() != 200) {
|
if (getUser.getStatusCodeValue() != 200) {
|
||||||
|
logger.debug("/api/getUser Error getting User");
|
||||||
return getUser;
|
return getUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
User user = (User) getUser.getBody();
|
User user = (User) getUser.getBody();
|
||||||
|
logger.debug("/api/getUser Got User: " + user.getEmail());
|
||||||
|
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
|
logger.debug("/api/getUser User != null " + user.getEmail());
|
||||||
|
logger.debug("/api/getUser Send User to Frontend");
|
||||||
return ResponseEntity.status(200).body(new Gson().toJson(user));
|
return ResponseEntity.status(200).body(new Gson().toJson(user));
|
||||||
} else {
|
} else {
|
||||||
|
logger.debug("Error in Getting User");
|
||||||
return ResponseEntity.status(404).body("Es gab einen Fehler. Bitte versuche es erneut oder kontaktiere einen Admin!e");
|
return ResponseEntity.status(404).body("Es gab einen Fehler. Bitte versuche es erneut oder kontaktiere einen Admin!e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -721,6 +660,10 @@ public class Controller {
|
|||||||
|
|
||||||
// löscht team, wenn keine teammitglieder mehr vorhanden
|
// löscht team, wenn keine teammitglieder mehr vorhanden
|
||||||
if (user_infos.size() == 0) {
|
if (user_infos.size() == 0) {
|
||||||
|
List<TeamInvite> teamInvites = teamInviteRepository.findByTeam(team);
|
||||||
|
for (TeamInvite teamInvite : teamInvites) {
|
||||||
|
teamInviteRepository.delete(teamInvite);
|
||||||
|
}
|
||||||
teamRepository.delete(team);
|
teamRepository.delete(team);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,6 +706,10 @@ public class Controller {
|
|||||||
if (invitedUser == null) {
|
if (invitedUser == null) {
|
||||||
return ResponseEntity.status(404).body("Es gibt keinen Benutzer mit dieser email.");
|
return ResponseEntity.status(404).body("Es gibt keinen Benutzer mit dieser email.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (invitedUser == user) {
|
||||||
|
return ResponseEntity.status(404).body("Du kannst dich selbst nicht einladen.");
|
||||||
|
}
|
||||||
//----------------------
|
//----------------------
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -11,4 +11,5 @@ import java.util.List;
|
|||||||
public interface TeamInviteRepository extends JpaRepository<TeamInvite, Integer> {
|
public interface TeamInviteRepository extends JpaRepository<TeamInvite, Integer> {
|
||||||
TeamInvite findByUserAndTeam(User user, Team team);
|
TeamInvite findByUserAndTeam(User user, Team team);
|
||||||
List<TeamInvite> findByUser(User user);
|
List<TeamInvite> findByUser(User user);
|
||||||
|
List<TeamInvite> findByTeam(Team team);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,12 +45,14 @@ public class CacheConstructionUtil {
|
|||||||
public static ResponseEntity createCacheUtil(Cache cache) {
|
public static ResponseEntity createCacheUtil(Cache cache) {
|
||||||
|
|
||||||
// Stationen werden in die Datenbank eingetragen
|
// Stationen werden in die Datenbank eingetragen
|
||||||
|
int position = 1;
|
||||||
for (Station station : cache.getStationen()) {
|
for (Station station : cache.getStationen()) {
|
||||||
ResponseEntity response = createStationUtil(station);
|
ResponseEntity response = createStationUtil(station, position);
|
||||||
if (response.getStatusCodeValue() == 400) {
|
if (response.getStatusCodeValue() == 400) {
|
||||||
deleteStationenUtil(cache);
|
deleteStationenUtil(cache);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
position++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Caches werden in die Datenbank eingetragen
|
// Caches werden in die Datenbank eingetragen
|
||||||
@ -81,18 +83,19 @@ public class CacheConstructionUtil {
|
|||||||
return ResponseEntity.status(200).body(new Gson().toJson(cache));
|
return ResponseEntity.status(200).body(new Gson().toJson(cache));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResponseEntity createStationUtil(Station station) {
|
public static ResponseEntity createStationUtil(Station station, int position) {
|
||||||
|
|
||||||
if (station.getDescription().length() == 0 || station.getLattitude() == 0.0 || station.getLongitude() == 0.0 /*|| station.getSolution().length() == 0*/) {
|
if (station.getDescription().length() == 0 /*|| station.getSolution().length() == 0*/) {
|
||||||
return ResponseEntity.status(400).body("Alle Felder müssen ausgefüllt werden!");
|
return ResponseEntity.status(400).body("Alle Felder müssen ausgefüllt werden!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (station.getLattitude() < 9 || station.getLattitude() > 10) {
|
if (station.getLattitude() < 49 || station.getLattitude() > 50) {
|
||||||
return ResponseEntity.status(400).body("Die Lattitude ist außerhalb der Bundesgartenschau");
|
|
||||||
|
return ResponseEntity.status(400).body("Der Breitengrad der Station " + position + " ist außerhalb der Bundesgartenschau. Dieser muss zwischen 49 und 50 liegen.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (station.getLongitude() < 49 || station.getLongitude() > 50) {
|
if (station.getLongitude() < 9 || station.getLongitude() > 10) {
|
||||||
return ResponseEntity.status(400).body("Die Longitude ist außerhalb der Bundesgartenschau");
|
return ResponseEntity.status(400).body("Der Längengrad der Station " + position + " ist außerhalb der Bundesgartenschau. Dieser muss zwischen 9 und 10 liegen.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Random r = new Random();
|
Random r = new Random();
|
||||||
@ -135,20 +138,21 @@ public class CacheConstructionUtil {
|
|||||||
|
|
||||||
ResponseEntity response = new ResponseEntity(HttpStatus.ACCEPTED);
|
ResponseEntity response = new ResponseEntity(HttpStatus.ACCEPTED);
|
||||||
List<Station> newCreatedStationList = new ArrayList<Station>();
|
List<Station> newCreatedStationList = new ArrayList<Station>();
|
||||||
|
int position = 1;
|
||||||
for (Station station : cache.getStationen()) {
|
for (Station station : cache.getStationen()) {
|
||||||
boolean stationIsNew = true;
|
boolean stationIsNew = true;
|
||||||
for (Station oldStation : oldCache.getStationen()) {
|
for (Station oldStation : oldCache.getStationen()) {
|
||||||
// wenn Station schon vorher vorhanden war, wird diese mit den neuen Daten geupdatet
|
// wenn Station schon vorher vorhanden war, wird diese mit den neuen Daten geupdatet
|
||||||
if (oldStation.getId() == station.getId()) {
|
if (oldStation.getId() == station.getId()) {
|
||||||
response = createStationUtil(station);
|
response = createStationUtil(station, position);
|
||||||
stationIsNew = false;
|
stationIsNew = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// wenn Station neu hinzugefügt wurde, wird die Station zusätzlich in die Datenbank gespeichert
|
// wenn Station neu hinzugefügt wurde, wirdcd die Station zusätzlich in die Datenbank gespeichert
|
||||||
if (stationIsNew) {
|
if (stationIsNew) {
|
||||||
response = createStationUtil(station);
|
response = createStationUtil(station, position);
|
||||||
if (response.getStatusCodeValue() == 200) {
|
if (response.getStatusCodeValue() == 200) {
|
||||||
newCreatedStationList.add(station);
|
newCreatedStationList.add(station);
|
||||||
}
|
}
|
||||||
@ -163,6 +167,7 @@ public class CacheConstructionUtil {
|
|||||||
deleteNewCreatedStationsUtil(newCreatedStationList);
|
deleteNewCreatedStationsUtil(newCreatedStationList);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
position++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// überprüft den Cache nach validen Daten
|
// überprüft den Cache nach validen Daten
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user