From 51b9587410df795bd68bbfeac3909b282dc1437f Mon Sep 17 00:00:00 2001 From: rchrist Date: Mon, 29 Apr 2019 19:51:12 +0200 Subject: [PATCH] started logical implementation of profile and team --- frontend/src/pages/Login.vue | 3 +- frontend/src/pages/Profile.vue | 77 ++++++++++++++++--- .../bugageocaching/controller/Controller.java | 2 + 3 files changed, 69 insertions(+), 13 deletions(-) diff --git a/frontend/src/pages/Login.vue b/frontend/src/pages/Login.vue index 881b3d7..26c6716 100644 --- a/frontend/src/pages/Login.vue +++ b/frontend/src/pages/Login.vue @@ -6,7 +6,7 @@
-
@@ -103,6 +103,7 @@ console.log("TOKEN"); console.log(response.data.token); localStorage.setItem('userToken', JSON.stringify(response.data)); + localStorage.setItem('userMail', JSON.stringify(data.email)); this.evalAuthentication(); }) .catch((error) => { diff --git a/frontend/src/pages/Profile.vue b/frontend/src/pages/Profile.vue index 810a559..310cb39 100644 --- a/frontend/src/pages/Profile.vue +++ b/frontend/src/pages/Profile.vue @@ -30,8 +30,8 @@ Mein Nutzername
-
- BuGaCacher2019 +
+

@@ -42,7 +42,7 @@
- muster.mail@muster.de +

@@ -53,7 +53,7 @@
- 1234 +

@@ -64,7 +64,7 @@
- BuGa19Community +

@@ -75,22 +75,22 @@
- 2019 +

- + - + - BuGa19Community + - + @@ -99,7 +99,7 @@ - + @@ -251,6 +251,12 @@ startedCaches: [], inviteMail: "", teamStatus: "", + userNameContent: null, + emailContent: null, + userRanking: null, + teamName: null, + teamRanking: null, + dropDownSelectedItem: null, } }, mounted: function () { @@ -258,12 +264,18 @@ computed: { hasAdminState() { return this.$store.getters['auth/GET_ADMINSTATE']; - } + }, }, created: function () { this.fetchUserCaches(); this.$store.commit('auth/SET_AUTHENTICATED'); this.$store.commit('auth/SET_USER'); + this.userNameContent = JSON.parse(localStorage.getItem('userToken')).name; + this.emailContent = JSON.parse(localStorage.getItem('userMail')); + this.userRanking = "1234"; + this.teamName = "BuGa19Community"; + this.dropDownSelectedItem = this.teamName; + this.teamRanking = "2019"; }, methods: { fetchUserCaches: function () { @@ -300,6 +312,47 @@ var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(String(email).toLowerCase()); }, + getPersonalRanking() { + const name = JSON.parse(localStorage.getItem('userToken')).name; + JSON.stringify(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() { + + }, + + dropDownSelectItem(item){ + if(item === 'team'){ + this.dropDownSelectedItem = this.teamName; + } else { + this.dropDownSelectedItem = item; + } + }, } } diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index 881f78c..837b7df 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -626,7 +626,9 @@ public class Controller { return ResponseEntity.status(200).body("Ok"); } + @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose @RequestMapping("/api/hello") + @ResponseBody public ResponseEntity hello(@RequestParam String name) { return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(name)); }