Merge branch 'develop' into frontend/robin
This commit is contained in:
commit
79ca7f53e9
@ -72,6 +72,7 @@ module.exports = function (ctx) {
|
||||
'QPopupEdit',
|
||||
'QSlideTransition',
|
||||
'QToggle',
|
||||
'QLinearProgress'
|
||||
],
|
||||
|
||||
directives: [
|
||||
@ -81,7 +82,8 @@ module.exports = function (ctx) {
|
||||
|
||||
// Quasar plugins
|
||||
plugins: [
|
||||
'Notify'
|
||||
'Notify',
|
||||
'Dialog'
|
||||
]
|
||||
|
||||
// iconSet: 'ionicons-v4'
|
||||
|
||||
@ -48,6 +48,21 @@
|
||||
cacheID: null,
|
||||
}
|
||||
},
|
||||
beforeRouteUpdate(to, from, next) {
|
||||
console.log("beforeRouteUpdate");
|
||||
this.askForPermission = true;
|
||||
this.activateCamera = false;
|
||||
this.isValid = false;
|
||||
this.validating = false;
|
||||
this.loading = false;
|
||||
this.paused = false;
|
||||
this.result = null;
|
||||
this.params = null;
|
||||
this.noStreamApiSupport = false;
|
||||
this.setCacheId();
|
||||
this.updateCameraState();
|
||||
next()
|
||||
},
|
||||
created() {
|
||||
this.setCacheId();
|
||||
},
|
||||
@ -89,6 +104,8 @@
|
||||
console.log("cache access definition");
|
||||
console.log(response.data.cacheAccesDefinition);
|
||||
resolve(true);
|
||||
this.askForPermission = true;
|
||||
this.activateCamera = false;
|
||||
if (Number(response.data.cacheAccesDefinition.id) === 0) {
|
||||
this.$router.push({path: `/station/${params.cacheID}/${params.stationID}`});
|
||||
} else if (Number(response.data.cacheAccesDefinition.id) === 1) {
|
||||
@ -166,8 +183,8 @@
|
||||
this.activateCamera = bool;
|
||||
if (this.askForPermission === false) {
|
||||
this.askForPermission = true;
|
||||
this.updateCameraState();
|
||||
}
|
||||
this.updateCameraState();
|
||||
},
|
||||
|
||||
logErrors(promise) {
|
||||
@ -190,19 +207,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeRouteUpdate(to, from, next) {
|
||||
this.askForPermission = true;
|
||||
this.activateCamera = false;
|
||||
this.isValid = false;
|
||||
this.validating = false;
|
||||
this.loading = false;
|
||||
this.paused = false;
|
||||
this.result = null;
|
||||
this.params = null;
|
||||
this.noStreamApiSupport = false;
|
||||
this.setCacheId();
|
||||
next()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -245,7 +245,7 @@
|
||||
},
|
||||
evalAuthentication: function () {
|
||||
this.$store.commit('auth/SET_AUTHENTICATED');
|
||||
// this.$store.commit('auth/SET_USER');
|
||||
this.$store.commit('auth/SET_USER');
|
||||
},
|
||||
logout: function () {
|
||||
console.log("logout()");
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
<p v-html="cache.reward.rewardDescription"></p>
|
||||
|
||||
<div class="column q-gutter-y-md">
|
||||
<q-btn unelevated color="primary" label="Rangliste" to="/ranking/"/>
|
||||
<q-btn unelevated color="primary" label="Startseite" to="/"/>
|
||||
<q-btn unelevated color="primary" label="Rangliste" to="/ranking"/>
|
||||
<q-btn unelevated color="primary" label="Zur Übersicht" to="/overview"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -138,7 +138,7 @@
|
||||
},
|
||||
evalAuthentication: function () {
|
||||
this.$store.commit('auth/SET_AUTHENTICATED');
|
||||
this.$store.commit('auth/SET_USER');
|
||||
// this.$store.commit('auth/SET_USER');
|
||||
},
|
||||
logout: function () {
|
||||
console.log("logout()");
|
||||
|
||||
@ -32,23 +32,21 @@
|
||||
expand-separator
|
||||
icon="location_on"
|
||||
:label="startedCache.cache.name"
|
||||
:caption=" startedCache.cache.description"
|
||||
:caption="startedCache.cache.rankingPoints+' Punkte, '+startedCache.cache.stationen.length+' Stationen'"
|
||||
>
|
||||
<q-item>
|
||||
<q-item-section top avatar class="self-center">
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-item-label caption>{{'Nächste Aufgabe: ' + startedCache.aktuelleStation.description }}
|
||||
</q-item-label>
|
||||
<q-item-label caption>{{'Ranglistenpunkte für diesen Cache: ' + startedCache.cache.rankingPoints}}
|
||||
<q-item class="q-pr-sm">
|
||||
<q-item-section top avatar class="self-center"/>
|
||||
<q-item-section class="">
|
||||
<q-linear-progress rounded style="height: 15px" :value="startedCache.progress" color="primary" class=""/>
|
||||
<q-item-label class="q-pt-xs" caption>
|
||||
{{ Math.round(startedCache.progress * 100) }}% bereits geschafft
|
||||
</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="continueCache(startedCache.cache.id)" unelevated color="positive" stack icon="arrow_forward"
|
||||
<q-item class="q-pr-sm reverse">
|
||||
<q-btn @click="continueCache(startedCache.cache.id)" unelevated color="positive" stack
|
||||
icon="arrow_forward"
|
||||
label="Fortfahren" size="sm"/>
|
||||
</q-item>
|
||||
</q-expansion-item>
|
||||
@ -58,7 +56,9 @@
|
||||
|
||||
<q-tab-panel name="finishedCaches" class="fit">
|
||||
<q-list>
|
||||
<q-card class="q-mb-md" v-for="finishedCache in startedCaches.filter(cache => cache.cacheAccesDefinition.id === 1)" :key="finishedCache.id">
|
||||
<q-card class="q-mb-md"
|
||||
v-for="finishedCache in startedCaches.filter(cache => cache.cacheAccesDefinition.id === 1)"
|
||||
:key="finishedCache.id">
|
||||
<q-expansion-item
|
||||
class=""
|
||||
expand-separator
|
||||
@ -80,7 +80,8 @@
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item class="q-pr-sm reverse q-gutter-x-sm">
|
||||
<q-btn @click="goToReward(finishedCache.cache.id)" unelevated color="primary" stack icon="arrow_forward"
|
||||
<q-btn @click="goToReward(finishedCache.cache.id)" unelevated color="primary" stack
|
||||
icon="arrow_forward"
|
||||
label="Belohnung ansehen" size="sm"/>
|
||||
</q-item>
|
||||
</q-expansion-item>
|
||||
@ -114,12 +115,26 @@
|
||||
},
|
||||
},
|
||||
created: function () {
|
||||
this.fetchUserCaches();
|
||||
this.$store.commit('auth/SET_AUTHENTICATED');
|
||||
this.$store.commit('auth/SET_USER');
|
||||
this.fetchUserCaches();
|
||||
},
|
||||
methods: {
|
||||
fetchUserCaches: function () {
|
||||
calculateProgress() {
|
||||
console.log("calcProgress...")
|
||||
console.log("this.startedCaches: ")
|
||||
console.log(this.startedCaches)
|
||||
this.startedCaches.forEach(startedCache => {
|
||||
console.log(startedCache)
|
||||
let stationCount = startedCache.cache.stationen.length;
|
||||
let stationPos = 1 + startedCache.cache.stationen.findIndex(station => station.id === startedCache.aktuelleStation.id);
|
||||
startedCache.progress = stationPos / stationCount;
|
||||
console.log("progress: "+startedCache.progress)
|
||||
});
|
||||
console.log("calcProgress finished.");
|
||||
console.log(this.startedCaches)
|
||||
},
|
||||
fetchUserCaches() {
|
||||
console.log("fetchCaches...")
|
||||
let token;
|
||||
if (localStorage.getItem('userToken')) {
|
||||
token = JSON.parse(localStorage.getItem('userToken')).token;
|
||||
@ -130,6 +145,7 @@
|
||||
.then((response) => {
|
||||
console.log(response.data)
|
||||
this.startedCaches = response.data;
|
||||
this.calculateProgress();
|
||||
}).catch((error) => {
|
||||
// Error
|
||||
let msg;
|
||||
@ -151,7 +167,9 @@
|
||||
}
|
||||
console.log(error.config);
|
||||
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
|
||||
})
|
||||
}).finally(() => {
|
||||
console.log("fetchCaches... finally")
|
||||
});
|
||||
},
|
||||
continueCache(cacheID) {
|
||||
console.log("cacheID");
|
||||
|
||||
@ -21,15 +21,21 @@
|
||||
<q-tab-panels v-model="tab" animated swipeable class="col">
|
||||
|
||||
<q-tab-panel name="list" class=" fit">
|
||||
|
||||
<q-list>
|
||||
<q-spinner-oval
|
||||
v-if="!render"
|
||||
class="absolute-center"
|
||||
color="primary"
|
||||
size="10em"
|
||||
/>
|
||||
<q-list v-if="render">
|
||||
<q-card class="q-mb-md" v-for="cache in caches" :key="cache.id">
|
||||
<q-expansion-item
|
||||
class=""
|
||||
expand-separator
|
||||
icon="location_on"
|
||||
:header-class="'text-'+(getColorClass(cache) === 'primary' ? 'black' : getColorClass(cache))"
|
||||
:label="cache.name"
|
||||
:caption="cache.rankingPoints+' Punkte / Size '+cache.stationen.length"
|
||||
:caption="cache.rankingPoints+' Punkte, '+cache.stationen.length+' Stationen'"
|
||||
>
|
||||
<q-item>
|
||||
<q-item-section top avatar class="self-center">
|
||||
@ -43,22 +49,29 @@
|
||||
</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"
|
||||
<q-btn v-if="(getCacheAccesDefinition(cache) === -1)" @click="startCache(cache.id)" unelevated
|
||||
:color="getColorClass(cache)" stack icon="arrow_forward"
|
||||
label="Starten" size="xs"/>
|
||||
<q-btn v-if="hasAdminState" @click="deleteCache(cache.id)" unelevated color="negative" stack
|
||||
icon="delete" label="Löschen" size="xs"/>
|
||||
<q-btn v-if="(getCacheAccesDefinition(cache) === 0)" @click="continueCache(cache.id)" unelevated
|
||||
:color="getColorClass(cache)" stack icon="arrow_forward"
|
||||
label="Fortsetzen" size="xs"/>
|
||||
<q-btn v-if="(getCacheAccesDefinition(cache) === 1)" @click="goToReward(cache.id)" unelevated
|
||||
:color="getColorClass(cache)" stack icon="arrow_forward"
|
||||
label="Belohnung" size="xs"/>
|
||||
<q-btn v-if="hasAdminState" @click="confirmDelete(cache.id)" unelevated color="negative" stack
|
||||
icon="delete" size="xs"/>
|
||||
<q-btn disable v-if="hasAdminState" @click="editCache(cache.id)" unelevated color="primary" stack
|
||||
icon="edit" label="Bearbeiten" size="xs"/>
|
||||
icon="edit" size="xs"/>
|
||||
<q-btn v-if="hasAdminState" @click="generateQrCodes(cache.id)" unelevated color="primary" stack
|
||||
icon="image" label="QR-Codes" size="xs"/>
|
||||
icon="image" label="QRCodes" size="xs"/>
|
||||
</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"/>
|
||||
</div>
|
||||
</q-list>
|
||||
</q-tab-panel>
|
||||
|
||||
|
||||
@ -94,82 +107,148 @@
|
||||
tab: 'list',
|
||||
caches: [],
|
||||
stations: [],
|
||||
pois: []
|
||||
pois: [],
|
||||
render: false
|
||||
}
|
||||
},
|
||||
mounted: function () {
|
||||
},
|
||||
computed: {
|
||||
// ...mapGetters([
|
||||
// 'auth/GET_ADMINSTATE'
|
||||
// ]),
|
||||
|
||||
hasAdminState() {
|
||||
return this.$store.getters['auth/GET_ADMINSTATE'];
|
||||
}
|
||||
},
|
||||
created: function () {
|
||||
beforeMount() {
|
||||
},
|
||||
|
||||
async created() {
|
||||
console.log("created(): " + this.caches);
|
||||
this.fetchAllCaches();
|
||||
this.$store.commit('auth/SET_AUTHENTICATED');
|
||||
this.$store.commit('auth/SET_USER');
|
||||
// this.$store.commit('auth/SET_AUTHENTICATED');
|
||||
// this.$store.commit('auth/SET_USER');
|
||||
await this.fetchAllCaches();
|
||||
this.render = await this.fetchMyCaches();
|
||||
},
|
||||
methods: {
|
||||
fetchAllCaches() {
|
||||
this.$axios.get('/api/allCaches')
|
||||
.then((response) => {
|
||||
this.caches = response.data;
|
||||
for(let cache in this.caches) {
|
||||
getColorClass(cache) {
|
||||
switch (this.getCacheAccesDefinition(cache)) {
|
||||
case -1:
|
||||
return "primary"
|
||||
case 0:
|
||||
return "amber"
|
||||
case 1:
|
||||
return "green"
|
||||
}
|
||||
},
|
||||
getCacheAccesDefinition(cache) {
|
||||
// console.log("getCacheAccessDefinition")
|
||||
// console.log(cache.hasOwnProperty('cacheAccesDefinition') ? cache.cacheAccesDefinition : -1)
|
||||
// can be -1 = no accessdefinition, 0 = started or 1 = finished
|
||||
return cache.hasOwnProperty('cacheAccesDefinition') ? cache.cacheAccesDefinition : -1;
|
||||
},
|
||||
|
||||
this.stations[cache]=(this.caches[cache].stationen[0]);
|
||||
const poiItem = {
|
||||
Name: this.caches[cache].name,
|
||||
CategoryID: 3,
|
||||
Latitude: this.stations[cache].lattitude,
|
||||
Longitude: this.stations[cache].longitude
|
||||
};
|
||||
this.pois.push(poiItem);
|
||||
fetchAllCaches() {
|
||||
return new Promise(resolve => {
|
||||
this.$axios.get('/api/allCaches')
|
||||
.then((response) => {
|
||||
this.caches = response.data;
|
||||
//this.fetchMyCaches();
|
||||
for (let cache in this.caches) {
|
||||
|
||||
this.stations[cache] = (this.caches[cache].stationen[0]);
|
||||
const poiItem = {
|
||||
Name: this.caches[cache].name,
|
||||
CategoryID: 3,
|
||||
Latitude: this.stations[cache].lattitude,
|
||||
Longitude: this.stations[cache].longitude
|
||||
};
|
||||
this.pois.push(poiItem);
|
||||
}
|
||||
this.initMap();
|
||||
resolve(true);
|
||||
}).catch((error) => {
|
||||
let message;
|
||||
let header = "Fehler: ";
|
||||
if (error.response) {
|
||||
console.log("ERROR RESPONSE");
|
||||
// The request was made and the server responded with a status code
|
||||
// that falls out of the range of 2xx
|
||||
message = error.response.data.error;
|
||||
header += error.response.status;
|
||||
} else if (error.request) {
|
||||
// The request was made but no response was received
|
||||
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
||||
// http.ClientRequest in node.js
|
||||
message = "Anfrage fehlgeschlagen.";
|
||||
} else {
|
||||
// Something happened in setting up the request that triggered an Error
|
||||
console.log('Error', error.message);
|
||||
message = error.message;
|
||||
}
|
||||
this.initMap();
|
||||
}).catch((error) => {
|
||||
let message;
|
||||
let header = "Fehler: ";
|
||||
if (error.response) {
|
||||
console.log("ERROR RESPONSE");
|
||||
// The request was made and the server responded with a status code
|
||||
// that falls out of the range of 2xx
|
||||
message = error.response.data.error;
|
||||
header += error.response.status;
|
||||
} else if (error.request) {
|
||||
// The request was made but no response was received
|
||||
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
||||
// http.ClientRequest in node.js
|
||||
message = "Anfrage fehlgeschlagen.";
|
||||
} else {
|
||||
// Something happened in setting up the request that triggered an Error
|
||||
console.log('Error', error.message);
|
||||
message = error.message;
|
||||
}
|
||||
console.log(error.config);
|
||||
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: message, title: header, });
|
||||
console.log(error.config);
|
||||
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: message, title: header,});
|
||||
resolve(true);
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
fetchMyCaches() {
|
||||
return new Promise(resolve => {
|
||||
console.log("fetchMyCaches...");
|
||||
if (this.$store.state.auth.isAuthenticated && localStorage.getItem('userToken')) {
|
||||
const token = JSON.parse(localStorage.getItem('userToken')).token;
|
||||
this.$axios.get('/api/getMyCaches', {params: {token}})
|
||||
.then((response) => {
|
||||
console.log("process data...")
|
||||
console.log(response.data)
|
||||
for (let item of response.data) {
|
||||
this.caches.forEach(cache => {
|
||||
if (cache.id === item.cache.id) {
|
||||
cache.cacheAccesDefinition = item.cacheAccesDefinition.id;
|
||||
console.log("found accessdefinition: id: " + cache.id + " ad: " + cache.cacheAccesDefinition);
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
console.log(this.caches);
|
||||
console.log("data processed.")
|
||||
}).finally(() => resolve(true))
|
||||
} else {
|
||||
resolve(true);
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
confirmDelete(cacheID) {
|
||||
this.$q.dialog({
|
||||
title: 'Löschen...',
|
||||
message: 'Willst du diesen Cache wirklich löschen?',
|
||||
persistent: true,
|
||||
cancel: true,
|
||||
}).onOk(() => {
|
||||
console.log('>>>> OK');
|
||||
this.deleteCache(cacheID)
|
||||
}).onCancel(() => {
|
||||
console.log('>>>> Cancel')
|
||||
}).onDismiss(() => {
|
||||
})
|
||||
},
|
||||
|
||||
addCache() {
|
||||
this.$router.push({path: `/cache`})
|
||||
},
|
||||
editCache() {
|
||||
},
|
||||
initMap(){
|
||||
initMap() {
|
||||
console.log("Signalwort: " + this.pois);
|
||||
// this.$axios.post('http://seserver.se.hs-heilbronn.de:3000/api/map', {
|
||||
// body: this.pois
|
||||
// }).then((response)=>{
|
||||
// console.log(response)
|
||||
// })
|
||||
// },
|
||||
// this.$axios.post('http://seserver.se.hs-heilbronn.de:3000/api/map', {
|
||||
// body: this.pois
|
||||
// }).then((response)=>{
|
||||
// console.log(response)
|
||||
// })
|
||||
// },
|
||||
this.$axios.get('http://www.se.hs-heilbronn.de:3000/api/map/lon=9&lat=49', {
|
||||
body: this.pois
|
||||
}).then((response)=>{
|
||||
}).then((response) => {
|
||||
console.log(response)
|
||||
})
|
||||
},
|
||||
@ -198,7 +277,7 @@
|
||||
message = error.message;
|
||||
}
|
||||
console.log(error.config);
|
||||
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: message, title: header, });
|
||||
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: message, title: header,});
|
||||
})
|
||||
},
|
||||
startCache(cacheID) {
|
||||
@ -208,6 +287,41 @@
|
||||
this.$store.state.currentCache.currentCacheID = Number(cacheID);
|
||||
this.$router.push({path: `/CacheStart/${cacheID}`})
|
||||
},
|
||||
continueCache(cacheID) {
|
||||
console.log("cacheID");
|
||||
console.log(cacheID);
|
||||
let currentStationID;
|
||||
if (localStorage.getItem('userToken')) {
|
||||
let params = {cacheID: cacheID};
|
||||
params.token = JSON.parse(localStorage.getItem('userToken')).token;
|
||||
this.$axios.get('/api/getCurrentStation', {params})
|
||||
.then((response) => {
|
||||
console.log(response.data);
|
||||
currentStationID = response.data.aktuelleStation.id;
|
||||
this.$router.push({path: `/station/${cacheID}/${currentStationID}`});
|
||||
})
|
||||
.catch((error) => {
|
||||
});
|
||||
}
|
||||
},
|
||||
goToReward(cacheID) {
|
||||
console.log("cacheID");
|
||||
console.log(cacheID);
|
||||
let currentStationID;
|
||||
if (localStorage.getItem('userToken')) {
|
||||
let params = {cacheID: cacheID};
|
||||
params.token = JSON.parse(localStorage.getItem('userToken')).token;
|
||||
this.$axios.get('/api/getCurrentStation', {params})
|
||||
.then((response) => {
|
||||
console.log(response.data);
|
||||
currentStationID = response.data.aktuelleStation.id;
|
||||
this.$router.push({path: `/CacheEnd/${params.cacheID}`});
|
||||
})
|
||||
.catch((error) => {
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
generateQrCodes(cacheID) {
|
||||
this.$router.push({path: `/generator/${cacheID}`})
|
||||
}
|
||||
|
||||
@ -37,6 +37,8 @@
|
||||
},
|
||||
beforeRouteUpdate(to, from, next) {
|
||||
console.log("beforeRouteUpdate: reset data and fetch");
|
||||
this.cameraActive = false;
|
||||
this.result = null;
|
||||
this.cacheID = "";
|
||||
this.cacheName = "";
|
||||
this.cache = {
|
||||
|
||||
@ -5,7 +5,7 @@ import routes from "./routes";
|
||||
import {axiosInstance} from "../boot/axios";
|
||||
Vue.use(VueRouter);
|
||||
|
||||
//import store from "../store/index";
|
||||
import store from "../store/index";
|
||||
|
||||
/*
|
||||
* If not building with SSR mode, you can
|
||||
@ -57,6 +57,7 @@ export default function({ store }/* { store, ssrContext } */) {
|
||||
})
|
||||
.then((response) => {
|
||||
console.log("Token valid!");
|
||||
store.commit('auth/SET_AUTHENTICATED');
|
||||
return next();
|
||||
})
|
||||
.catch((error) => {
|
||||
@ -72,6 +73,7 @@ export default function({ store }/* { store, ssrContext } */) {
|
||||
title: "Bitte erneut anmelden.",
|
||||
color: "blue", });
|
||||
localStorage.removeItem('userToken');
|
||||
store.commit('auth/SET_AUTHENTICATED');
|
||||
return next('/Login');
|
||||
} else {
|
||||
console.log("unexpected behaviour");
|
||||
|
||||
@ -324,6 +324,39 @@ public class Controller {
|
||||
return createCacheUtil(cache);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Edits a Cache")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 404, message = "Database error"),
|
||||
@ApiResponse(code = 401, message = "JWT Token expired"),
|
||||
@ApiResponse(code = 400, message = "Something wrong with the given Parameters")
|
||||
})
|
||||
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
|
||||
@RequestMapping(value = "/api/editCache", method = RequestMethod.PUT, produces = "application/json")
|
||||
@ResponseBody
|
||||
public ResponseEntity editCache(@RequestBody Cache newCache){
|
||||
|
||||
//----------------------
|
||||
//Get Cache
|
||||
ResponseEntity getCache = FinderUtil.findCacheById(newCache.getId() + "");
|
||||
|
||||
if (getCache.getStatusCodeValue() != 200) {
|
||||
return getCache;
|
||||
}
|
||||
|
||||
Cache oldCache = (Cache) getCache.getBody();
|
||||
//----------------------
|
||||
|
||||
oldCache.setDescription(newCache.getDescription());
|
||||
oldCache.setName(newCache.getName());
|
||||
oldCache.setRankingPoints(newCache.getRankingPoints());
|
||||
oldCache.setReward(newCache.getReward());
|
||||
oldCache.setStationen(newCache.getStationen());
|
||||
|
||||
cacheRepository.save(oldCache);
|
||||
|
||||
return ResponseEntity.status(200).body("Cache edited");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Checks if the given User has an admin role")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 404, message = "Database error"),
|
||||
@ -673,21 +706,22 @@ public class Controller {
|
||||
// verlässt team
|
||||
user_info.setTeam(null);
|
||||
|
||||
int i = 0;
|
||||
user_infoRepository.save(user_info);
|
||||
|
||||
//int i = 0;
|
||||
// zählt teammitglieder
|
||||
for (User_Info userInfo1 : user_infoRepository.findAll()) {
|
||||
List<User_Info> user_infos = user_infoRepository.findByTeam(team);
|
||||
/*for (User_Info userInfo1 : user_infoRepository.findAll()) {
|
||||
if (userInfo1.getTeam().equals(team)) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
// löscht team, wenn keine teammitglieder mehr vorhanden
|
||||
if (i == 0) {
|
||||
if (user_infos.size() == 0) {
|
||||
teamRepository.delete(team);
|
||||
}
|
||||
|
||||
user_infoRepository.save(user_info);
|
||||
|
||||
return ResponseEntity.status(200).body("Ok");
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user