From 10ac55b36bebf69b01168e07c5a03bee3746165b Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Thu, 21 Mar 2019 23:24:10 +0100 Subject: [PATCH 01/44] first simple data from demo api in index.vue --- frontend/quasar.conf.js | 5 +- frontend/src/pages/Index.vue | 137 +++++++---------------------------- 2 files changed, 30 insertions(+), 112 deletions(-) diff --git a/frontend/quasar.conf.js b/frontend/quasar.conf.js index 3f82b10..f8f9711 100644 --- a/frontend/quasar.conf.js +++ b/frontend/quasar.conf.js @@ -46,7 +46,8 @@ module.exports = function (ctx) { 'QCardSection', 'QCardActions', 'QCheckbox', - 'QSeparator' + 'QSeparator', + 'QInput' ], directives: [ @@ -86,7 +87,7 @@ module.exports = function (ctx) { devServer: { // https: true, // port: 8080, - open: true // opens browser window automatically + open: false // opens browser window automatically }, // animations: 'all' --- includes all animations diff --git a/frontend/src/pages/Index.vue b/frontend/src/pages/Index.vue index 4f72725..03ae658 100644 --- a/frontend/src/pages/Index.vue +++ b/frontend/src/pages/Index.vue @@ -2,9 +2,9 @@
- + @@ -59,127 +59,44 @@ export default { denseOn: true, filter: '', selected: [], + todos: [], columns: [ { name: 'desc', required: true, label: 'Dessert (100g serving)', align: 'left', - field: row => row.name, + field: row => row.title, format: val => `${val}`, sortable: true }, - { name: 'calories', align: 'center', label: 'Calories', field: 'calories', sortable: true }, - { name: 'fat', label: 'Fat (g)', field: 'fat', sortable: true }, - { name: 'carbs', label: 'Carbs (g)', field: 'carbs' }, - { name: 'protein', label: 'Protein (g)', field: 'protein' }, - { name: 'sodium', label: 'Sodium (mg)', field: 'sodium' }, - { name: 'calcium', label: 'Calcium (%)', field: 'calcium', sortable: true, sort: (a, b) => parseInt(a, 10) - parseInt(b, 10) }, - { name: 'iron', label: 'Iron (%)', field: 'iron', sortable: true, sort: (a, b) => parseInt(a, 10) - parseInt(b, 10) } + { name: 'userId', align: 'center', label: 'ID', field: 'userId', sortable: true }, + { name: 'id', label: 'fID', field: 'id', sortable: true }, + { name: 'title', label: 'Titel', field: 'title' }, + { name: 'completed', label: 'Komplett', field: 'completed' }, ], data: [ { - name: 'Frozen Yogurt', - calories: 159, - fat: 6.0, - carbs: 24, - protein: 4.0, - sodium: 87, - calcium: '14%', - iron: '1%' - }, - { - name: 'Ice cream sandwich', - calories: 237, - fat: 9.0, - carbs: 37, - protein: 4.3, - sodium: 129, - calcium: '8%', - iron: '1%' - }, - { - name: 'Eclair', - calories: 262, - fat: 16.0, - carbs: 23, - protein: 6.0, - sodium: 337, - calcium: '6%', - iron: '7%' - }, - { - name: 'Cupcake', - calories: 305, - fat: 3.7, - carbs: 67, - protein: 4.3, - sodium: 413, - calcium: '3%', - iron: '8%' - }, - { - name: 'Gingerbread', - calories: 356, - fat: 16.0, - carbs: 49, - protein: 3.9, - sodium: 327, - calcium: '7%', - iron: '16%' - }, - { - name: 'Jelly bean', - calories: 375, - fat: 0.0, - carbs: 94, - protein: 0.0, - sodium: 50, - calcium: '0%', - iron: '0%' - }, - { - name: 'Lollipop', - calories: 392, - fat: 0.2, - carbs: 98, - protein: 0, - sodium: 38, - calcium: '0%', - iron: '2%' - }, - { - name: 'Honeycomb', - calories: 408, - fat: 3.2, - carbs: 87, - protein: 6.5, - sodium: 562, - calcium: '0%', - iron: '45%' - }, - { - name: 'Donut', - calories: 452, - fat: 25.0, - carbs: 51, - protein: 4.9, - sodium: 326, - calcium: '2%', - iron: '22%' - }, - { - name: 'KitKat', - calories: 518, - fat: 26.0, - carbs: 65, - protein: 7, - sodium: 54, - calcium: '12%', - iron: '6%' + "userId": 1, + "id": 1, + "title": "delectus aut autem", + "completed": false } ] } + }, + + created: function() { + this.fetchTodos(); + }, + + methods: { + fetchTodos () { + this.$axios.get('https://jsonplaceholder.typicode.com/todos') + .then((response) => { + this.todos = response.data; + }) + } } } From 2f2f0edff72e97cb079b3d262b9b6ff027c502b2 Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Sat, 23 Mar 2019 10:43:39 +0100 Subject: [PATCH 02/44] sample cards for caches --- .idea/modules.xml | 10 --- ....hhn.labsw.labswp_2019_sose_geocaching.iml | 12 ---- .idea/vcs.xml | 6 ++ frontend/quasar.conf.js | 3 +- frontend/src/pages/Index.vue | 72 ++++++++----------- 5 files changed, 37 insertions(+), 66 deletions(-) delete mode 100644 .idea/modules.xml delete mode 100644 .idea/modules/LabSWPS.de.hhn.labsw.labswp_2019_sose_geocaching.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 9db8a1d..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/LabSWPS.de.hhn.labsw.labswp_2019_sose_geocaching.iml b/.idea/modules/LabSWPS.de.hhn.labsw.labswp_2019_sose_geocaching.iml deleted file mode 100644 index 92b5305..0000000 --- a/.idea/modules/LabSWPS.de.hhn.labsw.labswp_2019_sose_geocaching.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/frontend/quasar.conf.js b/frontend/quasar.conf.js index f8f9711..51b4962 100644 --- a/frontend/quasar.conf.js +++ b/frontend/quasar.conf.js @@ -47,7 +47,8 @@ module.exports = function (ctx) { 'QCardActions', 'QCheckbox', 'QSeparator', - 'QInput' + 'QInput', + 'QImg' ], directives: [ diff --git a/frontend/src/pages/Index.vue b/frontend/src/pages/Index.vue index 03ae658..0ad2ac0 100644 --- a/frontend/src/pages/Index.vue +++ b/frontend/src/pages/Index.vue @@ -1,49 +1,35 @@ From 9001b6d733efbc198b11020ee26f52e0be3ad5a1 Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Sat, 23 Mar 2019 11:36:02 +0100 Subject: [PATCH 03/44] fetch data from localhost/allCaches --- .gitignore | 5 ++++- frontend/src/pages/Index.vue | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 6c08a57..db2f45b 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,10 @@ labswp_2019_sose_geocaching.iml # public folder src/main/resources/public/ -.idea/ +# .idea/ +# nicht notwendig. alle problematischen files sind draußen. +# wenns trotzdem noch probleme macht muss man die entsprechenden +# files noch mit "git rm --cached untracken. # Gradle diff --git a/frontend/src/pages/Index.vue b/frontend/src/pages/Index.vue index 0ad2ac0..3e0e4ae 100644 --- a/frontend/src/pages/Index.vue +++ b/frontend/src/pages/Index.vue @@ -45,7 +45,7 @@ export default { denseOn: true, filter: '', selected: [], - todos: [], + caches: [], columns: [ { name: 'desc', @@ -61,14 +61,14 @@ export default { { name: 'title', label: 'Titel', field: 'title' }, { name: 'completed', label: 'Komplett', field: 'completed' }, ], - data: [ - { - "userId": 1, - "id": 1, - "title": "delectus aut autem", - "completed": false - } - ] + // data: [ + // { + // "userId": 1, + // "id": 1, + // "title": "delectus aut autem", + // "completed": false + // } + // ] } }, @@ -78,9 +78,9 @@ export default { methods: { fetchTodos () { - this.$axios.get('https://jsonplaceholder.typicode.com/todos') + this.$axios.get('http://localhost:8080/allCaches') .then((response) => { - this.todos = response.data; + this.caches = response.data; }) } } From 7a72715117110a6abc00b04e055e6037daac8bec Mon Sep 17 00:00:00 2001 From: Katharina Will Date: Sat, 23 Mar 2019 17:24:02 +0100 Subject: [PATCH 04/44] Designed pages CacheView and Login --- frontend/quasar.conf.js | 10 +- frontend/src/layouts/MyLayout.vue | 4 +- frontend/src/pages/CacheView.vue | 199 ++++++++++++++++++++++++++++++ frontend/src/pages/Login.vue | 52 ++++++++ frontend/src/router/routes.js | 10 ++ 5 files changed, 272 insertions(+), 3 deletions(-) diff --git a/frontend/quasar.conf.js b/frontend/quasar.conf.js index 3f82b10..00b6c98 100644 --- a/frontend/quasar.conf.js +++ b/frontend/quasar.conf.js @@ -46,7 +46,15 @@ module.exports = function (ctx) { 'QCardSection', 'QCardActions', 'QCheckbox', - 'QSeparator' + 'QSeparator', + 'QTabs', + 'QTab', + 'QRouteTab', + 'QTabPanels', + 'QTabPanel', + 'QInput', + 'QFab', + 'QFabAction' ], directives: [ diff --git a/frontend/src/layouts/MyLayout.vue b/frontend/src/layouts/MyLayout.vue index da749d4..80c2afb 100644 --- a/frontend/src/layouts/MyLayout.vue +++ b/frontend/src/layouts/MyLayout.vue @@ -1,6 +1,6 @@ + + diff --git a/frontend/src/pages/Login.vue b/frontend/src/pages/Login.vue index e69de29..8b5ee79 100644 --- a/frontend/src/pages/Login.vue +++ b/frontend/src/pages/Login.vue @@ -0,0 +1,52 @@ + + + diff --git a/frontend/src/router/routes.js b/frontend/src/router/routes.js index 8571b3d..2a9eed2 100644 --- a/frontend/src/router/routes.js +++ b/frontend/src/router/routes.js @@ -8,6 +8,16 @@ const routes = [ path: "/dashboard/", component: () => import("layouts/MyLayout.vue"), children: [{ path: "", component: () => import("pages/Dashboard.vue") }] + }, + { + path: "/cacheview/", + component: () => import("layouts/MyLayout.vue"), + children: [{ path: "", component: () => import("pages/CacheView.vue") }] + }, + { + path: "/login/", + component: () => import("layouts/MyLayout.vue"), + children: [{ path: "", component: () => import("pages/Login.vue") }] } ]; From 42e6d72fc3498313e4398d273c5421a370abd816 Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Sat, 23 Mar 2019 17:52:19 +0100 Subject: [PATCH 05/44] changed quasar dev port to 8081 and therefor added CORS policy to controller. tested allcaches api --- frontend/quasar.conf.js | 4 +- frontend/src/pages/Index.vue | 88 ------------------- frontend/src/router/routes.js | 5 ++ frontend/src/store/index.js | 52 ++++++++--- .../bugageocaching/controller/Controller.java | 2 + 5 files changed, 48 insertions(+), 103 deletions(-) delete mode 100644 frontend/src/pages/Index.vue diff --git a/frontend/quasar.conf.js b/frontend/quasar.conf.js index 51b4962..de6b87d 100644 --- a/frontend/quasar.conf.js +++ b/frontend/quasar.conf.js @@ -87,8 +87,8 @@ module.exports = function (ctx) { devServer: { // https: true, - // port: 8080, - open: false // opens browser window automatically + port: 8081, + open: true // opens browser window automatically }, // animations: 'all' --- includes all animations diff --git a/frontend/src/pages/Index.vue b/frontend/src/pages/Index.vue deleted file mode 100644 index 3e0e4ae..0000000 --- a/frontend/src/pages/Index.vue +++ /dev/null @@ -1,88 +0,0 @@ - - - - - diff --git a/frontend/src/router/routes.js b/frontend/src/router/routes.js index 8571b3d..554e56b 100644 --- a/frontend/src/router/routes.js +++ b/frontend/src/router/routes.js @@ -8,6 +8,11 @@ const routes = [ path: "/dashboard/", component: () => import("layouts/MyLayout.vue"), children: [{ path: "", component: () => import("pages/Dashboard.vue") }] + }, + { + path: "/testcaches/", + component: () => import("layouts/MyLayout.vue"), + children: [{ path: "", component: () => import("pages/TestCaches.vue") }] } ]; diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index ca79aab..e8a81c7 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -1,25 +1,51 @@ import Vue from "vue"; import Vuex from "vuex"; +import Axios from "axios"; // import example from './module-example' -Vue.use(Vuex); +Vue.use(Vuex, Axios); /* * If not building with SSR mode, you can * directly export the Store instantiation */ -export default function(/* { ssrContext } */) { - const Store = new Vuex.Store({ - modules: { - // example +// export default function(/* { ssrContext } */) { +// const Store = new Vuex.Store({ +// modules: { +// // example +// }, +// +// // enable strict mode (adds overhead!) +// // for dev mode only +// strict: process.env.DEV +// }); +// +// return Store; +// } + +export default new Vuex.Store({ + state: { + caches: [], + userToken: "", + userAuthenticated: true + }, + actions: {}, + mutations: { + checkAuth(state) { + console.log("checkAuth()"); + state.userAuthenticated = !state.userToken.isEmpty(); }, - - // enable strict mode (adds overhead!) - // for dev mode only - strict: process.env.DEV - }); - - return Store; -} + setUserToken(state, token) { + console.log("setUserToken()"); + state.userToken = token; + this.checkAuth(state); + } + }, + getters: { + userToken: state => state.userToken, + userAuthenticated: state => state.userAuthenticated + }, + modules: {} +}); diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index 8103518..9a03c55 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -5,6 +5,7 @@ import hhn.labsw.bugageocaching.repositories.CacheRepository; import hhn.labsw.bugageocaching.repositories.RewardRepository; import hhn.labsw.bugageocaching.repositories.StationRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; @@ -21,6 +22,7 @@ public class Controller { @Autowired StationRepository stationRepository; + @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose @RequestMapping("/allCaches") @ResponseBody public String getAllCaches(){ From b75f4d65e33d786891f68a849810adc0c55fc5df Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Sat, 23 Mar 2019 17:52:36 +0100 Subject: [PATCH 06/44] changed quasar dev port to 8081 and therefor added CORS policy to controller. tested allcaches api --- frontend/src/pages/TestCaches.vue | 83 +++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 frontend/src/pages/TestCaches.vue diff --git a/frontend/src/pages/TestCaches.vue b/frontend/src/pages/TestCaches.vue new file mode 100644 index 0000000..71e251c --- /dev/null +++ b/frontend/src/pages/TestCaches.vue @@ -0,0 +1,83 @@ + + + + + From f031ae9a9131e897f2acd2f6c0810b56ba4b016c Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 25 Mar 2019 13:14:54 +0100 Subject: [PATCH 07/44] mapping is done with /api beforehand now --- .../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 81e8242..241b764 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -33,13 +33,13 @@ public class Controller { @Autowired UserRepository userRepository; - @RequestMapping("/allCaches") + @RequestMapping("/api/allCaches") @ResponseBody public String getAllCaches() { return new Gson().toJson(cacheRepository.findAll()); } - @RequestMapping("/startCache") + @RequestMapping("/api/startCache") public @ResponseBody String startCache(@RequestParam(value = "userID", defaultValue = "-1") String userID, @RequestParam String cacheID) throws IllegalParameterException { From e0ee65f16d1a74e7bcb18acec01da9f482a5fba8 Mon Sep 17 00:00:00 2001 From: Katharina Will Date: Mon, 25 Mar 2019 13:17:21 +0100 Subject: [PATCH 08/44] Deleted .idea/ files --- .idea/checkstyle-idea.xml | 16 ---------------- .idea/compiler.xml | 13 ------------- .idea/encodings.xml | 4 ---- .idea/inspectionProfiles/Project_Default.xml | 6 ------ .idea/misc.xml | 9 --------- .idea/modules.xml | 11 ----------- ....de.hhn.labsw.labswp_2019_sose_geocaching.iml | 12 ------------ 7 files changed, 71 deletions(-) delete mode 100644 .idea/checkstyle-idea.xml delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/modules/LabSWPS.de.hhn.labsw.labswp_2019_sose_geocaching.iml diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml deleted file mode 100644 index 3918e38..0000000 --- a/.idea/checkstyle-idea.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 4aac343..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 15a15b2..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 03d9549..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index e62185c..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 50b8b01..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/LabSWPS.de.hhn.labsw.labswp_2019_sose_geocaching.iml b/.idea/modules/LabSWPS.de.hhn.labsw.labswp_2019_sose_geocaching.iml deleted file mode 100644 index 92b5305..0000000 --- a/.idea/modules/LabSWPS.de.hhn.labsw.labswp_2019_sose_geocaching.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file From 211b7279b50ec9dddb7620e038b0af671954151f Mon Sep 17 00:00:00 2001 From: Maximilian Leopold Date: Mon, 25 Mar 2019 15:56:45 +0100 Subject: [PATCH 09/44] Login is now possible --- build.gradle | 3 ++ .../bugageocaching/controller/Controller.java | 32 ++++++++++++++- .../labsw/bugageocaching/entities/Role.java | 34 ++++++++++++++++ .../labsw/bugageocaching/entities/User.java | 40 ++++++++++--------- .../repositories/UserRepository.java | 1 + 5 files changed, 90 insertions(+), 20 deletions(-) create mode 100644 src/main/java/hhn/labsw/bugageocaching/entities/Role.java diff --git a/build.gradle b/build.gradle index 5724707..62a8c2c 100644 --- a/build.gradle +++ b/build.gradle @@ -34,6 +34,9 @@ dependencies { //JSON Parser implementation 'com.google.code.gson:gson:2.8.5' + + compile group: 'org.springframework.security', name: 'spring-security-core', version: '5.1.4.RELEASE' + } node { diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index 241b764..273dd02 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -5,9 +5,14 @@ import hhn.labsw.bugageocaching.entities.*; import hhn.labsw.bugageocaching.exceptions.IllegalParameterException; import hhn.labsw.bugageocaching.repositories.*; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.crypto.bcrypt.BCrypt; import org.springframework.web.bind.annotation.*; +import java.time.Clock; import java.util.Optional; +import java.util.concurrent.atomic.AtomicLong; @RestController public class Controller { @@ -33,12 +38,35 @@ public class Controller { @Autowired UserRepository userRepository; + private AtomicLong counter = new AtomicLong(); + @RequestMapping("/api/allCaches") @ResponseBody public String getAllCaches() { return new Gson().toJson(cacheRepository.findAll()); } + @RequestMapping("/api/login") + @ResponseBody + public ResponseEntity login(@RequestParam(value = "username", defaultValue = "") String username, + @RequestParam(value = "password", defaultValue = "") String password){ + if(username == "" || password == ""){ + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); + } + if(userRepository.findByUsername(username) == null){ + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); + } + + if(BCrypt.checkpw(password, userRepository.findByUsername(username).getPassword())){ + String token = BCrypt.hashpw(String.valueOf(System.currentTimeMillis() + counter.incrementAndGet()), BCrypt.gensalt()); + String hashedToken = BCrypt.hashpw(token, BCrypt.gensalt()); + userRepository.findByUsername(username).setToken(hashedToken); + userRepository.save(userRepository.findByUsername(username)); + return ResponseEntity.ok(new Gson().toJson(token)); + } + return ResponseEntity.status(HttpStatus.BAD_GATEWAY).body(null); + } + @RequestMapping("/api/startCache") public @ResponseBody String startCache(@RequestParam(value = "userID", defaultValue = "-1") String userID, @@ -61,7 +89,7 @@ public class Controller { Cache cache = cacheOptional.get(); bearbeitet.setCache(cache); } else { - throw new IllegalParameterException( "There is no cache with the ID " + cacheID); + throw new IllegalParameterException("There is no cache with the ID " + cacheID); } Optional cacheAccesDefinitionOptional = @@ -83,7 +111,7 @@ public class Controller { Cache cache = cacheOptional.get(); return new Gson().toJson(cache); } else { - throw new IllegalParameterException( "There is no cache with the ID " + cacheID); + throw new IllegalParameterException("There is no cache with the ID " + cacheID); } } } diff --git a/src/main/java/hhn/labsw/bugageocaching/entities/Role.java b/src/main/java/hhn/labsw/bugageocaching/entities/Role.java new file mode 100644 index 0000000..5019a0b --- /dev/null +++ b/src/main/java/hhn/labsw/bugageocaching/entities/Role.java @@ -0,0 +1,34 @@ +package hhn.labsw.bugageocaching.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +public class Role { + + @Id + @GeneratedValue + private int id; + private String name; + + public Role() { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/hhn/labsw/bugageocaching/entities/User.java b/src/main/java/hhn/labsw/bugageocaching/entities/User.java index eb0e75d..ffbed7d 100644 --- a/src/main/java/hhn/labsw/bugageocaching/entities/User.java +++ b/src/main/java/hhn/labsw/bugageocaching/entities/User.java @@ -1,6 +1,7 @@ package hhn.labsw.bugageocaching.entities; import javax.persistence.*; +import java.util.List; @Entity @Table @@ -14,10 +15,13 @@ public class User { private String lastname; private String username; private int rankingPointsSum; - private String discriminator; //should be Admin or Cacher private String email; private String password; - private String salt; + + @ManyToMany + private List roles; + + private String token; @ManyToOne private Team team; @@ -62,14 +66,6 @@ public class User { this.rankingPointsSum = rankingPointsSum; } - public String getDiscriminator() { - return discriminator; - } - - public void setDiscriminator(String discriminator) { - this.discriminator = discriminator; - } - public String getEmail() { return email; } @@ -86,14 +82,6 @@ public class User { this.password = password; } - public String getSalt() { - return salt; - } - - public void setSalt(String salt) { - this.salt = salt; - } - public Team getTeam() { return team; } @@ -101,4 +89,20 @@ public class User { public void setTeam(Team team) { this.team = team; } + + public List getRoles() { + return roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } } diff --git a/src/main/java/hhn/labsw/bugageocaching/repositories/UserRepository.java b/src/main/java/hhn/labsw/bugageocaching/repositories/UserRepository.java index f899608..2434da1 100644 --- a/src/main/java/hhn/labsw/bugageocaching/repositories/UserRepository.java +++ b/src/main/java/hhn/labsw/bugageocaching/repositories/UserRepository.java @@ -4,4 +4,5 @@ import hhn.labsw.bugageocaching.entities.User; import org.springframework.data.repository.CrudRepository; public interface UserRepository extends CrudRepository { + User findByUsername(String username); } From 251f5c3f25ae7d3dfbfed49c896b7f012893b4c5 Mon Sep 17 00:00:00 2001 From: Maximilian Leopold Date: Mon, 25 Mar 2019 17:22:58 +0100 Subject: [PATCH 10/44] =?UTF-8?q?@RequestBody=20hinzugef=C3=BCgt=20beim=20?= =?UTF-8?q?login?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bugageocaching/controller/Controller.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index 273dd02..b0b29d6 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -48,20 +48,19 @@ public class Controller { @RequestMapping("/api/login") @ResponseBody - public ResponseEntity login(@RequestParam(value = "username", defaultValue = "") String username, - @RequestParam(value = "password", defaultValue = "") String password){ - if(username == "" || password == ""){ - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); + public ResponseEntity login(@RequestBody User user){ + if(user.getUsername() == null || user.getPassword() == null){ + return ResponseEntity.status(401).body(null); } - if(userRepository.findByUsername(username) == null){ - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); + if(userRepository.findByUsername(user.getUsername()) == null){ + return ResponseEntity.status(401).body(null); } - if(BCrypt.checkpw(password, userRepository.findByUsername(username).getPassword())){ + if(BCrypt.checkpw(user.getPassword(), userRepository.findByUsername(user.getUsername()).getPassword())){ String token = BCrypt.hashpw(String.valueOf(System.currentTimeMillis() + counter.incrementAndGet()), BCrypt.gensalt()); String hashedToken = BCrypt.hashpw(token, BCrypt.gensalt()); - userRepository.findByUsername(username).setToken(hashedToken); - userRepository.save(userRepository.findByUsername(username)); + userRepository.findByUsername(user.getUsername()).setToken(hashedToken); + userRepository.save(userRepository.findByUsername(user.getUsername())); return ResponseEntity.ok(new Gson().toJson(token)); } return ResponseEntity.status(HttpStatus.BAD_GATEWAY).body(null); From fdeab95b3d0452063d41e3b4136f355d90e6b6f3 Mon Sep 17 00:00:00 2001 From: Katharina Will Date: Mon, 25 Mar 2019 17:32:50 +0100 Subject: [PATCH 11/44] deleted files for fixes --- .idea/checkstyle-idea.xml | 16 ---------------- .idea/compiler.xml | 11 ----------- .idea/encodings.xml | 4 ---- .idea/inspectionProfiles/Project_Default.xml | 6 ------ .idea/misc.xml | 9 --------- .idea/modules.xml | 10 ---------- ....de.hhn.labsw.labswp_2019_sose_geocaching.iml | 12 ------------ .idea/vcs.xml | 6 ------ 8 files changed, 74 deletions(-) delete mode 100644 .idea/checkstyle-idea.xml delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/modules/LabSWPS.de.hhn.labsw.labswp_2019_sose_geocaching.iml delete mode 100644 .idea/vcs.xml diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml deleted file mode 100644 index 3918e38..0000000 --- a/.idea/checkstyle-idea.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 8b96030..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 15a15b2..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 03d9549..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index e62185c..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 9db8a1d..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/LabSWPS.de.hhn.labsw.labswp_2019_sose_geocaching.iml b/.idea/modules/LabSWPS.de.hhn.labsw.labswp_2019_sose_geocaching.iml deleted file mode 100644 index 92b5305..0000000 --- a/.idea/modules/LabSWPS.de.hhn.labsw.labswp_2019_sose_geocaching.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 7db636b01a2da61d08caae6f6c1623a3a1309e89 Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Mon, 25 Mar 2019 19:22:48 +0100 Subject: [PATCH 12/44] some changes --- .gitignore | 5 +-- .idea/modules.xml | 10 +++++ frontend/.eslintrc.js | 2 +- frontend/quasar.conf.js | 1 - frontend/src/layouts/MyLayout.vue | 6 +-- frontend/src/pages/Dashboard.vue | 10 ----- frontend/src/pages/Index.vue | 54 ++++++++++++++++++++++ frontend/src/pages/Login.vue | 74 ++++++++++++++++--------------- frontend/src/pages/TestCaches.vue | 3 ++ 9 files changed, 110 insertions(+), 55 deletions(-) create mode 100644 .idea/modules.xml create mode 100644 frontend/src/pages/Index.vue diff --git a/.gitignore b/.gitignore index db2f45b..6c08a57 100644 --- a/.gitignore +++ b/.gitignore @@ -24,10 +24,7 @@ labswp_2019_sose_geocaching.iml # public folder src/main/resources/public/ -# .idea/ -# nicht notwendig. alle problematischen files sind draußen. -# wenns trotzdem noch probleme macht muss man die entsprechenden -# files noch mit "git rm --cached untracken. +.idea/ # Gradle diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..9db8a1d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index 6ef542c..c4e9e64 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -14,7 +14,7 @@ module.exports = { // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules. extends: [ 'plugin:vue/essential', - '@vue/prettier' + // '@vue/prettier' ], // required to lint *.vue files diff --git a/frontend/quasar.conf.js b/frontend/quasar.conf.js index 1ffd38f..569ef43 100644 --- a/frontend/quasar.conf.js +++ b/frontend/quasar.conf.js @@ -47,7 +47,6 @@ module.exports = function (ctx) { 'QCardActions', 'QCheckbox', 'QSeparator', - 'QInput', 'QImg', 'QTabs', 'QTab', diff --git a/frontend/src/layouts/MyLayout.vue b/frontend/src/layouts/MyLayout.vue index 80c2afb..7dbfd97 100644 --- a/frontend/src/layouts/MyLayout.vue +++ b/frontend/src/layouts/MyLayout.vue @@ -1,7 +1,7 @@ diff --git a/frontend/src/pages/TestCaches.vue b/frontend/src/pages/TestCaches.vue index 71e251c..2f06321 100644 --- a/frontend/src/pages/TestCaches.vue +++ b/frontend/src/pages/TestCaches.vue @@ -23,6 +23,7 @@ + Hallo @@ -68,6 +69,7 @@ export default { }, created: function() { + console.log("created(): " + this.caches); this.fetchTodos(); }, @@ -75,6 +77,7 @@ export default { fetchTodos () { this.$axios.get('http://localhost:8080/allCaches') .then((response) => { + console.log("Caches: " + this.caches); this.caches = response.data; }) } From 9110c581ca7cc4694b98e4c08ef470da05128a2d Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Mon, 25 Mar 2019 19:33:43 +0100 Subject: [PATCH 13/44] uncached .idea/ --- .idea/checkstyle-idea.xml | 16 ---------------- .idea/compiler.xml | 13 ------------- .idea/encodings.xml | 4 ---- .idea/inspectionProfiles/Project_Default.xml | 6 ------ .idea/misc.xml | 9 --------- .idea/modules.xml | 10 ---------- .idea/vcs.xml | 6 ------ 7 files changed, 64 deletions(-) delete mode 100644 .idea/checkstyle-idea.xml delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml deleted file mode 100644 index 3918e38..0000000 --- a/.idea/checkstyle-idea.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 4aac343..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 15a15b2..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 03d9549..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index e62185c..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 9db8a1d..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 2db55ac35d6f87abfbe5c05131c7d765b47a1a13 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 25 Mar 2019 21:47:46 +0100 Subject: [PATCH 14/44] stationen haben nun eine reihenfolge innerhalb eines caches --- .../entities/StationReihenfolge.java | 53 +++++++++++++++++++ .../StationReihenfolgeRepository.java | 7 +++ 2 files changed, 60 insertions(+) create mode 100644 src/main/java/hhn/labsw/bugageocaching/entities/StationReihenfolge.java create mode 100644 src/main/java/hhn/labsw/bugageocaching/repositories/StationReihenfolgeRepository.java diff --git a/src/main/java/hhn/labsw/bugageocaching/entities/StationReihenfolge.java b/src/main/java/hhn/labsw/bugageocaching/entities/StationReihenfolge.java new file mode 100644 index 0000000..b51ef51 --- /dev/null +++ b/src/main/java/hhn/labsw/bugageocaching/entities/StationReihenfolge.java @@ -0,0 +1,53 @@ +package hhn.labsw.bugageocaching.entities; + +import javax.persistence.*; + +@Entity +@Table +public class StationReihenfolge { + + @Id + @GeneratedValue + private int id; + + @OneToOne + private Cache cache; + + @OneToOne + private Station station; + + @OneToOne + private Station nachfolgeStation; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Cache getCache() { + return cache; + } + + public void setCache(Cache cache) { + this.cache = cache; + } + + public Station getStation() { + return station; + } + + public void setStation(Station station) { + this.station = station; + } + + public Station getNachfolgeStation() { + return nachfolgeStation; + } + + public void setNachfolgeStation(Station nachfolgeStation) { + this.nachfolgeStation = nachfolgeStation; + } +} diff --git a/src/main/java/hhn/labsw/bugageocaching/repositories/StationReihenfolgeRepository.java b/src/main/java/hhn/labsw/bugageocaching/repositories/StationReihenfolgeRepository.java new file mode 100644 index 0000000..8897965 --- /dev/null +++ b/src/main/java/hhn/labsw/bugageocaching/repositories/StationReihenfolgeRepository.java @@ -0,0 +1,7 @@ +package hhn.labsw.bugageocaching.repositories; + +import hhn.labsw.bugageocaching.entities.StationReihenfolge; +import org.springframework.data.repository.CrudRepository; + +public interface StationReihenfolgeRepository extends CrudRepository { +} From 8bcaab5bff3279625fcaae68b21d6dc2c035c037 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 25 Mar 2019 21:48:13 +0100 Subject: [PATCH 15/44] =?UTF-8?q?Station=20hat=20nun=20ein=20Feld=20f?= =?UTF-8?q?=C3=BCr=20den=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/hhn/labsw/bugageocaching/entities/Station.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/hhn/labsw/bugageocaching/entities/Station.java b/src/main/java/hhn/labsw/bugageocaching/entities/Station.java index 0acfaa9..bdcf98d 100644 --- a/src/main/java/hhn/labsw/bugageocaching/entities/Station.java +++ b/src/main/java/hhn/labsw/bugageocaching/entities/Station.java @@ -14,6 +14,7 @@ public class Station { private String description; private double longitude; private double lattitude; + private int code; public Station() { } @@ -50,4 +51,11 @@ public class Station { this.lattitude = lattitude; } + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } } From 161d29f248667944f30eb1d90eed9fec008767c0 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 25 Mar 2019 21:49:37 +0100 Subject: [PATCH 16/44] bearbeitet tabelle trackt nun die station, bis zu der ein user innerhalb eines caches gekommen ist --- .../hhn/labsw/bugageocaching/entities/Bearbeitet.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/hhn/labsw/bugageocaching/entities/Bearbeitet.java b/src/main/java/hhn/labsw/bugageocaching/entities/Bearbeitet.java index c2c284d..f046d84 100644 --- a/src/main/java/hhn/labsw/bugageocaching/entities/Bearbeitet.java +++ b/src/main/java/hhn/labsw/bugageocaching/entities/Bearbeitet.java @@ -20,6 +20,9 @@ public class Bearbeitet { @OneToOne private CacheAccesDefinition cacheAccesDefinition; + @OneToOne + private Station aktuelleStation; + public int getId() { return id; } @@ -51,4 +54,12 @@ public class Bearbeitet { public void setCacheAccesDefinition(CacheAccesDefinition cacheAccesDefinition) { this.cacheAccesDefinition = cacheAccesDefinition; } + + public Station getAktuelleStation() { + return aktuelleStation; + } + + public void setAktuelleStation(Station aktuelleStation) { + this.aktuelleStation = aktuelleStation; + } } \ No newline at end of file From d5ca26bbd33b34a5811b83c484e537f06a25e3d0 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 25 Mar 2019 21:51:00 +0100 Subject: [PATCH 17/44] =?UTF-8?q?startCache=20wurde=20aufgrund=20des=20neu?= =?UTF-8?q?en=20Attributs=20station=20in=20der=20bearbeitet-Tabelle=20?= =?UTF-8?q?=C3=BCberarbeitet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../labsw/bugageocaching/controller/Controller.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index b0b29d6..4cdf7fc 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -69,7 +69,8 @@ public class Controller { @RequestMapping("/api/startCache") public @ResponseBody String startCache(@RequestParam(value = "userID", defaultValue = "-1") String userID, - @RequestParam String cacheID) throws IllegalParameterException { + @RequestParam String cacheID, + @RequestParam String stationID) throws IllegalParameterException { if (!userID.equals("-1")) { // ein angemeldeter user startet den cache(es werden zwei parameter übergeben) @@ -91,6 +92,14 @@ public class Controller { throw new IllegalParameterException("There is no cache with the ID " + cacheID); } + Optional stationOptional = stationRepository.findById(Integer.valueOf(stationID)); + if (stationOptional.isPresent()) { + Station station = stationOptional.get(); + bearbeitet.setAktuelleStation(station); + } else { + throw new IllegalParameterException("There is no station with the ID " + stationID); + } + Optional cacheAccesDefinitionOptional = cacheAccesDefinitionRepository.findById(1); // bearbeitet if (cacheAccesDefinitionOptional.isPresent()) { From ab4a642619298a1f23c26113d6719a177c8d47c3 Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Mon, 25 Mar 2019 22:39:41 +0100 Subject: [PATCH 18/44] login implemented and wired --- frontend/src/layouts/MyLayout.vue | 11 +-- frontend/src/pages/Login.vue | 95 ++++++++++++++----- .../bugageocaching/controller/Controller.java | 5 + 3 files changed, 79 insertions(+), 32 deletions(-) diff --git a/frontend/src/layouts/MyLayout.vue b/frontend/src/layouts/MyLayout.vue index 7dbfd97..4faab9f 100644 --- a/frontend/src/layouts/MyLayout.vue +++ b/frontend/src/layouts/MyLayout.vue @@ -24,10 +24,7 @@ v-model="leftDrawerOpen" bordered show-if-above - :mini="miniState" - @mouseover="miniState = false" - @mouseout="miniState = true" - content-class="bg-green-1"> + content-class=""> Essential Links
- - +