From 565bf98432a39eb8826a5ca39bb6e138473f8ad7 Mon Sep 17 00:00:00 2001 From: Maximilian Leopold Date: Mon, 29 Apr 2019 19:48:32 +0200 Subject: [PATCH 1/4] Added some team methods --- .../bugageocaching/controller/Controller.java | 12 ++ .../repositories/TeamRepository.java | 20 +++ .../labsw/bugageocaching/util/FinderUtil.java | 124 +++++++++++------- 3 files changed, 109 insertions(+), 47 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index 528af69..ec97905 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -808,6 +808,18 @@ public class Controller { return ResponseEntity.status(200).body(new Gson().toJson(teamStatus)); } + @RequestMapping("/api/getTeam") + public ResponseEntity getTeam(@RequestParam String name){ + ResponseEntity responseEntity = FinderUtil.findTeamByName(name); + + return responseEntity; + } + + @RequestMapping("/api/getTeamMembers") + public ResponseEntity getTeamMembers(@RequestParam String name){ + return FinderUtil.findTeammemberByTeamName(name); + } + @RequestMapping("/api/hello") public ResponseEntity hello(@RequestParam String name) { diff --git a/src/main/java/hhn/labsw/bugageocaching/repositories/TeamRepository.java b/src/main/java/hhn/labsw/bugageocaching/repositories/TeamRepository.java index 77c69d9..9390a7c 100644 --- a/src/main/java/hhn/labsw/bugageocaching/repositories/TeamRepository.java +++ b/src/main/java/hhn/labsw/bugageocaching/repositories/TeamRepository.java @@ -1,8 +1,28 @@ package hhn.labsw.bugageocaching.repositories; import hhn.labsw.bugageocaching.entities.Team; +import hhn.labsw.bugageocaching.entities.User; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; +import java.util.List; + public interface TeamRepository extends JpaRepository { + + Team findByName(String name); + + @Query(value = "SELECT *\n" + + "FROM user\n" + + "WHERE id = (\n" + + " SELECT user_id\n" + + " FROM user_info\n" + + " WHERE team_id = (SELECT team_id\n" + + " FROM team\n" + + " WHERE name = ?1\n" + + " )\n" + + ")", nativeQuery = true) + List getTeammembers(String name); + + } diff --git a/src/main/java/hhn/labsw/bugageocaching/util/FinderUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/FinderUtil.java index 98b7b6b..a79d112 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/FinderUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/FinderUtil.java @@ -10,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; +import java.util.LinkedList; +import java.util.List; import java.util.Optional; @Component @@ -33,53 +35,6 @@ public class FinderUtil { static TeamInviteRepository teamInviteRepository; - - @Autowired - public void setCacheRepository(CacheRepository cacheRepository) { - FinderUtil.cacheRepository= cacheRepository; - } - - @Autowired - public void setRewardRepository(RewardRepository rewardRepository) { - FinderUtil.rewardRepository = rewardRepository; - } - - @Autowired - public void setStationRepository(StationRepository stationRepository) { - FinderUtil.stationRepository = stationRepository; - } - - @Autowired - public void setBearbeitetRepository(BearbeitetRepository bearbeitetRepository) { - FinderUtil.bearbeitetRepository = bearbeitetRepository; - } - - @Autowired - public void setCacheAccesDefinitionRepository(CacheAccesDefinitionRepository cacheAccesDefinitionRepository) { - FinderUtil.cacheAccesDefinitionRepository = cacheAccesDefinitionRepository; - } - - @Autowired - public void setTeamRepository(TeamRepository teamRepository) { - FinderUtil.teamRepository = teamRepository; - } - - @Autowired - public void setUserRepository(UserRepository userRepository) { - FinderUtil.userRepository = userRepository; - } - - @Autowired - public void setUser_infoRepository(User_InfoRepository user_infoRepository) { - FinderUtil.user_infoRepository = user_infoRepository; - } - - @Autowired - public void setTeamInviteRepository(TeamInviteRepository teamInviteRepository) { - FinderUtil.teamInviteRepository = teamInviteRepository; - } - - public static ResponseEntity findCacheById(String cacheID) { Optional cacheOptional = cacheRepository.findById(Integer.valueOf(cacheID)); @@ -167,4 +122,79 @@ public class FinderUtil { } } + public static ResponseEntity findTeamByName(String name) { + + Team team = teamRepository.findByName(name); + if (team != null) { + return ResponseEntity.status(200).body(team); + } else { + return ResponseEntity.status(404).body("Couldnt find Team with name " + name); + } } + + public static ResponseEntity findTeammemberByTeamName(String name) { + + List list = teamRepository.getTeammembers(name); + if (list != null) { + + List sendBack = new LinkedList<>(); + + for (Object[] obj : + list) { + User tmp = new User(); + tmp.setUsername((String) obj[3]); + sendBack.add(tmp); + } + + return ResponseEntity.status(200).body(sendBack); + } else { + return ResponseEntity.status(404).body("Couldnt find Team member of Team " + name); + } + } + + @Autowired + public void setCacheRepository(CacheRepository cacheRepository) { + FinderUtil.cacheRepository = cacheRepository; + } + + @Autowired + public void setRewardRepository(RewardRepository rewardRepository) { + FinderUtil.rewardRepository = rewardRepository; + } + + @Autowired + public void setStationRepository(StationRepository stationRepository) { + FinderUtil.stationRepository = stationRepository; + } + + @Autowired + public void setBearbeitetRepository(BearbeitetRepository bearbeitetRepository) { + FinderUtil.bearbeitetRepository = bearbeitetRepository; + } + + @Autowired + public void setCacheAccesDefinitionRepository(CacheAccesDefinitionRepository cacheAccesDefinitionRepository) { + FinderUtil.cacheAccesDefinitionRepository = cacheAccesDefinitionRepository; + } + + @Autowired + public void setTeamRepository(TeamRepository teamRepository) { + FinderUtil.teamRepository = teamRepository; + } + + @Autowired + public void setUserRepository(UserRepository userRepository) { + FinderUtil.userRepository = userRepository; + } + + @Autowired + public void setUser_infoRepository(User_InfoRepository user_infoRepository) { + FinderUtil.user_infoRepository = user_infoRepository; + } + + @Autowired + public void setTeamInviteRepository(TeamInviteRepository teamInviteRepository) { + FinderUtil.teamInviteRepository = teamInviteRepository; + } + +} From 51b9587410df795bd68bbfeac3909b282dc1437f Mon Sep 17 00:00:00 2001 From: rchrist Date: Mon, 29 Apr 2019 19:51:12 +0200 Subject: [PATCH 2/4] 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)); } From 247e7622894f99419a3dd9a6c32bff80f3a5f499 Mon Sep 17 00:00:00 2001 From: rchrist Date: Tue, 30 Apr 2019 14:21:22 +0200 Subject: [PATCH 3/4] design of profl --- frontend/quasar.conf.js | 3 + frontend/src/pages/Profile.vue | 280 +++++++++++------- .../bugageocaching/controller/Controller.java | 2 + 3 files changed, 174 insertions(+), 111 deletions(-) diff --git a/frontend/quasar.conf.js b/frontend/quasar.conf.js index 1ceac6e..48f675b 100644 --- a/frontend/quasar.conf.js +++ b/frontend/quasar.conf.js @@ -69,6 +69,9 @@ module.exports = function (ctx) { 'QSelect', 'QField', 'QBtnDropdown', + 'QPopupEdit', + 'QSlideTransition', + 'QToggle', ], directives: [ diff --git a/frontend/src/pages/Profile.vue b/frontend/src/pages/Profile.vue index 310cb39..dd4ef3e 100644 --- a/frontend/src/pages/Profile.vue +++ b/frontend/src/pages/Profile.vue @@ -12,7 +12,7 @@ switch-indicator > - + @@ -23,62 +23,15 @@ - -
-
- - Mein Nutzername - -
-
- -
-
-
-
-
- - Meine Email - -
-
- -
-
-
-
-
- - Meine Ranglistenposition - -
-
- -
-
-
-
-
- - Mein Team - -
-
- -
-
-
-
-
- - Teamranglistenposition - -
-
- -
-
-
+

Persönliche Daten

+
@@ -110,58 +63,36 @@
-
+

Teammitglieder

+ +
+

Einladungen

+
- - Teammitglieder - -
-
-
- BuGaCacher2019 -
- Max -
- Timo -
- Katharina -
- Michael -
- Robin -
-
-
-
- -
-
- -
-
-
-
- - Aktueller Teamstatus - -
-
-
- Dienstag 15:00 Treffen zum Blumencache. +

+

Teamstatus

+

{{currentTeamStatus}}

+ type="text" label="Neuer Teamstatus" + :rules="[val=>val.length<=160||'Status zu lang!']"/>
-
@@ -236,10 +167,17 @@