From 405c1e6bb72f7e24213c2e54a7659d6afb9d1842 Mon Sep 17 00:00:00 2001 From: rchrist Date: Mon, 13 May 2019 12:42:03 +0200 Subject: [PATCH 01/18] changes to team view --- frontend/src/pages/Profile.vue | 158 +++++++++++++++------------------ 1 file changed, 71 insertions(+), 87 deletions(-) diff --git a/frontend/src/pages/Profile.vue b/frontend/src/pages/Profile.vue index c711f26..7de88cd 100644 --- a/frontend/src/pages/Profile.vue +++ b/frontend/src/pages/Profile.vue @@ -66,87 +66,78 @@ -
-

Teammitglieder

- -
-

Einladungen

- -
- -
-
-

Teamstatus

-

{{currentTeamStatus}}

- -
- -
-
- -
- -
+

Teamstatus

+

{{currentTeamStatus}}

+ +
+
-
- - - - - - - - - - +
+

Teammitglieder

+ +
+

Einladungen

+ +
+
-
- - +
+
+
+ + + + + + + + + + + + @@ -238,16 +229,9 @@ field: row => row.name, format: val => `${val}`, }, - { - name: 'email', - label: 'Email', - required: true, - align: 'left', - field: 'email', - }, { name: 'ranking', - label: 'Rangliste (Solo)', + label: 'Rang', required: true, align: 'left', field: 'ranking', @@ -289,7 +273,7 @@ return false; }, leaveConfirmed() { - if (this.leaveTeamCheck === 'BESTÄTIGEN'){ + if (this.leaveTeamCheck === 'BESTÄTIGEN') { return true; } return false; From c1dcba7c0499c0d08a1784ac2a0d18c0f072a989 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 13 May 2019 15:34:34 +0200 Subject: [PATCH 02/18] first implementation of editCache --- .../bugageocaching/controller/Controller.java | 48 +++++----- .../util/CacheConstructionUtil.java | 92 +++++++++++++++++++ 2 files changed, 118 insertions(+), 22 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index 2385965..72027ea 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -6,6 +6,7 @@ import hhn.labsw.bugageocaching.helper.POI; import hhn.labsw.bugageocaching.helper.RankingListHelper; import hhn.labsw.bugageocaching.helper.TeamRankingListHelper; import hhn.labsw.bugageocaching.repositories.*; +import hhn.labsw.bugageocaching.util.CacheConstructionUtil; import hhn.labsw.bugageocaching.util.FinderUtil; import hhn.labsw.bugageocaching.util.VerificationUtil; import io.jsonwebtoken.Claims; @@ -24,6 +25,7 @@ import java.util.List; import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.createCacheUtil; import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.deleteCacheUtil; +import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.editCacheUtil; import static hhn.labsw.bugageocaching.util.VerificationUtil.fetchPublicKey; @RestController @@ -57,7 +59,7 @@ public class Controller { TeamInviteRepository teamInviteRepository; @PostConstruct - public void init(){ + public void init() { fetchPublicKey(); } @@ -333,28 +335,30 @@ public class Controller { @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @RequestMapping(value = "/api/editCache", method = RequestMethod.PUT, produces = "application/json") @ResponseBody - public ResponseEntity editCache(@RequestBody Cache newCache){ + public ResponseEntity editCache(@RequestBody Cache newCache) { - //---------------------- - //Get Cache - ResponseEntity getCache = FinderUtil.findCacheById(newCache.getId() + ""); +// //---------------------- +// //Get Cache +// ResponseEntity getCache = FinderUtil.findCacheById(newCache.getId() + ""); +// +// if (getCache.getStatusCodeValue() != 200) { +// return getCache; +// } +// +// Cache oldCache = (Cache) getCache.getBody(); +// //---------------------- +// +// oldCache.setDescription(newCache.getDescription()); +// oldCache.setName(newCache.getName()); +// oldCache.setRankingPoints(newCache.getRankingPoints()); +// oldCache.setReward(newCache.getReward()); +// oldCache.setStationen(newCache.getStationen()); +// +// cacheRepository.save(oldCache); +// +// return ResponseEntity.status(200).body("Cache edited"); - if (getCache.getStatusCodeValue() != 200) { - return getCache; - } - - Cache oldCache = (Cache) getCache.getBody(); - //---------------------- - - oldCache.setDescription(newCache.getDescription()); - oldCache.setName(newCache.getName()); - oldCache.setRankingPoints(newCache.getRankingPoints()); - oldCache.setReward(newCache.getReward()); - oldCache.setStationen(newCache.getStationen()); - - cacheRepository.save(oldCache); - - return ResponseEntity.status(200).body("Cache edited"); + return editCacheUtil(newCache); } @ApiOperation(value = "Checks if the given User has an admin role") @@ -823,7 +827,7 @@ public class Controller { List teamInvitesList = teamInviteRepository.findByUser(user); - for (TeamInvite tmp : teamInvitesList){ + for (TeamInvite tmp : teamInvitesList) { tmp.setUser(null); } diff --git a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java index 5deb9c5..959c2f5 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java @@ -13,6 +13,7 @@ import org.springframework.stereotype.Component; import javax.persistence.RollbackException; import java.util.ArrayList; +import java.util.List; import java.util.Optional; import java.util.Random; @@ -120,6 +121,87 @@ public class CacheConstructionUtil { return ResponseEntity.status(200).body(new Gson().toJson(station)); } + public static ResponseEntity editCacheUtil(Cache cache) { + Optional oldCacheOptional = cacheRepository.findById(cache.getId()); + Cache oldCache; + if (oldCacheOptional.isPresent()) { + oldCache = oldCacheOptional.get(); + } else { + return ResponseEntity.status(404).body("There isnt a cache with the id " + cache.getId()); + } + + ResponseEntity response; + List newCreatedStationList = new ArrayList(); + for (Station station : cache.getStationen()) { + // wenn Station schon vorher vorhanden war, wird nur nach validen Daten geprüft + if (oldCache.getStationen().contains(station)) { + response = checkStationUtil(station); + } + // wenn Station neu hinzugefügt wurde, wird die Station zusätzlich in die Datenbank gespeichert + else { + response = createStationUtil(station); + if (response.getStatusCodeValue() == 200) { + newCreatedStationList.add(station); + } + } + if (response.getStatusCodeValue() == 400) { + // neu erzeugte Stationen werden gelöscht, falls es einen Fehler gibt + deleteNewCreatedStationsUtil(newCreatedStationList); + return response; + } + } + + for (Station station : oldCache.getStationen()) { + // wenn Station entfernt wurde, wird diese auch aus der Datenbank gelöscht + if (!cache.getStationen().contains(station)) { + stationRepository.delete(station); + } + } + + // überprüft den Cache nach validen Daten + if (cache.getDescription().length() == 0 || cache.getName().length() == 0 || cache.getRankingPoints() == 0.0) { + deleteNewCreatedStationsUtil(newCreatedStationList); + return ResponseEntity.status(400).body("cache fields can´t be empty"); + } + + if (cache.getStationen().size() < 2) { + deleteNewCreatedStationsUtil(newCreatedStationList); + return ResponseEntity.status(400).body("a cache needs atleast 2 stations"); + } + + for (Cache cache1 : cacheRepository.findAll()) { + if (cache1.getName().equals(cache.getName())) { + deleteNewCreatedStationsUtil(newCreatedStationList); + return ResponseEntity.status(400).body("name is already taken"); + } + } + + if (cache.getRankingPoints() < 0) { + deleteNewCreatedStationsUtil(newCreatedStationList); + return ResponseEntity.status(400).body("Ranking points has to be a positive number"); + } + + cacheRepository.save(cache); + + return ResponseEntity.status(200).body(new Gson().toJson(cache)); + } + + public static ResponseEntity checkStationUtil(Station station) { + 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"); + } + + if (station.getLattitude() < 9 || station.getLattitude() > 10) { + return ResponseEntity.status(400).body("Lattitude has to be between 9 and 10 degrees"); + } + + if (station.getLongitude() < 49 || station.getLongitude() > 50) { + return ResponseEntity.status(400).body("Longitude has to be in the range of 49 to 50 degrees"); + } + + return ResponseEntity.status(200).body(new Gson().toJson(station)); + } + public static void deleteStationenUtil(Cache cache) { for (Station station : cache.getStationen()) { try { @@ -130,6 +212,16 @@ public class CacheConstructionUtil { } } + public static void deleteNewCreatedStationsUtil(List newCreatedStationList) { + for (Station station : newCreatedStationList) { + try { + stationRepository.delete(station); + } catch (IllegalArgumentException e) { // station is null + // do nothing + } + } + } + public static ResponseEntity deleteCacheUtil(String cacheID) { Optional optionalCache = cacheRepository.findById(Integer.valueOf(cacheID)); if (!optionalCache.isPresent()) { From 30cb1d15796d57964b801e9e160c1bd97dad8352 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 13 May 2019 15:41:13 +0200 Subject: [PATCH 03/18] a fix in editCache --- .../labsw/bugageocaching/util/CacheConstructionUtil.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java index 959c2f5..7dc78ac 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java @@ -171,8 +171,10 @@ public class CacheConstructionUtil { for (Cache cache1 : cacheRepository.findAll()) { if (cache1.getName().equals(cache.getName())) { - deleteNewCreatedStationsUtil(newCreatedStationList); - return ResponseEntity.status(400).body("name is already taken"); + if (cache1 != oldCache) { + deleteNewCreatedStationsUtil(newCreatedStationList); + return ResponseEntity.status(400).body("name is already taken"); + } } } From 074a18a831190fb55c46856769235336eacce0b7 Mon Sep 17 00:00:00 2001 From: Maximilian Leopold Date: Tue, 14 May 2019 09:09:59 +0200 Subject: [PATCH 04/18] More Logger --- .../bugageocaching/controller/Controller.java | 25 +++++++++++++++---- .../bugageocaching/util/VerificationUtil.java | 14 +++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index 6098d36..93182f4 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -68,6 +68,7 @@ public class Controller { @RequestMapping(value = "/api/allCaches", method = RequestMethod.GET, produces = "application/json") @ResponseBody public ResponseEntity getAllCaches() { + logger.warn("API CALL: /api/allCaches"); return ResponseEntity.status(200).body(new Gson().toJson(cacheRepository.findAll())); } @@ -405,6 +406,7 @@ public class Controller { @RequestMapping(value = "/api/getAllStations", method = RequestMethod.GET, produces = "application/json") @ResponseBody public ResponseEntity getAllStations() { + logger.warn("API CALL: /api/getAllStations"); return ResponseEntity.status(200).body(new Gson().toJson(stationRepository.findAll())); } @@ -416,6 +418,7 @@ public class Controller { @RequestMapping(value = "/api/deleteCache", method = {RequestMethod.DELETE, RequestMethod.GET}, produces = "application/json") @ResponseBody public ResponseEntity deleteCache(@RequestParam String cacheID) { + logger.warn("API CALL: /api/deleteCache"); return deleteCacheUtil(cacheID); } @@ -430,6 +433,7 @@ public class Controller { @ResponseBody public ResponseEntity getMyCaches(@RequestParam String token) { + logger.warn("API CALL: /api/getMyCaches"); ResponseEntity verifyToken = VerificationUtil.verifyToken(token); @@ -439,6 +443,8 @@ public class Controller { Claims claims = (Claims) verifyToken.getBody(); + logger.debug("/api/getMyCaches Token verified"); + ResponseEntity getUser = FinderUtil.findUserFromClaim(claims); if (getUser.getStatusCodeValue() != 200) { @@ -447,14 +453,18 @@ public class Controller { User user = (User) getUser.getBody(); - if (user != null) { - ArrayList bearbeitetList = new ArrayList<>(); + logger.debug("/api/getMyCaches Got User: " + user.getEmail()); - for (Bearbeitet bearbeitet : bearbeitetRepository.findAll()) { + if (user != null) { + //ArrayList bearbeitetList = new ArrayList<>(); + + /*for (Bearbeitet bearbeitet : bearbeitetRepository.findAll()) { if (bearbeitet.getUser().getId() == user.getId()) { bearbeitetList.add(bearbeitet); } - } + }*/ + List bearbeitetList = bearbeitetRepository.findByUser(user); + logger.debug("/api/getMyCaches Got all bearbeitet entreis of user: " +user.getEmail()); return ResponseEntity.status(200).body(new Gson().toJson(bearbeitetList)); } else { return ResponseEntity.status(404).body("User was not found in the database"); @@ -470,13 +480,18 @@ public class Controller { @ResponseBody public ResponseEntity getRankingList() { + logger.warn("API CALL: /api/getRankingList"); + List sendBackUsers = new LinkedList<>(); + + logger.debug("/api/getRankingList create sendBackUsers"); List rankingUsers = userRepository.getRankingList(); + logger.debug("/api/getRankingList got Object[] from DB"); for (Object[] obj : rankingUsers) { RankingListHelper tmp = new RankingListHelper((String) obj[1], (Integer) obj[2]); - System.out.println(tmp); sendBackUsers.add(tmp); } + logger.debug("/api/getRankingList Converted Objects to RankingListHelper"); return ResponseEntity.status(200).body(new Gson().toJson(sendBackUsers)); } diff --git a/src/main/java/hhn/labsw/bugageocaching/util/VerificationUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/VerificationUtil.java index 1ad5b5f..fb047af 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/VerificationUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/VerificationUtil.java @@ -1,5 +1,6 @@ package hhn.labsw.bugageocaching.util; +import hhn.labsw.bugageocaching.controller.Controller; import hhn.labsw.bugageocaching.fetchObjects.PublicKey; import io.jsonwebtoken.Claims; import io.jsonwebtoken.ExpiredJwtException; @@ -16,16 +17,23 @@ public class VerificationUtil { public static Key publicKey; + private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(VerificationUtil.class); + public static void fetchPublicKey(){ RestTemplate restTemplate = new RestTemplate(); try { + logger.warn("POST CONSCTRUCT: FETCH PUBLIC KEY"); PublicKey response = restTemplate.getForObject("http://seserver.se.hs-heilbronn.de:9080/buga19usermanagement/token/publickey", PublicKey.class); + logger.debug("FETCH PUBLIC KEY: Got response from http://seserver.se.hs-heilbronn.de:9080/buga19usermanagement/token/publickey"); + byte[] decodedKey = Base64.getDecoder().decode(response.getMessage()); KeyFactory factory = KeyFactory.getInstance("RSA"); X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(decodedKey); Key key = factory.generatePublic(publicKeySpec); publicKey = key; + + logger.debug("FETCH PUBLIC KEY: Decoded Key: " + publicKey.toString()); } catch (Exception e) { e.printStackTrace(); } @@ -36,14 +44,20 @@ public class VerificationUtil { public static ResponseEntity verifyToken(String token){ try{ + + logger.warn("VERIFY TOKEN: token: " + token); Claims claims = Jwts.parser() //Parse JWT .setSigningKey(VerificationUtil.publicKey) .parseClaimsJws(token).getBody(); + logger.debug("VERIFY TOKEN: Got Claims: " + claims); + return ResponseEntity.status(200).body(claims); } catch (ExpiredJwtException e){ + logger.debug("VERIFY TOKEN: JWT Token expired"); return ResponseEntity.status(401).body("JWT Token expired"); } catch (Exception e){ + logger.debug("VERIFY TOKEN: Something went wrong verificating"); return ResponseEntity.status(400).body("Something went wrong"); } } From 0d2ac9af37fc4ec611a6dc3c9c4162a0aa7af09a Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 14 May 2019 09:53:48 +0200 Subject: [PATCH 05/18] refactored code --- .../util/CacheConstructionUtil.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java index 7dc78ac..0f618b6 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java @@ -86,12 +86,12 @@ public class CacheConstructionUtil { return ResponseEntity.status(400).body("station fields can´t be empty"); } - if (station.getLattitude() < 9 || station.getLattitude() > 10) { + if (station.getLongitude() < 9 || station.getLongitude() > 10) { return ResponseEntity.status(400).body("Lattitude has to be between 9 and 10 degrees"); } - if (station.getLongitude() < 49 || station.getLongitude() > 50) { - return ResponseEntity.status(400).body("Longitude has to be in the range of 49 to 50 degrees"); + if (station.getLattitude() < 49 || station.getLattitude() > 50) { + return ResponseEntity.status(400).body("Lattitude has to be in the range of 49 to 50 degrees"); } Random r = new Random(); @@ -151,13 +151,6 @@ public class CacheConstructionUtil { } } - for (Station station : oldCache.getStationen()) { - // wenn Station entfernt wurde, wird diese auch aus der Datenbank gelöscht - if (!cache.getStationen().contains(station)) { - stationRepository.delete(station); - } - } - // überprüft den Cache nach validen Daten if (cache.getDescription().length() == 0 || cache.getName().length() == 0 || cache.getRankingPoints() == 0.0) { deleteNewCreatedStationsUtil(newCreatedStationList); @@ -185,6 +178,13 @@ public class CacheConstructionUtil { cacheRepository.save(cache); + for (Station station : oldCache.getStationen()) { + // wenn Station entfernt wurde, wird diese auch aus der Datenbank gelöscht + if (!cache.getStationen().contains(station)) { + stationRepository.delete(station); + } + } + return ResponseEntity.status(200).body(new Gson().toJson(cache)); } From ea7a02e9f6c48673aa37253e7c2674a55ad77f8c Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 14 May 2019 11:11:31 +0200 Subject: [PATCH 06/18] changes to editCache --- .../util/CacheConstructionUtil.java | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java index 0f618b6..198c429 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java @@ -8,6 +8,7 @@ import hhn.labsw.bugageocaching.repositories.BearbeitetRepository; import hhn.labsw.bugageocaching.repositories.CacheRepository; import hhn.labsw.bugageocaching.repositories.StationRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; @@ -86,12 +87,12 @@ public class CacheConstructionUtil { return ResponseEntity.status(400).body("station fields can´t be empty"); } - if (station.getLongitude() < 9 || station.getLongitude() > 10) { + if (station.getLattitude() < 9 || station.getLattitude() > 10) { return ResponseEntity.status(400).body("Lattitude has to be between 9 and 10 degrees"); } - if (station.getLattitude() < 49 || station.getLattitude() > 50) { - return ResponseEntity.status(400).body("Lattitude has to be in the range of 49 to 50 degrees"); + if (station.getLongitude() < 49 || station.getLongitude() > 50) { + return ResponseEntity.status(400).body("Longitude has to be in the range of 49 to 50 degrees"); } Random r = new Random(); @@ -124,21 +125,28 @@ public class CacheConstructionUtil { public static ResponseEntity editCacheUtil(Cache cache) { Optional oldCacheOptional = cacheRepository.findById(cache.getId()); Cache oldCache; + List oldStationen; if (oldCacheOptional.isPresent()) { oldCache = oldCacheOptional.get(); + oldStationen = new ArrayList<>(oldCache.getStationen()); } else { return ResponseEntity.status(404).body("There isnt a cache with the id " + cache.getId()); } - ResponseEntity response; + ResponseEntity response = new ResponseEntity(HttpStatus.ACCEPTED); List newCreatedStationList = new ArrayList(); for (Station station : cache.getStationen()) { + boolean stationIsNew = true; // wenn Station schon vorher vorhanden war, wird nur nach validen Daten geprüft - if (oldCache.getStationen().contains(station)) { - response = checkStationUtil(station); + for (Station oldStation : oldCache.getStationen()) { + if (oldStation.getId() == station.getId()) { + response = createStationUtil(station); + stationIsNew = false; + break; + } } // wenn Station neu hinzugefügt wurde, wird die Station zusätzlich in die Datenbank gespeichert - else { + if (stationIsNew) { response = createStationUtil(station); if (response.getStatusCodeValue() == 200) { newCreatedStationList.add(station); @@ -146,6 +154,10 @@ public class CacheConstructionUtil { } if (response.getStatusCodeValue() == 400) { // neu erzeugte Stationen werden gelöscht, falls es einen Fehler gibt + // alle veränderten Stationen werden resettet + for (Station oldStation : oldStationen) { + stationRepository.save(oldStation); + } deleteNewCreatedStationsUtil(newCreatedStationList); return response; } @@ -164,7 +176,7 @@ public class CacheConstructionUtil { for (Cache cache1 : cacheRepository.findAll()) { if (cache1.getName().equals(cache.getName())) { - if (cache1 != oldCache) { + if (cache1.getId() != oldCache.getId()) { deleteNewCreatedStationsUtil(newCreatedStationList); return ResponseEntity.status(400).body("name is already taken"); } @@ -178,12 +190,13 @@ public class CacheConstructionUtil { cacheRepository.save(cache); - for (Station station : oldCache.getStationen()) { - // wenn Station entfernt wurde, wird diese auch aus der Datenbank gelöscht - if (!cache.getStationen().contains(station)) { - stationRepository.delete(station); - } - } +// nicht gebrauchte Stationen müssen noch gelöscht werden +// for (Station oldStation : oldCache.getStationen()) { +// // wenn Station entfernt wurde, wird diese auch aus der Datenbank gelöscht +// if (!cache.getStationen().contains(station)) { +// stationRepository.delete(station); +// } +// } return ResponseEntity.status(200).body(new Gson().toJson(cache)); } From 159f8e67a5e97c7749f0ab515b13e216ce526716 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 14 May 2019 11:12:47 +0200 Subject: [PATCH 07/18] more changes --- .../util/CacheConstructionUtil.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java index 198c429..8534159 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java @@ -137,14 +137,15 @@ public class CacheConstructionUtil { List newCreatedStationList = new ArrayList(); for (Station station : cache.getStationen()) { boolean stationIsNew = true; - // wenn Station schon vorher vorhanden war, wird nur nach validen Daten geprüft for (Station oldStation : oldCache.getStationen()) { + // wenn Station schon vorher vorhanden war, wird diese mit den neuen Daten geupdatet if (oldStation.getId() == station.getId()) { response = createStationUtil(station); stationIsNew = false; break; } } + // wenn Station neu hinzugefügt wurde, wird die Station zusätzlich in die Datenbank gespeichert if (stationIsNew) { response = createStationUtil(station); @@ -201,21 +202,21 @@ public class CacheConstructionUtil { return ResponseEntity.status(200).body(new Gson().toJson(cache)); } - public static ResponseEntity checkStationUtil(Station station) { - 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"); - } - - if (station.getLattitude() < 9 || station.getLattitude() > 10) { - return ResponseEntity.status(400).body("Lattitude has to be between 9 and 10 degrees"); - } - - if (station.getLongitude() < 49 || station.getLongitude() > 50) { - return ResponseEntity.status(400).body("Longitude has to be in the range of 49 to 50 degrees"); - } - - return ResponseEntity.status(200).body(new Gson().toJson(station)); - } +// public static ResponseEntity checkStationUtil(Station station) { +// 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"); +// } +// +// if (station.getLattitude() < 9 || station.getLattitude() > 10) { +// return ResponseEntity.status(400).body("Lattitude has to be between 9 and 10 degrees"); +// } +// +// if (station.getLongitude() < 49 || station.getLongitude() > 50) { +// return ResponseEntity.status(400).body("Longitude has to be in the range of 49 to 50 degrees"); +// } +// +// return ResponseEntity.status(200).body(new Gson().toJson(station)); +// } public static void deleteStationenUtil(Cache cache) { for (Station station : cache.getStationen()) { From 7be8b265bd2a506a99a1fab82c5e43e9b32661a5 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 14 May 2019 11:30:15 +0200 Subject: [PATCH 08/18] more changes --- .../bugageocaching/util/CacheConstructionUtil.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java index 8534159..f488eb6 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java @@ -125,10 +125,10 @@ public class CacheConstructionUtil { public static ResponseEntity editCacheUtil(Cache cache) { Optional oldCacheOptional = cacheRepository.findById(cache.getId()); Cache oldCache; - List oldStationen; +// List oldStationen; if (oldCacheOptional.isPresent()) { oldCache = oldCacheOptional.get(); - oldStationen = new ArrayList<>(oldCache.getStationen()); +// oldStationen = new ArrayList<>(oldCache.getStationen()); } else { return ResponseEntity.status(404).body("There isnt a cache with the id " + cache.getId()); } @@ -153,12 +153,13 @@ public class CacheConstructionUtil { newCreatedStationList.add(station); } } + if (response.getStatusCodeValue() == 400) { // neu erzeugte Stationen werden gelöscht, falls es einen Fehler gibt // alle veränderten Stationen werden resettet - for (Station oldStation : oldStationen) { - stationRepository.save(oldStation); - } +// for (Station oldStation : oldStationen) { +// stationRepository.save(oldStation); +// } deleteNewCreatedStationsUtil(newCreatedStationList); return response; } @@ -191,7 +192,7 @@ public class CacheConstructionUtil { cacheRepository.save(cache); -// nicht gebrauchte Stationen müssen noch gelöscht werden +// nicht gebrauchte Stationen müssen noch aus der DB gelöscht werden // for (Station oldStation : oldCache.getStationen()) { // // wenn Station entfernt wurde, wird diese auch aus der Datenbank gelöscht // if (!cache.getStationen().contains(station)) { From 9d56f2720a045e207112625fdd5d9996f649f030 Mon Sep 17 00:00:00 2001 From: Maximilian Leopold Date: Tue, 14 May 2019 12:05:19 +0200 Subject: [PATCH 09/18] Fehlermeldungen CacheConstruction --- .../bugageocaching/controller/Controller.java | 2 ++ .../util/CacheConstructionUtil.java | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index 93182f4..46c8f63 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -1,6 +1,7 @@ package hhn.labsw.bugageocaching.controller; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import hhn.labsw.bugageocaching.entities.*; import hhn.labsw.bugageocaching.helper.POI; import hhn.labsw.bugageocaching.helper.RankingListHelper; @@ -492,6 +493,7 @@ public class Controller { sendBackUsers.add(tmp); } logger.debug("/api/getRankingList Converted Objects to RankingListHelper"); + logger.debug("/api/getRankingList RankingList: " + new GsonBuilder().setPrettyPrinting().create().toJson(sendBackUsers)); return ResponseEntity.status(200).body(new Gson().toJson(sendBackUsers)); } diff --git a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java index 5deb9c5..b7cdfe1 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java @@ -54,24 +54,24 @@ public class CacheConstructionUtil { // Caches werden in die Datenbank eingetragen if (cache.getDescription().length() == 0 || cache.getName().length() == 0 || cache.getRankingPoints() == 0.0) { deleteStationenUtil(cache); - return ResponseEntity.status(400).body("cache fields can´t be empty"); + return ResponseEntity.status(400).body("Alle Felder müssen ausgefüllt werden!"); } if (cache.getStationen().size() < 2) { deleteStationenUtil(cache); - return ResponseEntity.status(400).body("a cache needs atleast 2 stations"); + return ResponseEntity.status(400).body("Ein Cache muss mindestens zwei Stationen besitzen.\nBitte füge noch eine Station hinzu!"); } for (Cache cache1 : cacheRepository.findAll()) { if (cache1.getName().equals(cache.getName())) { deleteStationenUtil(cache); - return ResponseEntity.status(400).body("name is already taken"); + return ResponseEntity.status(400).body("Der Cachename ist bereits vergeben. Bitte wähle einen anderen Name!"); } } if (cache.getRankingPoints() < 0) { deleteStationenUtil(cache); - return ResponseEntity.status(400).body("Ranking points has to be a positive number"); + return ResponseEntity.status(400).body("Die Punkte für den Cache dürfen nicht negativ sein!"); } cacheRepository.save(cache); @@ -82,15 +82,15 @@ public class CacheConstructionUtil { public static ResponseEntity createStationUtil(Station station) { 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"); + return ResponseEntity.status(400).body("Alle Felder müssen ausgefüllt werden!"); } if (station.getLattitude() < 9 || station.getLattitude() > 10) { - return ResponseEntity.status(400).body("Lattitude has to be between 9 and 10 degrees"); + return ResponseEntity.status(400).body("Die Lattitude ist außerhalb der Bundesgartenschau"); } if (station.getLongitude() < 49 || station.getLongitude() > 50) { - return ResponseEntity.status(400).body("Longitude has to be in the range of 49 to 50 degrees"); + return ResponseEntity.status(400).body("Die Longitude ist außerhalb der Bundesgartenschau"); } Random r = new Random(); @@ -112,7 +112,7 @@ public class CacheConstructionUtil { try { station.setCode(code); } catch (RollbackException e) { - return ResponseEntity.status(400).body("There was an error generating the unique code"); + return ResponseEntity.status(400).body("Es gab einen Fehler beim Konsturieren der QR Codes"); } stationRepository.save(station); @@ -133,7 +133,7 @@ public class CacheConstructionUtil { public static ResponseEntity deleteCacheUtil(String cacheID) { Optional optionalCache = cacheRepository.findById(Integer.valueOf(cacheID)); if (!optionalCache.isPresent()) { - return ResponseEntity.status(404).body(new Gson().toJson("There is no cache with the ID " + cacheID)); + return ResponseEntity.status(404).body(new Gson().toJson("Es gab einen Fehler beim Löschen des Caches")); } Cache cache = optionalCache.get(); From 1960fc4356d0db289194b5e8c0441e198297d75f Mon Sep 17 00:00:00 2001 From: Maximilian Leopold Date: Tue, 14 May 2019 12:07:53 +0200 Subject: [PATCH 10/18] Noch mehr in CacheContruction --- .../bugageocaching/util/CacheConstructionUtil.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java index da7833c..43893f5 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java @@ -130,7 +130,7 @@ public class CacheConstructionUtil { oldCache = oldCacheOptional.get(); // oldStationen = new ArrayList<>(oldCache.getStationen()); } else { - return ResponseEntity.status(404).body("There isnt a cache with the id " + cache.getId()); + return ResponseEntity.status(404).body("Es gab einen Fehler. Bitte versuchen Sie es erneut oder kontaktieren Sie einen Admin."); } ResponseEntity response = new ResponseEntity(HttpStatus.ACCEPTED); @@ -168,26 +168,26 @@ public class CacheConstructionUtil { // überprüft den Cache nach validen Daten if (cache.getDescription().length() == 0 || cache.getName().length() == 0 || cache.getRankingPoints() == 0.0) { deleteNewCreatedStationsUtil(newCreatedStationList); - return ResponseEntity.status(400).body("cache fields can´t be empty"); + return ResponseEntity.status(400).body("Alle Felder müssen ausgefüllt sein!"); } if (cache.getStationen().size() < 2) { deleteNewCreatedStationsUtil(newCreatedStationList); - return ResponseEntity.status(400).body("a cache needs atleast 2 stations"); + return ResponseEntity.status(400).body("Ein Cache muss mindestens zwei Stationen haben. Bitte füge eine weiter Station hinzu!"); } for (Cache cache1 : cacheRepository.findAll()) { if (cache1.getName().equals(cache.getName())) { if (cache1.getId() != oldCache.getId()) { deleteNewCreatedStationsUtil(newCreatedStationList); - return ResponseEntity.status(400).body("name is already taken"); + return ResponseEntity.status(400).body("Der Cachename ist bereits vergeben. Bitte wähle einen anderen!"); } } } if (cache.getRankingPoints() < 0) { deleteNewCreatedStationsUtil(newCreatedStationList); - return ResponseEntity.status(400).body("Ranking points has to be a positive number"); + return ResponseEntity.status(400).body("Die Punkte für den Cache dürfen nicht negativ sein!"); } cacheRepository.save(cache); From fd72445e1e262b1a1c9a564c605f817ebb727d79 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 14 May 2019 12:08:25 +0200 Subject: [PATCH 11/18] reworked exception messages in FinderUtil --- .../labsw/bugageocaching/util/FinderUtil.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/util/FinderUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/FinderUtil.java index c42e4d0..4b2d9bb 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/FinderUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/FinderUtil.java @@ -89,7 +89,7 @@ public class FinderUtil { if (cacheOptional.isPresent()) { return ResponseEntity.status(200).body(cacheOptional.get()); } else { - return ResponseEntity.status(404).body("Couldnt find Cache " + cacheID); + return ResponseEntity.status(404).body("Ein Fehler ist aufgetreten. Bitte versuchen sie es erneut."); } } @@ -99,7 +99,7 @@ public class FinderUtil { if (stationOptional.isPresent()) { return ResponseEntity.status(200).body(stationOptional.get()); } else { - return ResponseEntity.status(404).body("Couldnt find Station " + stationID); + return ResponseEntity.status(404).body("Ein Fehler ist aufgetreten. Bitte versuchen sie es erneut."); } } @@ -111,7 +111,7 @@ public class FinderUtil { return ResponseEntity.status(200).body(bearbeitet); } - return ResponseEntity.status(404).body("The user has not started this cache yet"); + return ResponseEntity.status(404).body("Ein Fehler ist aufgetreten. Bitte versuchen sie es erneut."); } public static ResponseEntity findCacheAccesDefinitionById(String cacheAccesDefinitionID) { @@ -119,7 +119,7 @@ public class FinderUtil { if (cacheAccesDefinitionOptional.isPresent()) { return ResponseEntity.status(200).body(cacheAccesDefinitionOptional.get()); } else { - return ResponseEntity.status(404).body("Couldnt find CacheAccesDefinition " + cacheAccesDefinitionID); + return ResponseEntity.status(404).body("Ein Fehler ist aufgetreten. Bitte versuchen sie es erneut."); } } @@ -135,11 +135,11 @@ public class FinderUtil { User user = userOptional.get(); return ResponseEntity.status(200).body(user); } else { - return ResponseEntity.status(404).body("Couldnt find User " + userID); + return ResponseEntity.status(404).body("Ein Fehler ist aufgetreten. Bitte versuchen sie es erneut."); } } catch (ParseException e) { e.printStackTrace(); - return ResponseEntity.status(404).body("String format was corrupt"); + return ResponseEntity.status(404).body("Ein Fehler ist aufgetreten. Bitte versuchen sie es erneut."); } } @@ -148,7 +148,7 @@ public class FinderUtil { if (teamOptional.isPresent()) { return ResponseEntity.status(200).body(teamOptional.get()); } else { - return ResponseEntity.status(404).body("Couldnt find User_Info " + teamID); + return ResponseEntity.status(404).body("Ein Fehler ist aufgetreten. Bitte versuchen sie es erneut."); } } @@ -157,7 +157,7 @@ public class FinderUtil { if (teamInviteOptional.isPresent()) { return ResponseEntity.status(200).body(teamInviteOptional.get()); } else { - return ResponseEntity.status(404).body("Couldnt find User_Info " + teamInviteID); + return ResponseEntity.status(404).body("Ein Fehler ist aufgetreten. Bitte versuchen sie es erneut."); } } @@ -167,7 +167,7 @@ public class FinderUtil { if (team != null) { return ResponseEntity.status(200).body(team); } else { - return ResponseEntity.status(404).body("Couldnt find Team with name " + name); + return ResponseEntity.status(404).body("Ein Fehler ist aufgetreten. Bitte versuchen sie es erneut."); } } @@ -189,7 +189,7 @@ public class FinderUtil { return ResponseEntity.status(200).body(new Gson().toJson(sendBack)); } else { - return ResponseEntity.status(404).body("Couldnt find Team member of Team " + name); + return ResponseEntity.status(404).body("Ein Fehler ist aufgetreten. Bitte versuchen sie es erneut."); } } } From c18cbeff51cdceab0277e1aa4ffbf0abedc40703 Mon Sep 17 00:00:00 2001 From: Maximilian Leopold Date: Tue, 14 May 2019 12:14:31 +0200 Subject: [PATCH 12/18] Fehlermeldungen --- .../bugageocaching/controller/Controller.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index 4bbd3cf..67dd857 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -236,11 +236,11 @@ public class Controller { System.out.println(durchgefuehrterCache.getName()); if (!cacheID.equals(durchgefuehrterCacheID)) { - return ResponseEntity.status(400).body("The scanned station isn´t the correct following station (Name)"); + return ResponseEntity.status(400).body("Die gescannte Station ist nicht die korrekte nachfolge Station"); } if (!cache.getStationen().contains(station)) { - return ResponseEntity.status(400).body("The scanned station isnt a part of the cache"); + return ResponseEntity.status(400).body("Die gescannte Station gehört nicht zu dem gerade bearbeiteten Cache"); } //---------------------- @@ -281,13 +281,13 @@ public class Controller { Station aktuelleStation = bearbeitet.getAktuelleStation(); if (aktuelleStation == null) { - return ResponseEntity.status(400).body("Database Error"); + return ResponseEntity.status(400).body("Es gab einen Fehler. Bitte versuche es erneut oder kontaktiere einen Admin"); } int i = cache.getStationen().indexOf(station); if (i == 0) { - return ResponseEntity.status(400).body("The scanned station isn´t the correct following station (i==0)"); + return ResponseEntity.status(400).body("Die gescannte Station ist nicht die korrekte nachfolge Station"); } if (cache.getStationen().get(i - 1).equals(aktuelleStation)) { @@ -314,7 +314,7 @@ public class Controller { bearbeitetRepository.save(bearbeitet); return ResponseEntity.status(200).body(new Gson().toJson(bearbeitet)); } else { - return ResponseEntity.status(400).body("The scanned station isn´t the correct following station(nicht letzte)"); + return ResponseEntity.status(400).body("Die gescannte Station ist nicht die korrekte nachfolge Station"); } } @@ -451,7 +451,7 @@ public class Controller { logger.debug("/api/getMyCaches Got all bearbeitet entreis of user: " +user.getEmail()); return ResponseEntity.status(200).body(new Gson().toJson(bearbeitetList)); } else { - return ResponseEntity.status(404).body("User was not found in the database"); + return ResponseEntity.status(404).body("Es gab einen Fehler. Bitte versuche es erneut oder kontaktiere einen Admin!"); } } @@ -530,7 +530,7 @@ public class Controller { if (user != null) { return ResponseEntity.status(200).body(new Gson().toJson(user)); } else { - return ResponseEntity.status(404).body("User was not found in the database"); + return ResponseEntity.status(404).body("Es gab einen Fehler. Bitte versuche es erneut oder kontaktiere einen Admin!e"); } } @@ -567,13 +567,13 @@ public class Controller { User_Info user_info = user_infoRepository.findUser_InfoByUser(user); //---------------------- if (user_info.getTeam() != null) { - return ResponseEntity.status(400).body("You already have a team"); + return ResponseEntity.status(400).body("Du bist bereits in einem Team. Bitte verlasse dieses Team um ein neues Team zu erstellen!"); } // checkt, ob der name bereits vorhanden ist for (Team team : teamRepository.findAll()) { if (team.getName().equals(name)) { - return ResponseEntity.status(400).body("The teamname is already taken"); + return ResponseEntity.status(400).body("Der Teamname ist bereits vergeben. Bitte wähle einen anderen name"); } } @@ -622,7 +622,7 @@ public class Controller { User_Info user_info = user_infoRepository.findUser_InfoByUser(user); //---------------------- if (user_info.getTeam() != null) { - return ResponseEntity.status(400).body("You already have a team"); + return ResponseEntity.status(400).body("Du bist bereits in einem Team. Bitte verlasse dieses Team um einem neuen Team beizutreten"); } //Get team @@ -647,7 +647,7 @@ public class Controller { // wenn maximalanzahl der teammitglieder erreicht... if (user_infos.size() >= 10) { - return ResponseEntity.status(400).body("The team already has 10 members"); + return ResponseEntity.status(400).body("Das Team hat die Mitgliederanzahlgrenze von 10 Mitgliedern erreicht. Du kannst zurzeit nicht beitreten!"); } // tritt dem team bei @@ -693,7 +693,7 @@ public class Controller { User_Info user_info = user_infoRepository.findUser_InfoByUser(user); //---------------------- if (user_info.getTeam() == null) { - return ResponseEntity.status(400).body("You aren´t in any team"); + return ResponseEntity.status(400).body("Du bist bereits in keinem Team, welches du verlassen könntest."); } //Get team From 08c933976f0d6f28fe056fc6b340bce33d523f78 Mon Sep 17 00:00:00 2001 From: rchrist Date: Tue, 14 May 2019 12:14:36 +0200 Subject: [PATCH 13/18] reworked design of profile and team site --- frontend/src/pages/Profile.vue | 325 +++++++++++++++------------------ 1 file changed, 143 insertions(+), 182 deletions(-) diff --git a/frontend/src/pages/Profile.vue b/frontend/src/pages/Profile.vue index 7de88cd..29e472a 100644 --- a/frontend/src/pages/Profile.vue +++ b/frontend/src/pages/Profile.vue @@ -20,124 +20,120 @@
- -

Persönliche Daten

- + +
+

{{userName}}

+

{{email}}

+

Mein Rang: {{userRanking}}

+

Mein Team: {{teamName}}

+
+
+ + + + + + + + + + + + +
+ +
+
- -
- - - - - - - - - - - - - - Offene Teameinladungen - - - - - - - - - Neues Team erstellen - Neues Team erstellen
(Team verlassen um Option zu - nutzen) -
-
-
-
-
+ +
+

{{teamName}}

+

Unser Rang: {{teamRanking}}

+

+ {{currentTeamStatus}} + +

+ +
+ + +
-

Teamstatus

-

{{currentTeamStatus}}

- -
- -
-
-

Teammitglieder

- -
-

Einladungen

- -
- +

Teammitglieder

+ +
+
+ +
+
+ + +
+
+ +
+
-
-
- -
- - - - - - - - - - - -
@@ -175,55 +171,17 @@ teamName: null, boolAlreadyInTeam: false, teamRanking: null, - dropDownSelectedItem: null, - boolMyTeam: true, - boolInvites: false, - boolCreateTeam: false, newTeamName: "", leaveTeamCheck: "", teamMembers: [], teamInvites: [], - columns: [ - { - name: 'desc', - required: true, - align: 'left', - field: row => row.name, - format: val => `${val}`, - }, - { - name: 'userData', - required: true, - align: 'left', - field: 'userData', - } - ], - data: [ - { - name: 'Benutzername', - userData: this.userName, - }, - { - name: 'E-Mail', - userData: this.email, - }, - { - name: 'Rang', - userData: this.userRanking, - }, - { - name: 'Team', - userData: this.teamName, - }, - { - name: 'Team-Rang', - userData: this.teamRanking, - }, - ], + inviteActivated: false, + boolStatus: false, + boolMemberTableUpdating: false, teamColumns: [ { name: 'desc', - label: 'Benutzername', + label: 'Name', required: true, align: 'left', field: row => row.name, @@ -244,7 +202,6 @@ descending: false, page: 1, rowsPerPage: 10 - // rowsNumber: xx if getting data from a server }, } }, @@ -283,14 +240,40 @@ 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[1].userData = this.email; this.getPersonalRanking(); this.getTeamData(); this.fetchTeamInvites(); }, methods: { + confirmLeave() { + this.$q.dialog({ + title: 'Verlassen...', + message: 'Willst du dein aktuelles Team wirklich verlassen?', + persistent: true, + cancel: true, + }).onOk(() => { + console.log('>>>> OK'); + this.leaveTeam(); + }).onCancel(() => { + console.log('>>>> Cancel') + }).onDismiss(() => { + }) + }, + activateInvite() { + if (this.inviteActivated) { + this.inviteActivated = false; + } else { + this.inviteActivated = true; + } + }, + updateStatus() { + if (this.boolStatus) { + this.boolStatus = false; + } else { + this.boolStatus = true; + } + }, validateEmail(email) { let 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()); @@ -300,7 +283,6 @@ this.$axios.get('/api/getRankingPlace', {params: {email}}) .then((response) => { this.userRanking = response.data; - this.data[2].userData = this.userRanking; }).catch((error) => { this.handleError(error); }) @@ -324,35 +306,12 @@ this.boolAlreadyInTeam = true; this.teamName = response.data.name; this.currentTeamStatus = response.data.teamStatus; - //this.teamRanking = response.data.teamRanking; this.fetchTeamMembers(); } - this.data[3].userData = this.teamName; - this.dropDownSelectedItem = this.teamName; - this.data[4].userData = this.teamRanking; console.log("getTeam: " + response); }).catch((error) => { this.handleError(error); - }) - }, - - dropDownSelectItem(item) { - if (item === 'team') { - this.dropDownSelectedItem = this.teamName; - this.boolMyTeam = true; - this.boolInvites = false; - this.boolCreateTeam = false; - } else if (item === 'Offene Teameinladungen') { - this.dropDownSelectedItem = item; - this.boolMyTeam = false; - this.boolInvites = true; - this.boolCreateTeam = false; - } else { - this.dropDownSelectedItem = item; - this.boolMyTeam = false; - this.boolInvites = false; - this.boolCreateTeam = true; - } + }); }, createTeam() { let params = {}; @@ -395,6 +354,7 @@ }) }, fetchTeamMembers() { + this.teamData = []; let name = this.teamName; this.$axios.get('/api/getTeamMembers', {params: {name}}) .then((response) => { @@ -510,6 +470,7 @@ }).catch((error) => { this.handleError(error); }) + this.updateStatus(); }, handleError(error) { // Error From 2533442cae829dfa6bc05fa90d857ac1c6ec909f Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 14 May 2019 12:16:44 +0200 Subject: [PATCH 14/18] better exception messages --- .../bugageocaching/controller/Controller.java | 8 ++++---- .../bugageocaching/util/VerificationUtil.java | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index 4bbd3cf..34f66bd 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -761,7 +761,7 @@ public class Controller { User invitedUser = userRepository.findByEmail(invitedUserEmail); if (invitedUser == null) { - return ResponseEntity.status(404).body("There isnt any user with that email"); + return ResponseEntity.status(404).body("Es gibt keinen Benutzer mit dieser email."); } //---------------------- @@ -770,7 +770,7 @@ public class Controller { User_Info user_info = user_infoRepository.findUser_InfoByUser(user); //---------------------- if (user_info.getTeam() == null) { - return ResponseEntity.status(400).body("You aren´t in any team"); + return ResponseEntity.status(400).body("Du bist derzeit in keinem Team und kannst deshalb keine Teameinladungen versenden."); } //Get team @@ -783,7 +783,7 @@ public class Controller { Team team = (Team) getTeam.getBody(); if (teamInviteRepository.findByUserAndTeam(invitedUser, team) != null) { - return ResponseEntity.status(400).body("The user is already invited to this team"); + return ResponseEntity.status(400).body("Der Benutzer ist bereits in das Team eingeladen."); } TeamInvite teamInvite = new TeamInvite(); @@ -906,7 +906,7 @@ public class Controller { User_Info user_info = user_infoRepository.findUser_InfoByUser(user); //---------------------- if (user_info.getTeam() == null) { - return ResponseEntity.status(400).body("You aren´t in any team"); + return ResponseEntity.status(400).body("Du kannst einen Teamstatus nur setzen, wenn du in einem Team bist."); } //Get team diff --git a/src/main/java/hhn/labsw/bugageocaching/util/VerificationUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/VerificationUtil.java index fb047af..8c092ce 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/VerificationUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/VerificationUtil.java @@ -19,7 +19,7 @@ public class VerificationUtil { private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(VerificationUtil.class); - public static void fetchPublicKey(){ + public static void fetchPublicKey() { RestTemplate restTemplate = new RestTemplate(); try { logger.warn("POST CONSCTRUCT: FETCH PUBLIC KEY"); @@ -41,9 +41,9 @@ public class VerificationUtil { //Fehler muss zurückgegeben werden } - public static ResponseEntity verifyToken(String token){ + public static ResponseEntity verifyToken(String token) { - try{ + try { logger.warn("VERIFY TOKEN: token: " + token); Claims claims = Jwts.parser() //Parse JWT @@ -53,12 +53,12 @@ public class VerificationUtil { logger.debug("VERIFY TOKEN: Got Claims: " + claims); return ResponseEntity.status(200).body(claims); - } catch (ExpiredJwtException e){ + } catch (ExpiredJwtException e) { logger.debug("VERIFY TOKEN: JWT Token expired"); - return ResponseEntity.status(401).body("JWT Token expired"); - } catch (Exception e){ + return ResponseEntity.status(401).body("Bitte loggen sie sich erneut ein."); + } catch (Exception e) { logger.debug("VERIFY TOKEN: Something went wrong verificating"); - return ResponseEntity.status(400).body("Something went wrong"); + return ResponseEntity.status(401).body("Bitte loggen sie sich erneut ein."); } } } From adad85d4d0845cf99655b8ac9a1cc7a0a7442995 Mon Sep 17 00:00:00 2001 From: rchrist Date: Tue, 14 May 2019 14:12:10 +0200 Subject: [PATCH 15/18] bugfixes --- frontend/src/pages/Profile.vue | 220 ++++++++++++++++++-------------- frontend/src/pages/Register.vue | 2 +- 2 files changed, 126 insertions(+), 96 deletions(-) diff --git a/frontend/src/pages/Profile.vue b/frontend/src/pages/Profile.vue index 911acb4..d5bef62 100644 --- a/frontend/src/pages/Profile.vue +++ b/frontend/src/pages/Profile.vue @@ -12,7 +12,7 @@ switch-indicator > - +
@@ -23,24 +23,28 @@

{{userName}}

-

{{email}}

+

Meine Email: {{email}}

Mein Rang: {{userRanking}}

Mein Team: {{teamName}}

- - +
+ + +
+
+

Teameinladungen

-
- -
+ +

{{teamName}}

Unser Rang: {{teamRanking}}

- {{currentTeamStatus}} + Unser Status: {{currentTeamStatus}}

-
+

Teammitglieder


- - +
+ + +

()\[\]\\.,;:\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()); @@ -287,31 +302,38 @@ this.handleError(error); }) }, + async updateTeamData() { + await this.getTeamData(); + this.boolTable = false; + this.boolTable = await this.fetchTeamMembers(); + await this.fetchTeamInvites(); + }, getTeamData() { - let token; - if (localStorage.getItem('userToken')) { - token = JSON.parse(localStorage.getItem('userToken')).token; - } else { - return; - } - this.$axios.get('/api/getTeamOfUser', {params: {token}}) - .then(response => { - 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; - this.currentTeamStatus = response.data.teamStatus; - this.fetchTeamMembers(); - } - console.log("getTeam: " + response); - }).catch((error) => { - this.handleError(error); - }); + return new Promise(resolve => { + let token; + if (localStorage.getItem('userToken')) { + token = JSON.parse(localStorage.getItem('userToken')).token; + } else { + return; + } + this.$axios.get('/api/getTeamOfUser', {params: {token}}) + .then(response => { + if (response.data === '') { + this.boolAlreadyInTeam = false; + this.teamName = "Aktuell in keinem Team"; + this.currentTeamStatus = ""; + this.teamRanking = "-"; + } else { + this.boolAlreadyInTeam = true; + this.teamName = response.data.name; + this.currentTeamStatus = response.data.teamStatus; + this.teamRanking = "-"; + } + console.log("getTeam: " + response); + }).catch((error) => { + this.handleError(error); + }).finally(() => resolve(true)); + }) }, createTeam() { let params = {}; @@ -329,6 +351,7 @@ title: "Teamerstellung", color: "blue" }); + this.updateTeamData(); }).catch((error) => { this.handleError(error); }) @@ -344,56 +367,63 @@ .then((response) => { console.log("createTeam: " + response); this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { - message: "Dus hast das Team " + this.teamName + " verlassen!", + message: "Du hast das Team " + this.teamName + " verlassen!", title: "Team verlassen", color: "blue" }); - this.getTeamData(); + this.updateTeamData(); }).catch((error) => { this.handleError(error); }) }, fetchTeamMembers() { - this.teamData = []; - let name = this.teamName; - this.$axios.get('/api/getTeamMembers', {params: {name}}) - .then((response) => { - console.log(response.data); - this.teamMembers = response.data; - for (var i = 0; i < this.teamMembers.length; i++) { - let member = {}; - member.name = this.teamMembers[i].username; - member.email = this.teamMembers[i].email; - this.getMemberRanking(member, member.email); - this.teamData.push(member); - } - }).catch((error) => { - this.handleError(error); + return new Promise(resolve => { + this.teamData = []; + let name = this.teamName; + this.$axios.get('/api/getTeamMembers', {params: {name}}) + .then(async (response) => { + console.log(response.data); + this.teamMembers = response.data; + for (var i = 0; i < this.teamMembers.length; i++) { + let member = {}; + member.name = this.teamMembers[i].username; + member.email = this.teamMembers[i].email; + await this.getMemberRanking(member, member.email); + this.teamData.push(member); + } + }).catch((error) => { + this.handleError(error); + }).finally(() => resolve(true)) }) }, getMemberRanking(member, email) { - let ranking; - this.$axios.get('/api/getRankingPlace', {params: {email}}) - .then((response) => { - ranking = response.data; - member.ranking = ranking; - }).catch((error) => { - this.handleError(error); - }); + return new Promise(resolve => { + this.updateTable(); + let ranking; + this.$axios.get('/api/getRankingPlace', {params: {email}}) + .then((response) => { + ranking = response.data; + member.ranking = ranking; + }).catch((error) => { + this.handleError(error); + }).finally(() => resolve(true)) + }) }, fetchTeamInvites() { - let token; - if (localStorage.getItem('userToken')) { - token = JSON.parse(localStorage.getItem('userToken')).token; - } else { - return; - } - this.$axios.get('/api/getMyTeamInvites', {params: {token}}) - .then((response) => { - this.teamInvites = response.data; - console.log(this.teamInvites); - }).catch((error) => { - this.handleError(error); + return new Promise(resolve => { + let token; + if (localStorage.getItem('userToken')) { + token = JSON.parse(localStorage.getItem('userToken')).token; + } else { + return; + } + this.$axios.get('/api/getMyTeamInvites', {params: {token}}) + .then((response) => { + this.teamInvites = response.data; + console.log(this.teamInvites); + }).catch((error) => { + this.handleError(error); + }).finally(() => resolve(true)) }) }, joinTeam(teamInvite) { @@ -412,7 +442,7 @@ title: "Teambeitrittsanfrage", color: "blue" }); - this.getTeamData(); + this.updateTeamData(); }).catch((error) => { this.handleError(error); }) @@ -432,7 +462,7 @@ title: "Teambeitrittsanfrage", color: "blue" }); - this.getTeamData(); + this.updateTeamData(); }).catch((error) => { this.handleError(error); }) @@ -466,7 +496,7 @@ params.teamStatus = this.teamStatus; this.$axios.put('/api/setTeamStatus', null, {params}) .then((response) => { - this.getTeamData(); + this.updateTeamData(); }).catch((error) => { this.handleError(error); }) diff --git a/frontend/src/pages/Register.vue b/frontend/src/pages/Register.vue index 2a9d9ae..868d5b7 100644 --- a/frontend/src/pages/Register.vue +++ b/frontend/src/pages/Register.vue @@ -6,7 +6,7 @@
-
From a4f6401ff9ee178c392e454ee7903ee95809e33c Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 15 May 2019 10:05:49 +0200 Subject: [PATCH 16/18] =?UTF-8?q?fehlermeldungen=20=C3=BCberarbeitet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../labsw/bugageocaching/util/CacheConstructionUtil.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java index 43893f5..cfabb7d 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java @@ -83,16 +83,16 @@ public class CacheConstructionUtil { public static ResponseEntity createStationUtil(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.getSolution().length() == 0*/) { return ResponseEntity.status(400).body("Alle Felder müssen ausgefüllt werden!"); } if (station.getLattitude() < 9 || station.getLattitude() > 10) { - return ResponseEntity.status(400).body("Die Lattitude ist außerhalb der Bundesgartenschau"); + return ResponseEntity.status(400).body("Der Breitengrad einer Station ist außerhalb der Bundesgartenschau"); } if (station.getLongitude() < 49 || station.getLongitude() > 50) { - return ResponseEntity.status(400).body("Die Longitude ist außerhalb der Bundesgartenschau"); + return ResponseEntity.status(400).body("Der Längengrad einer Station ist außerhalb der Bundesgartenschau"); } Random r = new Random(); From 8d1b2c5e8a4b3a83ab4e5c48975b0d57874b7d33 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 15 May 2019 11:08:37 +0200 Subject: [PATCH 17/18] changed longitude/latitude --- .../labsw/bugageocaching/util/CacheConstructionUtil.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java index cfabb7d..78ff956 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java @@ -87,12 +87,12 @@ public class CacheConstructionUtil { return ResponseEntity.status(400).body("Alle Felder müssen ausgefüllt werden!"); } - if (station.getLattitude() < 9 || station.getLattitude() > 10) { - return ResponseEntity.status(400).body("Der Breitengrad einer Station ist außerhalb der Bundesgartenschau"); + if (station.getLattitude() < 49 || station.getLattitude() > 50) { + return ResponseEntity.status(400).body("Der Längengrad einer Station ist außerhalb der Bundesgartenschau"); } - if (station.getLongitude() < 49 || station.getLongitude() > 50) { - return ResponseEntity.status(400).body("Der Längengrad einer Station ist außerhalb der Bundesgartenschau"); + if (station.getLongitude() < 9 || station.getLongitude() > 10) { + return ResponseEntity.status(400).body("Der Breitengrad einer Station ist außerhalb der Bundesgartenschau"); } Random r = new Random(); From 4b72e5c1e6f586e033928a652a449b3756b42b61 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 15 May 2019 11:08:56 +0200 Subject: [PATCH 18/18] .. --- .../hhn/labsw/bugageocaching/util/CacheConstructionUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java index 78ff956..0866ba6 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java @@ -88,11 +88,11 @@ public class CacheConstructionUtil { } if (station.getLattitude() < 49 || station.getLattitude() > 50) { - return ResponseEntity.status(400).body("Der Längengrad einer Station ist außerhalb der Bundesgartenschau"); + return ResponseEntity.status(400).body("Der Breitengrad einer Station ist außerhalb der Bundesgartenschau"); } if (station.getLongitude() < 9 || station.getLongitude() > 10) { - return ResponseEntity.status(400).body("Der Breitengrad einer Station ist außerhalb der Bundesgartenschau"); + return ResponseEntity.status(400).body("Der Längengrad einer Station ist außerhalb der Bundesgartenschau"); } Random r = new Random();