From 45515d33e0c9c837f6ef915dd4ebbe1172f7a5ac Mon Sep 17 00:00:00 2001 From: rchrist Date: Thu, 9 May 2019 18:02:53 +0200 Subject: [PATCH] inviteToTeam finished --- frontend/src/pages/Profile.vue | 38 ++++++++++++------- frontend/src/pages/Register.vue | 14 ++++++- .../bugageocaching/controller/Controller.java | 2 +- 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/frontend/src/pages/Profile.vue b/frontend/src/pages/Profile.vue index b6688af..8929eb2 100644 --- a/frontend/src/pages/Profile.vue +++ b/frontend/src/pages/Profile.vue @@ -57,7 +57,8 @@ - Neues Team erstellen + Neues Team erstellen + Neues Team erstellen
(Team verlassen um Option zu nutzen)
@@ -164,6 +165,7 @@ inviteMail: "", currentTeamStatus: "", teamStatus: "", + userName: "", email: null, userRanking: null, teamName: null, @@ -192,6 +194,10 @@ } ], data: [ + { + name: 'Benutzername', + userData: this.userName, + }, { name: 'E-Mail', userData: this.email, @@ -290,8 +296,10 @@ created: function () { this.$store.commit('auth/SET_AUTHENTICATED'); this.$store.commit('auth/SET_USER'); + this.userName = JSON.parse(localStorage.getItem('userToken')).name; + this.data[0].userData = this.userName; this.email = JSON.parse(localStorage.getItem('userMail')); - this.data[0].userData = this.email; + this.data[1].userData = this.email; this.getPersonalRanking(); this.getTeamData(); this.fetchTeamInvites(); @@ -302,11 +310,11 @@ return re.test(String(email).toLowerCase()); }, getPersonalRanking() { - let name = this.email; - this.$axios.get('/api/hello', {params: {name}}) + let email = this.email; + this.$axios.get('/api/getRankingPlace', {params: {email}}) .then((response) => { this.userRanking = response.data; - this.data[1].userData = this.userRanking; + this.data[2].userData = this.userRanking; }).catch((error) => { this.handleError(error); }) @@ -320,11 +328,12 @@ } this.$axios.get('/api/getTeamOfUser', {params: {token}}) .then(response => { - if (response.data.name === '') { + if (response.data === '') { this.boolAlreadyInTeam = false; this.teamName = "Aktuell in keinem Team"; this.currentTeamStatus = ""; this.teamRanking = "-"; + this.dropDownSelectItem('Offene Teameinladungen'); } else { this.boolAlreadyInTeam = true; this.teamName = response.data.name; @@ -332,9 +341,9 @@ //this.teamRanking = response.data.teamRanking; this.fetchTeamMembers(); } - this.data[2].userData = this.teamName; + this.data[3].userData = this.teamName; this.dropDownSelectedItem = this.teamName; - this.data[3].userData = this.teamRanking; + this.data[4].userData = this.teamRanking; console.log("getTeam: " + response); }).catch((error) => { this.handleError(error); @@ -398,8 +407,8 @@ } this.$axios.get('/api/getMyTeamInvites', {params: {token}}) .then((response) => { - console.log(response.data); this.teamInvites = response.data; + console.log(this.teamInvites); }).catch((error) => { this.handleError(error); }) @@ -445,16 +454,20 @@ }) }, sendTeamInvite() { - let params; + let params = {}; if (localStorage.getItem('userToken')) { params.token = JSON.parse(localStorage.getItem('userToken')).token; } else { return; } params.invitedUserEmail = this.inviteMail; - this.$axios.post('/api/sendTeamInvite', {params: {params}}) + this.$axios.post('/api/sendTeamInvite', null, {params}) .then((response) => { - console.log(response.data); + this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { + message: "Du hast " + params.invitedUserEmail + " eingeladen!", + title: "Einladung ins Team", + color: "blue" + }); }).catch((error) => { this.handleError(error); }) @@ -469,7 +482,6 @@ params.teamStatus = this.teamStatus; this.$axios.put('/api/setTeamStatus', null, {params}) .then((response) => { - console.log(response.data); this.getTeamData(); }).catch((error) => { this.handleError(error); diff --git a/frontend/src/pages/Register.vue b/frontend/src/pages/Register.vue index 4a7b581..404948e 100644 --- a/frontend/src/pages/Register.vue +++ b/frontend/src/pages/Register.vue @@ -3,6 +3,14 @@
+
+
+
+ +
+
+
@@ -63,6 +71,7 @@ data() { return { user: { + name: "", email: "", checkemail: "", password: "", @@ -72,7 +81,8 @@ }, computed: { validationSuccesful() { - if (this.validateEmail(this.user.email) + if (this.user.name >= 2 + && this.validateEmail(this.user.email) && this.user.email === this.user.checkemail && this.user.password.length >= 8 && this.user.password === this.user.checkpassword) { @@ -93,7 +103,7 @@ if (this.user.email === this.user.checkemail && this.user.password === this.user.checkpassword) { const data = { - name: this.user.email, + name: this.user.name, password: this.user.password, email: this.user.email, roles: [ diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index f5dbe40..3cd9c39 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -950,7 +950,7 @@ public class Controller { @ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 400, message = "Something went wrong at verification") }) - @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose + @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @RequestMapping(value = "/api/getRankingPlace", method = RequestMethod.GET, produces = "application/json") public ResponseEntity getRankingPlace(@RequestParam String email) { return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(email));