From dc2d69356256f6c987e6242b5d9956ac09b0aaa1 Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Fri, 10 May 2019 09:23:55 +0200 Subject: [PATCH 01/10] added confirmation promt to delete Cache --- frontend/quasar.conf.js | 3 ++- frontend/src/pages/Login.vue | 2 +- frontend/src/pages/Overview.vue | 18 +++++++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/frontend/quasar.conf.js b/frontend/quasar.conf.js index 7e353ec..f1a98b0 100644 --- a/frontend/quasar.conf.js +++ b/frontend/quasar.conf.js @@ -81,7 +81,8 @@ module.exports = function (ctx) { // Quasar plugins plugins: [ - 'Notify' + 'Notify', + 'Dialog' ] // iconSet: 'ionicons-v4' diff --git a/frontend/src/pages/Login.vue b/frontend/src/pages/Login.vue index ec2a41d..96418a7 100644 --- a/frontend/src/pages/Login.vue +++ b/frontend/src/pages/Login.vue @@ -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()"); diff --git a/frontend/src/pages/Overview.vue b/frontend/src/pages/Overview.vue index d55cae8..2f0d8ad 100644 --- a/frontend/src/pages/Overview.vue +++ b/frontend/src/pages/Overview.vue @@ -45,7 +45,7 @@ - @@ -154,6 +154,22 @@ this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: message, title: header, }); }) }, + + 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`}) }, From d1b7fb7c87620ecd337111c32ff9795c779f7105 Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Fri, 10 May 2019 09:49:15 +0200 Subject: [PATCH 02/10] fixed bug in qrscanner component --- frontend/quasar.conf.js | 3 +++ frontend/src/components/qrscanner.vue | 32 +++++++++++++++------------ frontend/src/pages/StationView.vue | 2 ++ frontend/src/router/index.js | 4 +++- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/frontend/quasar.conf.js b/frontend/quasar.conf.js index f1a98b0..c0f8b50 100644 --- a/frontend/quasar.conf.js +++ b/frontend/quasar.conf.js @@ -72,6 +72,9 @@ module.exports = function (ctx) { 'QPopupEdit', 'QSlideTransition', 'QToggle', + 'QStepper', + 'QStep', + 'QStepperNavigation' ], directives: [ diff --git a/frontend/src/components/qrscanner.vue b/frontend/src/components/qrscanner.vue index a2abe74..471a353 100644 --- a/frontend/src/components/qrscanner.vue +++ b/frontend/src/components/qrscanner.vue @@ -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() - }, } diff --git a/frontend/src/pages/StationView.vue b/frontend/src/pages/StationView.vue index 990e5b1..5e32c7c 100644 --- a/frontend/src/pages/StationView.vue +++ b/frontend/src/pages/StationView.vue @@ -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 = { diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index 713eb99..e56463b 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -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"); From 9410463620f3c3caa4efba6f427b70d3b97d344a Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Fri, 10 May 2019 11:16:29 +0200 Subject: [PATCH 03/10] implemented progress bar --- frontend/quasar.conf.js | 4 +- frontend/src/pages/MyCaches.vue | 139 +++++++++++--------------------- frontend/src/pages/Overview.vue | 2 +- 3 files changed, 51 insertions(+), 94 deletions(-) diff --git a/frontend/quasar.conf.js b/frontend/quasar.conf.js index c0f8b50..5fc390f 100644 --- a/frontend/quasar.conf.js +++ b/frontend/quasar.conf.js @@ -72,9 +72,7 @@ module.exports = function (ctx) { 'QPopupEdit', 'QSlideTransition', 'QToggle', - 'QStepper', - 'QStep', - 'QStepperNavigation' + 'QLinearProgress' ], directives: [ diff --git a/frontend/src/pages/MyCaches.vue b/frontend/src/pages/MyCaches.vue index ff7022f..1dab5cd 100644 --- a/frontend/src/pages/MyCaches.vue +++ b/frontend/src/pages/MyCaches.vue @@ -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'" > - - - - - {{'Nächste Aufgabe: ' + startedCache.aktuelleStation.description }} - - {{'Ranglistenpunkte für diesen Cache: ' + startedCache.cache.rankingPoints}} + + + + + + {{ startedCache.progress * 100 }}% bereits geschafft - - - - + @@ -58,7 +56,9 @@ - + - @@ -104,11 +105,8 @@ return { tab: 'startedCaches', startedCaches: [], - inviteMail: "", - currentTeamStatus: "Dienstag 15:00 Treffen zum Blumencache", - teamStatus: "", - userName: null, - email: null, + + //progress: 0.4 } }, mounted: function () { @@ -119,12 +117,35 @@ }, }, created: function () { - this.fetchUserCaches(); this.$store.commit('auth/SET_AUTHENTICATED'); - this.$store.commit('auth/SET_USER'); + //this.$store.commit('auth/SET_USER'); + this.fetchUserCaches(); + }, methods: { - fetchUserCaches: function () { + calculateProgress() { + console.log("calcProgress...") + console.log("this.startedCaches: ") + console.log(this.startedCaches) + // for (let startedCache of this.startedCaches) { + // 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(startedCache.progress) + // } + 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(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; @@ -135,6 +156,7 @@ .then((response) => { console.log(response.data) this.startedCaches = response.data; + }).catch((error) => { // Error let msg; @@ -156,7 +178,11 @@ } console.log(error.config); this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,}); - }) + }).finally(() => { + console.log("fetchCaches... finally") + this.calculateProgress(); + }); + console.log("fetchCaches... outside") }, continueCache(cacheID) { console.log("cacheID"); @@ -192,73 +218,6 @@ }); } }, - getPersonalRanking() { - const name = JSON.parse(localStorage.getItem('userToken')).name; - console.log(JSON.parse(localStorage.getItem('userToken')).name); - this.$axios.get('/api/hello', {params: {name}}) - .then((response) => { - this.userRanking = response.data; - console.log(response.data); - }).catch((error) => { - // Error - let msg; - let title; - if (error.response) { - // The request was made and the server responded with a status code - title = "Problem with response!"; - msg = error.response; - } else if (error.request) { - // The request was made but no response was received - title = "Problem with request!"; - msg = "Error occured due to wrong server request!" - console.log(error.request); - } else { - // Something happened in setting up the request that triggered an Error - title = "Error"; - msg = error.message; - console.log('Error', error.message); - } - console.log(error.config); - this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,}); - }) - }, - getTeamData() { - const userName = {name: JSON.parse(localStorage.getItem('userToken')).name}; - this.$axios.get('/api/getTeam', {params: userName}) - .then(response => { - console.log("getTeam: " + response); - }).catch((error) => { - // Error - let msg; - let title; - if (error.response) { - // The request was made and the server responded with a status code - title = "Problem with response!"; - msg = error.response; - } else if (error.request) { - // The request was made but no response was received - title = "Problem with request!"; - msg = "Error occured due to wrong server request!" - console.log(error.request); - } else { - // Something happened in setting up the request that triggered an Error - title = "Error"; - msg = error.message; - console.log('Error', error.message); - } - console.log(error.config); - this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,}); - }) - - }, - - dropDownSelectItem(item) { - if (item === 'team') { - this.dropDownSelectedItem = this.teamName; - } else { - this.dropDownSelectedItem = item; - } - }, } } diff --git a/frontend/src/pages/Overview.vue b/frontend/src/pages/Overview.vue index 2f0d8ad..0741a0c 100644 --- a/frontend/src/pages/Overview.vue +++ b/frontend/src/pages/Overview.vue @@ -29,7 +29,7 @@ expand-separator icon="location_on" :label="cache.name" - :caption="cache.rankingPoints+' Punkte / Size '+cache.stationen.length" + :caption="cache.rankingPoints+' Punkte, '+cache.stationen.length+' Stationen'" > From 235f3fd0b57061ef869cf3ceaebb7b449fcbb7cd Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Fri, 10 May 2019 11:30:39 +0200 Subject: [PATCH 04/10] small bugfix --- frontend/src/pages/MyCaches.vue | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/frontend/src/pages/MyCaches.vue b/frontend/src/pages/MyCaches.vue index 1dab5cd..aa27a91 100644 --- a/frontend/src/pages/MyCaches.vue +++ b/frontend/src/pages/MyCaches.vue @@ -105,8 +105,6 @@ return { tab: 'startedCaches', startedCaches: [], - - //progress: 0.4 } }, mounted: function () { @@ -118,30 +116,21 @@ }, created: function () { this.$store.commit('auth/SET_AUTHENTICATED'); - //this.$store.commit('auth/SET_USER'); this.fetchUserCaches(); - }, methods: { calculateProgress() { console.log("calcProgress...") console.log("this.startedCaches: ") console.log(this.startedCaches) - // for (let startedCache of this.startedCaches) { - // 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(startedCache.progress) - // } 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(startedCache.progress) - }) - console.log("calcProgress finished.") + console.log("progress: "+startedCache.progress) + }); + console.log("calcProgress finished."); console.log(this.startedCaches) }, fetchUserCaches() { @@ -156,7 +145,7 @@ .then((response) => { console.log(response.data) this.startedCaches = response.data; - + this.calculateProgress(); }).catch((error) => { // Error let msg; @@ -180,9 +169,7 @@ this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,}); }).finally(() => { console.log("fetchCaches... finally") - this.calculateProgress(); }); - console.log("fetchCaches... outside") }, continueCache(cacheID) { console.log("cacheID"); From ec4202a5aa5585570ed2d7c748268c5a4912485f Mon Sep 17 00:00:00 2001 From: Maximilian Leopold Date: Fri, 10 May 2019 17:13:10 +0200 Subject: [PATCH 05/10] Noch mehr von Michaels methoden fixen --- .../hhn/labsw/bugageocaching/controller/Controller.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index a9643d9..bdbe78c 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -673,16 +673,17 @@ public class Controller { // verlässt team user_info.setTeam(null); - int i = 0; + //int i = 0; // zählt teammitglieder - for (User_Info userInfo1 : user_infoRepository.findAll()) { + List 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); } From f110c81ba369ce5e3d916ddda7a392c4a73847bd Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Fri, 10 May 2019 17:19:38 +0200 Subject: [PATCH 06/10] improved cache overview --- frontend/src/layouts/MyLayout.vue | 2 +- frontend/src/pages/CacheEnd.vue | 4 +- frontend/src/pages/Overview.vue | 214 ++++++++++++++++++++++-------- 3 files changed, 159 insertions(+), 61 deletions(-) diff --git a/frontend/src/layouts/MyLayout.vue b/frontend/src/layouts/MyLayout.vue index 23d2b46..7d4edf9 100644 --- a/frontend/src/layouts/MyLayout.vue +++ b/frontend/src/layouts/MyLayout.vue @@ -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()"); diff --git a/frontend/src/pages/CacheEnd.vue b/frontend/src/pages/CacheEnd.vue index 93e4f8c..7012c57 100644 --- a/frontend/src/pages/CacheEnd.vue +++ b/frontend/src/pages/CacheEnd.vue @@ -9,8 +9,8 @@

- - + +
diff --git a/frontend/src/pages/Overview.vue b/frontend/src/pages/Overview.vue index 0741a0c..4daba55 100644 --- a/frontend/src/pages/Overview.vue +++ b/frontend/src/pages/Overview.vue @@ -21,13 +21,19 @@ - - + + @@ -43,22 +49,29 @@
- + + + icon="delete" size="xs"/> + icon="edit" size="xs"/> + icon="image" label="QRCodes" size="xs"/> -
+ @@ -94,64 +107,114 @@ 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."; + 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 { - // Something happened in setting up the request that triggered an Error - console.log('Error', error.message); - message = error.message; + resolve(true); } - console.log(error.config); - this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: message, title: header, }); }) }, @@ -175,17 +238,17 @@ }, 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) }) }, @@ -214,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) { @@ -224,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}`}) } From c5ffa61eda21f2c07e4b71187af225dee66e272d Mon Sep 17 00:00:00 2001 From: Maximilian Leopold Date: Fri, 10 May 2019 17:50:45 +0200 Subject: [PATCH 07/10] Added edit Cache --- .../bugageocaching/controller/Controller.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index bdbe78c..59e6db1 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -324,6 +324,32 @@ public class Controller { return createCacheUtil(cache); } + @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"), From 06da9b9a4f73d9945069b447084e207817dd8748 Mon Sep 17 00:00:00 2001 From: Maximilian Leopold Date: Fri, 10 May 2019 17:51:59 +0200 Subject: [PATCH 08/10] Added docu --- .../hhn/labsw/bugageocaching/controller/Controller.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index 59e6db1..2bee0ce 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -324,6 +324,13 @@ 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){ From 2d68ad6a2bde84be902895375a2795230a463587 Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Fri, 10 May 2019 17:55:06 +0200 Subject: [PATCH 09/10] improved cache progress percentage --- frontend/src/pages/MyCaches.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/pages/MyCaches.vue b/frontend/src/pages/MyCaches.vue index aa27a91..d541885 100644 --- a/frontend/src/pages/MyCaches.vue +++ b/frontend/src/pages/MyCaches.vue @@ -39,7 +39,7 @@ - {{ startedCache.progress * 100 }}% bereits geschafft + {{ Math.round(startedCache.progress * 100) }}% bereits geschafft From 96221b950427a136cda47dd296c81434a06258f3 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 13 May 2019 11:32:57 +0200 Subject: [PATCH 10/10] fixed an error in leaveTeam --- .../java/hhn/labsw/bugageocaching/controller/Controller.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index 2bee0ce..3903591 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -706,6 +706,8 @@ public class Controller { // verlässt team user_info.setTeam(null); + user_infoRepository.save(user_info); + //int i = 0; // zählt teammitglieder List user_infos = user_infoRepository.findByTeam(team); @@ -720,8 +722,6 @@ public class Controller { teamRepository.delete(team); } - user_infoRepository.save(user_info); - return ResponseEntity.status(200).body("Ok"); }