diff --git a/frontend/src/pages/Cache.vue b/frontend/src/pages/Cache.vue
new file mode 100644
index 0000000..896ba01
--- /dev/null
+++ b/frontend/src/pages/Cache.vue
@@ -0,0 +1,21 @@
+
+
+
+
Cache erstellen/bearbeiten
+
Cache Name
+
Cache Beschreibung
+
Cache Punkte
+
Stationen
+
+
+
+
+
+
+
diff --git a/frontend/src/pages/CacheView.vue b/frontend/src/pages/CacheView.vue
deleted file mode 100644
index 6257998..0000000
--- a/frontend/src/pages/CacheView.vue
+++ /dev/null
@@ -1,199 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{ col.label }}
-
-
- {{ col.value }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/frontend/src/pages/Login.vue b/frontend/src/pages/Login.vue
index c5d83e3..cb0e8cc 100644
--- a/frontend/src/pages/Login.vue
+++ b/frontend/src/pages/Login.vue
@@ -21,8 +21,8 @@
{
- // this.$router.push('/')
- // })
const data = {
username: this.user.username,
password: this.user.password
- } //JSON.stringify(this.user);
+ };
+
console.log("GET http://localhost:8080/api/login/ - json: " + JSON.stringify(data));
- this.$axios.post('http://localhost:8080/api/login', data) // TODO muss GET mit AUTH Header werden
+
+ this.$axios.post('http://localhost:8080/api/login', data)
.then((response) => {
+ // TODO Catch clause funktioniert nicht mehr wenn Statuscode zurückgegeben wird. -> hier if/else mit HTTP-Codes
console.log("GET/POST http://localhost:8080/api/login/ - response: " + response.data);
- //this.user.token = response.data;
localStorage.setItem('userToken', JSON.stringify(response.data));
- //localStorage.setItem('userToken', response.data);
- this.isAuthenticated();
+ this.evalAuthentication();
})
.catch((error) => {
console.log("error: " + error);
this.credentialsDialog=true;
})
},
- isAuthenticated: function () {
- console.log("isAuthenticated()");
- console.log("content of localstorage: ");
- console.log(JSON.parse(localStorage.getItem('userToken')));
- if (localStorage.getItem('userToken')) {
- this.user.isAuthenticated = true;
- } else {
- this.user.isAuthenticated = false;
- }
+ evalAuthentication: function () {
+ this.$store.commit('auth/SET_AUTHENTICATED');
},
logout: function () {
console.log("logout()");
@@ -129,7 +124,7 @@
.then((response) => {
console.log("GET/POST http://localhost:8080/api/logout/ - response: " + response.data);
localStorage.removeItem('userToken');
- this.isAuthenticated();
+ this.evalAuthentication();
})
.catch((error) => {
});
diff --git a/frontend/src/pages/Overview.vue b/frontend/src/pages/Overview.vue
index f9285c7..d206e53 100644
--- a/frontend/src/pages/Overview.vue
+++ b/frontend/src/pages/Overview.vue
@@ -32,9 +32,7 @@
:label="cache.name"
:caption="cache.rankingPoints+' Punkte / Size '+cache.stationen.length"
>
-
+
@@ -45,8 +43,10 @@
-
-
+
+
+
+
@@ -90,21 +90,11 @@
}
},
mounted: function () {
- //this.header.h = style(this.$refs.layout.$refs.header, 'height')
- // this.hheight = height(document.getElementById('qheader'));
- // this.fheight = height(document.getElementById('qfooter'));
},
computed: {
- // mapHeight() {
- // let header = this.hheight
- // let footer = this.fheight
- // let offset = header + footer + 1;
- // console.log(offset)
- // return {minHeight: offset ? `calc(100vh - ${offset}px)` : '100vh'};
- // },
- // computedMainStyle() {
- // return { height: `calc( 100vh - ${this.header.h} )` };
- // }
+ hasAdminState() {
+ return this.$store.state.auth.userAuthenticated.isAdmin
+ }
},
created: function() {
console.log("created(): " + this.caches);
@@ -129,6 +119,7 @@
this.$axios.get('http://localhost:8080/api/startCache', { params })
.then((response) => {
console.log("Angefangen: " + response.data);
+ this.$router.push({ path: `/station/${cacheID}` })
})
}
}
diff --git a/frontend/src/pages/Station.vue b/frontend/src/pages/StationEdit.vue
similarity index 100%
rename from frontend/src/pages/Station.vue
rename to frontend/src/pages/StationEdit.vue
diff --git a/frontend/src/pages/StationView.vue b/frontend/src/pages/StationView.vue
new file mode 100644
index 0000000..f81a729
--- /dev/null
+++ b/frontend/src/pages/StationView.vue
@@ -0,0 +1,65 @@
+
+
+
+
+
{{ data.cacheName }}
+
Station {{ data.station.position }}
+
{{ data.station.description }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/pages/TestCaches.vue b/frontend/src/pages/TestCaches.vue
deleted file mode 100644
index 59402e7..0000000
--- a/frontend/src/pages/TestCaches.vue
+++ /dev/null
@@ -1,84 +0,0 @@
-
-
-
-
-
-
-
-
- {{ cache.name }}
-
-
-
-
-
-
- {{ cache.description }}
-
-
-
- Cache starten
- Ansehen
-
-
-
-
-
-
-
-
-
diff --git a/frontend/src/router/routes.js b/frontend/src/router/routes.js
index c027592..ce6b632 100644
--- a/frontend/src/router/routes.js
+++ b/frontend/src/router/routes.js
@@ -10,24 +10,19 @@ const routes = [
children: [{ path: "", component: () => import("pages/Overview.vue") }]
},
{
- path: "/testcaches/",
+ path: "/cache/",
component: () => import("layouts/MyLayout.vue"),
- children: [{path: "", component: () => import("pages/TestCaches.vue")}]
- },
- {
- path: "/cacheview/",
- component: () => import("layouts/MyLayout.vue"),
- children: [{ path: "", component: () => import("pages/CacheView.vue") }]
+ children: [{ path: "", component: () => import("pages/Cache.vue") }]
},
{
path: "/station/",
component: () => import("layouts/MyLayout.vue"),
- children: [{ path: "", component: () => import("pages/Station.vue") }]
+ children: [{ path: "", component: () => import("pages/StationEdit.vue") }]
},
{
path: "/station/:id",
component: () => import("layouts/MyLayout.vue"),
- children: [{ path: "", component: () => import("pages/Station.vue") }]
+ children: [{ path: "", component: () => import("pages/StationView.vue") }]
},
{
path: "/login/",
diff --git a/frontend/src/store/auth/mutations.js b/frontend/src/store/auth/mutations.js
index ffa7222..46266c0 100644
--- a/frontend/src/store/auth/mutations.js
+++ b/frontend/src/store/auth/mutations.js
@@ -1,38 +1,18 @@
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;
+export const SET_AUTHENTICATED = (state) => {
+ console.log("SET_AUTHENTICATED()");
+ console.log(JSON.parse(localStorage.getItem('userToken')));
+ if (localStorage.getItem('userToken')) {
+ state.userAuthenticated.isAuthenticated = true;
} else {
- state.user.isAuthenticated = false;
+ state.userAuthenticated.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 SET_USER_PROPERTIES = (state, user) => {
+ console.log("SET_USER_PROPERTIES()");
+ console.log("still todo!");
};
-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;
- })
+export const SET_LOGOUT = (state) => {
+ console.log("SET_LOGOUT()");
+ state.userAuthenticated = null;
};
diff --git a/frontend/src/store/auth/state.js b/frontend/src/store/auth/state.js
index 307952d..0e9581a 100644
--- a/frontend/src/store/auth/state.js
+++ b/frontend/src/store/auth/state.js
@@ -1,7 +1,12 @@
export default {
- user: {
- username: "moximoti",
- password: "1234",
- isAuthenticated: false
+ userAuthenticated: {
+ id: 1,
+ firstname: "t",
+ lastname: "v",
+ username: "mo",
+ email: "test@user.com",
+ rankingPointsSum: 345,
+ isAuthenticated: false,
+ isAdmin: false,
},
}
diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js
index dfbcdb1..8ccfe4c 100644
--- a/frontend/src/store/index.js
+++ b/frontend/src/store/index.js
@@ -45,8 +45,8 @@ export default function (/* { ssrContext } */) {
*/
if (process.env.DEV && module.hot) {
module.hot.accept(['./auth'], () => {
- const newShowcase = require('./auth').default;
- store.hotUpdate({ modules: { showcase: newShowcase } })
+ const auth = require('./auth').default;
+ store.hotUpdate({ modules: { auth: newAuth } })
})
}