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/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 00b6c98..ab65a8f 100644 --- a/frontend/quasar.conf.js +++ b/frontend/quasar.conf.js @@ -47,6 +47,7 @@ module.exports = function (ctx) { 'QCardActions', 'QCheckbox', 'QSeparator', + 'QImg', 'QTabs', 'QTab', 'QRouteTab', @@ -54,11 +55,13 @@ module.exports = function (ctx) { 'QTabPanel', 'QInput', 'QFab', - 'QFabAction' + 'QFabAction', + 'QDialog' ], directives: [ - 'Ripple' + 'Ripple', + 'ClosePopup' ], // Quasar plugins @@ -93,7 +96,7 @@ module.exports = function (ctx) { devServer: { // https: true, - // port: 8080, + port: 8081, open: true // opens browser window automatically }, diff --git a/frontend/src/layouts/MyLayout.vue b/frontend/src/layouts/MyLayout.vue index 80c2afb..4faab9f 100644 --- a/frontend/src/layouts/MyLayout.vue +++ b/frontend/src/layouts/MyLayout.vue @@ -1,7 +1,7 @@ diff --git a/frontend/src/pages/Index.vue b/frontend/src/pages/Index.vue index 4f72725..5c54dac 100644 --- a/frontend/src/pages/Index.vue +++ b/frontend/src/pages/Index.vue @@ -1,185 +1,54 @@ - - - - diff --git a/frontend/src/pages/Login.vue b/frontend/src/pages/Login.vue index 8b5ee79..a9fa432 100644 --- a/frontend/src/pages/Login.vue +++ b/frontend/src/pages/Login.vue @@ -1,52 +1,129 @@ diff --git a/frontend/src/pages/TestCaches.vue b/frontend/src/pages/TestCaches.vue new file mode 100644 index 0000000..2f06321 --- /dev/null +++ b/frontend/src/pages/TestCaches.vue @@ -0,0 +1,86 @@ + + + + + diff --git a/frontend/src/router/routes.js b/frontend/src/router/routes.js index 2a9eed2..7cb5491 100644 --- a/frontend/src/router/routes.js +++ b/frontend/src/router/routes.js @@ -9,6 +9,11 @@ const routes = [ 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")}] + }, { path: "/cacheview/", component: () => import("layouts/MyLayout.vue"), diff --git a/frontend/src/store/auth/actions.js b/frontend/src/store/auth/actions.js new file mode 100644 index 0000000..4787a5f --- /dev/null +++ b/frontend/src/store/auth/actions.js @@ -0,0 +1,4 @@ +/* +export function someAction (context) { +} +*/ diff --git a/frontend/src/store/auth/getters.js b/frontend/src/store/auth/getters.js new file mode 100644 index 0000000..cc054a3 --- /dev/null +++ b/frontend/src/store/auth/getters.js @@ -0,0 +1,4 @@ +/* +export function someGetter (state) { +} +*/ diff --git a/frontend/src/store/auth/index.js b/frontend/src/store/auth/index.js new file mode 100644 index 0000000..b41a219 --- /dev/null +++ b/frontend/src/store/auth/index.js @@ -0,0 +1,12 @@ +import state from './state' +import * as getters from './getters' +import * as mutations from './mutations' +import * as actions from './actions' + +export default { + namespaced: true, + state, + getters, + mutations, + actions +} diff --git a/frontend/src/store/auth/mutations.js b/frontend/src/store/auth/mutations.js new file mode 100644 index 0000000..ffa7222 --- /dev/null +++ b/frontend/src/store/auth/mutations.js @@ -0,0 +1,38 @@ +import axios from 'axios' +/* +export function someMutation (state) { +} +*/ +export const evalAuth = (state) => { + console.log("isAuthenticated()"); + console.log(localStorage.getItem('userToken')); + if (localStorage.getItem('userToken')) { // TODO hier muss Abfrage mit API, z.B. /api/user?token="ME" stattfinden. + state.user.isAuthenticated = true; + } else { + state.user.isAuthenticated = false; + } +}; +export const logout = (state) => { + console.log("logout()"); + console.log(localStorage.getItem('userToken')); + localStorage.removeItem('userToken'); + console.log(localStorage.getItem('userToken')); + state.commit(evalAuth(state)); +}; +export const login = (state) => { + const data = { + username: state.user.username, + password: state.user.password + }; + console.log("GET http://localhost:8080/api/login/ - json: " + JSON.stringify(data)); + this.state.$axios.post('http://localhost:8080/api/login', data) // TODO muss GET mit AUTH Header werden + .then((response) => { + console.log("GET/POST http://localhost:8080/api/login/ - response: " + response.data); + localStorage.setItem('userToken', JSON.stringify(response)); + state.commit(evalAuth(state)); + }) + .catch((error) => { + console.log("error: " + error); + //errorDialog = true; + }) +}; diff --git a/frontend/src/store/auth/state.js b/frontend/src/store/auth/state.js new file mode 100644 index 0000000..307952d --- /dev/null +++ b/frontend/src/store/auth/state.js @@ -0,0 +1,7 @@ +export default { + user: { + username: "moximoti", + password: "1234", + isAuthenticated: false + }, +} diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index ca79aab..dfbcdb1 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -1,25 +1,54 @@ import Vue from "vue"; import Vuex from "vuex"; +import Axios from "axios"; +import auth from "./auth" // 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 } */) { +// 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 function (/* { ssrContext } */) { const Store = new Vuex.Store({ modules: { - // example + auth }, // enable strict mode (adds overhead!) // for dev mode only strict: process.env.DEV - }); + }) - return Store; -} + /* + if we want some HMR magic for it, we handle + the hot update like below. Notice we guard this + code with "process.env.DEV" -- so this doesn't + get into our production build (and it shouldn't). + */ + if (process.env.DEV && module.hot) { + module.hot.accept(['./auth'], () => { + const newShowcase = require('./auth').default; + store.hotUpdate({ modules: { showcase: newShowcase } }) + }) + } + + return Store +}; diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index 4cdf7fc..b96905d 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -40,16 +40,20 @@ public class Controller { private AtomicLong counter = new AtomicLong(); + @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose @RequestMapping("/api/allCaches") @ResponseBody public String getAllCaches() { return new Gson().toJson(cacheRepository.findAll()); } + @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose @RequestMapping("/api/login") @ResponseBody public ResponseEntity login(@RequestBody User user){ if(user.getUsername() == null || user.getPassword() == null){ + System.out.println(user.getUsername()); + System.out.println(user.getPassword()); return ResponseEntity.status(401).body(null); } if(userRepository.findByUsername(user.getUsername()) == null){ @@ -66,6 +70,7 @@ public class Controller { return ResponseEntity.status(HttpStatus.BAD_GATEWAY).body(null); } + @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose @RequestMapping("/api/startCache") public @ResponseBody String startCache(@RequestParam(value = "userID", defaultValue = "-1") String userID, diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 3fd5f91..e29f753 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -2,4 +2,5 @@ spring.datasource.url=jdbc:mariadb://seserver.se.hs-heilbronn.de:3406/buga19Geoc spring.datasource.username=BuGa19GeocachingUser spring.datasource.password=GeocachingPw spring.datasource.driver-class-name=org.mariadb.jdbc.Driver -spring.jpa.hibernate.ddl-auto=update \ No newline at end of file +spring.jpa.hibernate.ddl-auto=update +spring.jpa.show-sql=true \ No newline at end of file