-
-
-
-
-
+
@@ -55,10 +57,11 @@
-
+
-
+
+
diff --git a/frontend/src/router/routes.js b/frontend/src/router/routes.js
index 2b285ca..bcecad6 100644
--- a/frontend/src/router/routes.js
+++ b/frontend/src/router/routes.js
@@ -20,25 +20,19 @@ const routes = [
children: [{ path: "", component: () => import("pages/Cache.vue") }]
},
{
- path: "/station?local=:pos",
+ path: "/station/",
component: () => import("layouts/MyLayout.vue"),
children: [{ path: "", component: () => import("pages/StationEdit.vue") }]
},
{
- path: "/station/:id",
+ path: "/station/:cache/:id",
component: () => import("layouts/MyLayout.vue"),
children: [{ path: "", component: () => import("pages/StationView.vue") }]
},
{
- path: "/station/",
+ path: "/station-l/:pos",
component: () => import("layouts/MyLayout.vue"),
- // props: true,
- children: [{
- path: "",
- component: () => import("pages/StationEdit.vue"),
- // props: true
- //props: ['stationObject']
- }]
+ children: [{ path: "", component: () => import("pages/StationEdit.vue") }]
},
{
path: "/login/",
diff --git a/frontend/src/store/auth/getters.js b/frontend/src/store/auth/getters.js
index cc054a3..da66d9b 100644
--- a/frontend/src/store/auth/getters.js
+++ b/frontend/src/store/auth/getters.js
@@ -1,4 +1,24 @@
-/*
-export function someGetter (state) {
+/**
+ * @return {boolean}
+ */
+export function GET_ADMINSTATE(state) {
+ console.log("GET_ADMINSTATE()");
+ if (state.userAuthenticated !== null) {
+ console.log(state.userAuthenticated.roles.find(x => x.name === "admin") != null);
+ return state.userAuthenticated.roles.find(x => x.name === "admin") != null;
+ } else {
+ console.log(state.userAuthenticated);
+ return false;
+ }
}
-*/
+
+// /**
+// * @return {boolean}
+// */
+// export function IS_AUTHENTICATED(state) {
+// console.log("IS_AUTHENTICATED()");
+// console.log(JSON.parse(localStorage.getItem('userToken')));
+// console.log(!(JSON.parse(localStorage.getItem('userToken')) === null));
+// console.log(!(localStorage.getItem('userToken') === null));
+// return !(localStorage.getItem('userToken') === null);
+// }
diff --git a/frontend/src/store/auth/mutations.js b/frontend/src/store/auth/mutations.js
index 3a5c061..fed76c1 100644
--- a/frontend/src/store/auth/mutations.js
+++ b/frontend/src/store/auth/mutations.js
@@ -1,17 +1,43 @@
+import axios from 'axios'
export const SET_AUTHENTICATED = (state) => {
console.log("SET_AUTHENTICATED()");
console.log(JSON.parse(localStorage.getItem('userToken')));
if (localStorage.getItem('userToken')) {
- state.userAuthenticated.isAuthenticated = true;
+ state.isAuthenticated = true;
} else {
- state.userAuthenticated.isAuthenticated = false;
+ state.isAuthenticated = false;
}
};
-export const SET_USER_PROPERTIES = (state, user) => {
- console.log("SET_USER_PROPERTIES()");
- console.log("still todo!");
-};
export const SET_LOGOUT = (state) => {
console.log("SET_LOGOUT()");
+ localStorage.removeItem('userToken');
state.userAuthenticated = null;
+ state.isAuthenticated = false;
+ console.log(localStorage.getItem('userToken'));
};
+export const SET_USER = (state) => {
+ console.log("SET_USER()");
+ if (localStorage.getItem('userToken')) {
+ axios.get('http://localhost:8080/api/getUser', {
+ params: {
+ token: JSON.parse(localStorage.getItem('userToken'))
+ }
+ })
+ .then((response) => {
+ console.log("GET/POST http://localhost:8080/api/getUser - response: ");
+ console.log(response.data);
+ state.userAuthenticated = response.data;
+ state.isAuthenticated = true;
+ if (state.userAuthenticated.hasOwnProperty('password')) delete state.userAuthenticated.password;
+ console.log(state.userAuthenticated);
+ })
+ .catch((error) => {
+ console.log("Catch Block: ")
+ console.log(error)
+ });
+ } else {
+ state.isAuthenticated = false;
+ state.userAuthenticated = null;
+ }
+};
+
diff --git a/frontend/src/store/auth/state.js b/frontend/src/store/auth/state.js
index 1fee418..902a77e 100644
--- a/frontend/src/store/auth/state.js
+++ b/frontend/src/store/auth/state.js
@@ -1,12 +1,19 @@
export default {
- userAuthenticated: {
- id: 1,
- firstname: "t",
- lastname: "v",
- username: "mo",
- email: "test@user.com",
- rankingPointsSum: 345,
- isAuthenticated: false,
- isAdmin: true,
- },
+ isAuthenticated: false,
+ userAuthenticated: null,
+ // userAuthenticated: {
+ // id: 1,
+ // firstname: "Timo",
+ // lastname: "Volkmann",
+ // username: "moximoti",
+ // rankingPointsSum: 0,
+ // email: "test@user.com",
+ // password: "$2a$10$c3Fo5nuUG.nlwXP94qc7qO01/UC1OL2DebEm.5zYlisKJGRhXMnqq",
+ // roles: [
+ // {
+ // id: 0,
+ // name: "admin"
+ // }
+ // ]
+ // },
}
diff --git a/frontend/src/store/cacheCollector/mutations.js b/frontend/src/store/cacheCollector/mutations.js
index ee2cab7..646ab0f 100644
--- a/frontend/src/store/cacheCollector/mutations.js
+++ b/frontend/src/store/cacheCollector/mutations.js
@@ -10,17 +10,20 @@ export const ADD_STATION = (state, station) => {
console.log("ADD_STATION: add new station to cache: "+station);
state.newCache.stationen.push(station);
};
-export const EDIT_STATION = (state, index, station) => {
- console.log("ADD_STATION: add new station to cache: "+station);
+export const EDIT_STATION = (state, indexStation) => {
+ let index, station;
+ index = indexStation.index;
+ station = indexStation.station;
+ console.log("EDIT_STATION: "+index+" "+station);
+
state.newCache.stationen[index] = station;
};
export const REMOVE_STATION = (state, index) => {
- console.log("ADD_STATION: add new station to cache: "+station);
+ console.log("REMOVE_STATION: "+index);
state.newCache.stationen.splice(index,1);
};
export const RESET_NEW_CACHE = (state) => {
state.newCache = {
- id: null,
name: "",
description: "",
rankingPoints: 0,
diff --git a/frontend/src/store/cacheCollector/state.js b/frontend/src/store/cacheCollector/state.js
index 3836b13..7087a3a 100644
--- a/frontend/src/store/cacheCollector/state.js
+++ b/frontend/src/store/cacheCollector/state.js
@@ -1,38 +1,44 @@
export default {
newCache: {
- name: "Blumencache",
- description: "Dieser Cache umfasst 4 Stationen mit Rätseln rund um das Thema Blumen",
- rankingPoints: 100,
- stationen: [
- {
- description: "Ein kleines winterliches Schlaginstrument. Welche Blume ist damit gemeint?",
- longitude: 9.206628,
- lattitude: 49.147734,
- code: 213812,
- solution: "Schneeglöckchen"
- },
- {
- description: "Ein blühendes Federvieh. Welche Blume ist damit gemeint?",
- longitude: 9.206806,
- lattitude: 49.147318,
- code: 237823,
- solution: "Gänseblümchen"
- },
- {
- description: "Eine wertvolle Farbe. Welche Blume ist damit gemeint?",
- longitude: 9.207844,
- lattitude: 49.148032,
- code: 899423,
- solution: "Edelweiß"
- },
- {
- description: "Ein Zerkleinerungsgerät in der Brüllöffnung eines Raubtieres. Welche Blume ist damit gemeint?",
- longitude: 9.207649,
- lattitude: 49.150142,
- code: 347923,
- solution: "Löwenzahn"
- }
- ]
+ name: "",
+ description: "",
+ rankingPoints: 0,
+ stationen: []
},
+ // newCache: {
+ // name: "Blumencache",
+ // description: "Dieser Cache umfasst 4 Stationen mit Rätseln rund um das Thema Blumen",
+ // rankingPoints: 100,
+ // stationen: [
+ // {
+ // description: "Ein kleines winterliches Schlaginstrument. Welche Blume ist damit gemeint?",
+ // longitude: 9.206628,
+ // lattitude: 49.147734,
+ // code: 213812,
+ // solution: "Schneeglöckchen"
+ // },
+ // {
+ // description: "Ein blühendes Federvieh. Welche Blume ist damit gemeint?",
+ // longitude: 9.206806,
+ // lattitude: 49.147318,
+ // code: 237823,
+ // solution: "Gänseblümchen"
+ // },
+ // {
+ // description: "Eine wertvolle Farbe. Welche Blume ist damit gemeint?",
+ // longitude: 9.207844,
+ // lattitude: 49.148032,
+ // code: 899423,
+ // solution: "Edelweiß"
+ // },
+ // {
+ // description: "Ein Zerkleinerungsgerät in der Brüllöffnung eines Raubtieres. Welche Blume ist damit gemeint?",
+ // longitude: 9.207649,
+ // lattitude: 49.150142,
+ // code: 347923,
+ // solution: "Löwenzahn"
+ // }
+ // ]
+ // },
tempStation: {},
}
diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js
index 8eb6c71..0ce2a96 100644
--- a/frontend/src/store/index.js
+++ b/frontend/src/store/index.js
@@ -22,7 +22,8 @@ export default function (/* { ssrContext } */) {
// enable strict mode (adds overhead!)
// for dev mode only
- strict: process.env.DEV
+ //strict: process.env.DEV
+ strict: false
})
/*
diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java
index cf052cc..477d1f1 100644
--- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java
+++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java
@@ -199,7 +199,9 @@ public class Controller {
@RequestMapping("/api/createCache")
@ResponseBody
public ResponseEntity createCache(@RequestBody Cache cache) {
-
+ System.out.println(cache.getName());
+ System.out.println(cache.getStationen().size());
+ System.out.println(cache.getStationen().get(0).getId());
// Stationen werden in die Datenbank eingetragen
for (Station station : cache.getStationen()) {
ResponseEntity response = createStation(station);
@@ -208,7 +210,7 @@ public class Controller {
return response;
}
}
-
+ System.out.println("Stationen eingetragen!");
// Caches werden in die Datenbank eingetragen
if (cache.getDescription().length() == 0 || cache.getName().length() == 0 || cache.getRankingPoints() == 0.0 || cache.getStationen().size() == 0) {
deleteStationen(cache);
@@ -234,7 +236,7 @@ public class Controller {
public ResponseEntity createStation(Station station) {
- if (station.getDescription().length() == 0 || station.getLattitude() == 0.0 || station.getLongitude() == 0.0 || station.getSolution().length() == 0) {
+ if (station.getDescription().length() == 0 || station.getLattitude() == 0.0 || station.getLongitude() == 0.0 /*|| station.getSolution().length() == 0*/) {
return ResponseEntity.status(400).body("station fields can´t be empty");
}