Merge branch 'develop' into frontend/kathy

This commit is contained in:
Katharina Will 2019-05-27 12:21:07 +02:00
commit 5e67597659
8 changed files with 2101 additions and 329 deletions

View File

@ -1,20 +0,0 @@
<html lang="de">
<head>
<meta charset="UTF-8">
<title>BuGa Lageplan</title>
<script src="/config.js"></script>
<!--get local copy of openlayers javascript file-->
<script src="/scripts/ol.js"></script>
<!--get openlayers support javascript file-->
<script src="/scripts/mapScript.js"></script>
<link rel="stylesheet" href="/stylesheets/map.css">
<link rel="stylesheet" href="/stylesheets/style.css">
</head>
<body class="fullscreen">
<div id="map" class="map fullscreen"></div>
<script type="text/javascript">
const map = createMapFromPoiSet([{"Name":"Wolfszipfel_Station1","Latitude":49.14709,"Longitude":9.208993,"CategoryID":0},{"Name":"Live Demo Cache_Station1","Latitude":49,"Longitude":9,"CategoryID":0},{"Name":"GeoCaching für alle_Station1","Latitude":49,"Longitude":9,"CategoryID":0},{"Name":"Test Cache_Station1","Latitude":49.1,"Longitude":9.207,"CategoryID":0},{"Name":"GeoCaching für alle_Station2","Latitude":49,"Longitude":9,"CategoryID":1},{"Name":"GeoCaching für alle_Station3","Latitude":49,"Longitude":9,"CategoryID":1},{"Name":"GeoCaching für alle_Station4","Latitude":49,"Longitude":9,"CategoryID":1},{"Name":"GeoCaching für alle_Station5","Latitude":49,"Longitude":9,"CategoryID":1}]);
</script>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -16,8 +16,10 @@
"@quasar/extras": "^1.1.2",
"ajv": "6.8.1",
"axios": "^0.18.0",
"openlayers": "^4.6.5",
"quasar": "^1.0.0-beta.23",
"vue-qrcode-reader": "^1.4.2"
"vue-qrcode-reader": "^1.4.2",
"vuelayers": "^0.11.4"
},
"devDependencies": {
"@quasar/app": "^1.0.0-beta.25",

View File

@ -29,6 +29,7 @@
:key="startedCache.id"
>
<q-expansion-item
group="started"
class=""
expand-separator
icon="location_on"
@ -46,9 +47,31 @@
</q-item>
<q-item class="q-pr-sm reverse">
<q-btn @click="continueCache(startedCache.cache.id)" unelevated color="positive" stack
icon="arrow_forward"
label="Fortfahren" size="sm"/>
<!-- <q-btn @click="continueCache(startedCache.cache.id)" unelevated color="positive"-->
<!-- icon="arrow_forward"-->
<!-- label="Fortfahren" size=""/>-->
<q-btn-dropdown
@click="continueCache(startedCache.cache.id)"
label="Fortfahren"
color="amber"
unelevated
icon="arrow_forward"
split
>
<q-list>
<q-item clickable v-close-popup class="text-grey-14" @click="confirmReset(startedCache.cache.id)" >
<q-item-section>
Cache zurücksetzen
</q-item-section>
<q-item-section avatar>
<q-icon name="delete"/>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
</q-item>
</q-expansion-item>
</q-card>
@ -62,6 +85,7 @@
v-for="finishedCache in startedCaches.filter(cache => cache.cacheAccesDefinition.id === 1)"
:key="finishedCache.id">
<q-expansion-item
group="finished"
class=""
expand-separator
icon="location_on"
@ -82,9 +106,30 @@
</q-item-section>
</q-item>
<q-item class="q-pr-sm reverse q-gutter-x-sm">
<q-btn @click="goToReward(finishedCache.cache.id)" unelevated color="primary" stack
<q-btn @click="goToReward(finishedCache.cache.id)" unelevated color="primary"
icon="arrow_forward"
label="Belohnung ansehen" size="sm"/>
label="Belohnung ansehen" size=""/>
<q-btn-dropdown
@click="goToReward(finishedCache.cache.id)"
label="Belohnung"
color="primary"
unelevated
icon="arrow_forward"
split
>
<q-list>
<q-item clickable v-close-popup class="text-grey-14" @click="confirmReset(startedCache.cache.id)" >
<q-item-section>
Cache zurücksetzen
</q-item-section>
<q-item-section avatar>
<q-icon name="delete"/>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
</q-item>
</q-expansion-item>
</q-card>
@ -121,6 +166,51 @@
this.fetchUserCaches();
},
methods: {
confirmReset(cacheID) {
console.log("confirmReset")
console.log("CacheID: "+cacheID)
this.$q.dialog({
title: 'Zurücksetzen...',
message: 'Möchtest du deinen Fortschritt bei diesem Cache wirklich zurücksetzen? ' +
'Bereits erworbene Punkte werden dir wieder abgezogen. ' +
'Du kannst den Cache danach wieder von vorne beginnen.',
persistent: true,
cancel: true,
}).onOk(() => {
console.log('>>>> OK');
this.resetCache(cacheID)
}).onCancel(() => {
console.log('>>>> Cancel')
}).onDismiss(() => {
})
},
resetCache(cacheID) {
console.log('reset cache: ' + cacheID);
const token = JSON.parse(localStorage.getItem('userToken')).token;
this.$axios.delete('/api/deleteCacheForUser', {params: {cacheID: cacheID , token: token}})
.then((response) => {
this.fetchUserCaches();
}).catch((error) => {
let msg;
let title;
if (error.response) {
title = "Fehler!";
msg = error.response.data;
} else if (error.request) {
title = "Verbindungsfehler!";
msg = "Es konnte keine Verbindung zum Server aufgebaut werden. Versuchen Sie es später noch einmal!"
console.log(error.request);
} else {
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,});
})
},
calculateProgress() {
console.log("calcProgress...")
console.log("this.startedCaches: ")

View File

@ -18,7 +18,7 @@
</div>
<div class="col flex column">
<q-tab-panels v-model="tab" animated swipeable class="col">
<q-tab-panels v-model="tab" animated class="col">
<q-tab-panel name="list" class=" fit">
<q-spinner-oval
@ -31,6 +31,7 @@
<q-list v-if="render">
<q-card class="q-mb-md" v-for="cache in caches" :key="cache.id">
<q-expansion-item
group="cachegroup"
class=""
expand-separator
icon="location_on"
@ -50,21 +51,51 @@
</q-item-section>
</q-item>
<q-item class="q-pr-sm reverse q-gutter-x-sm">
<q-btn v-if="(getCacheAccesDefinition(cache) === -1)" @click="startCache(cache.id)" unelevated
:color="getColorClass(cache)" stack icon="arrow_forward"
label="Starten" size="xs"/>
<q-btn v-if="(getCacheAccesDefinition(cache) === 0)" @click="continueCache(cache.id)" unelevated
:color="getColorClass(cache)" stack icon="arrow_forward"
label="Fortsetzen" size="xs"/>
<q-btn v-if="(getCacheAccesDefinition(cache) === 1)" @click="goToReward(cache.id)" unelevated
:color="getColorClass(cache)" stack icon="arrow_forward"
label="Belohnung" size="xs"/>
<q-btn v-if="hasAdminState" @click="confirmDelete(cache.id)" unelevated color="negative" stack
icon="delete" size="xs"/>
<q-btn v-if="hasAdminState" @click="editCache(cache.id)" unelevated color="primary" stack
icon="edit" size="xs"/>
<q-btn v-if="hasAdminState" @click="generateQrCodes(cache.id)" unelevated color="primary" stack
icon="image" label="QRCodes" size="xs"/>
<q-btn-dropdown
v-if="hasAdminState"
@click="openCache(cache)"
:color="getColorClass(cache)"
:label="getOpenCacheLabel(cache)"
unelevated
icon="arrow_forward"
split
>
<q-list>
<q-item clickable v-close-popup class="text-grey-14" @click="generateQrCodes(cache.id)" >
<q-item-section>
QR-Codes
</q-item-section>
<q-item-section avatar>
<q-icon name="image"/>
</q-item-section>
</q-item>
<q-item clickable v-close-popup class="text-grey-14" @click="editCache(cache.id)" >
<q-item-section>
Bearbeiten
</q-item-section>
<q-item-section avatar>
<q-icon name="edit"/>
</q-item-section>
</q-item>
<q-item clickable v-close-popup class="text-grey-14" @click="confirmDelete(cache.id)" >
<q-item-section>
Löschen
</q-item-section>
<q-item-section avatar>
<q-icon name="delete"/>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
<div v-if="!hasAdminState">
<q-btn @click="startCache(cache.id)" unelevated
:color="getColorClass(cache)" icon="arrow_forward"
label="Starten" size="" />
</div>
</q-item>
</q-expansion-item>
</q-card>
@ -171,6 +202,29 @@ Vue.use(VueLayers);
return "green"
}
},
getOpenCacheLabel(cache) {
switch (this.getCacheAccesDefinition(cache)) {
case -1:
return "Starten"
case 0:
return "Fortsetzen"
case 1:
return "Belohnung"
}
},
openCache(cache) {
switch (this.getCacheAccesDefinition(cache)) {
case -1:
return this.startCache(cache.id);
case 0:
return this.continueCache(cache.id);
case 1:
return this.goToReward(cache.id);
}
},
getCacheAccesDefinition(cache) {
// console.log("getCacheAccessDefinition")
// console.log(cache.hasOwnProperty('cacheAccesDefinition') ? cache.cacheAccesDefinition : -1)

View File

@ -21,16 +21,21 @@
<q-tab-panels v-model="tab" animated swipeable class="col">
<q-tab-panel name="solo" class="q-pa-md fit">
<q-list>
<q-card class="q-mb-md" v-for="(user,index) in rankinglist" :key="user.id">
<q-card class="q-mb-md" v-for="(user) in rankinglist" :key="user.id">
<q-item class="q-pr-sm ">
<q-item-section>
<q-item-label><a class="text-black" style="text-decoration: none"><span>{{index+1}}. {{user.username}}</span></a></q-item-label>
</q-item-section>
<q-item-label v-if="username === user.username" @click="gotoProfile"><a class="text-green" style="text-decoration: none"><span>{{user.rank}}. {{user.username}}</span></a></q-item-label>
<q-item-label v-if="username !== user.username"><a class="text-black" style="text-decoration: none"><span>{{user.rank}}. {{user.username}}</span></a></q-item-label>
</q-item-section>
<q-item-section side>
<span class="text-grey">{{user.rankingPointsSum}} Punkte </span>
</q-item-section>
</q-item>
</q-card>
<div v-if="hasAdminState" class="row">
<q-btn @click="resetRankingList" unelevated color="primary" label="Rangliste zurücksetzen"
class="full-width"/>
</div>
</q-list>
</q-tab-panel>
@ -69,7 +74,8 @@
return {
tab: 'solo',
rankinglist: [],
teamRankinglist: []
teamRankinglist: [],
username: null
}
},
created: function() {
@ -77,16 +83,34 @@
console.log("created(): " + this.teamRankinglist);
this.fetchRankinglist();
this.fetchTeamRankinglist();
this.username = JSON.parse(localStorage.getItem('userToken')).name;
},
computed: {
hasAdminState() {
return this.$store.getters['auth/GET_ADMINSTATE'];
}
},
methods: {
fetchRankinglist() {
this.$axios.get('/api/getRankingList')
.then((response) => {
console.log("Rankinglist: ");
console.log(response.data);
this.rankinglist = response.data;
}).catch((error) => {
})
let token;
if(localStorage.getItem('userToken')){
token = JSON.parse(localStorage.getItem('userToken')).token;
this.$axios.get('/api/getRankingList', {params: {token}})
.then((response) => {
console.log("Rankinglist: ");
console.log(response.data);
this.rankinglist = response.data;
}).catch((error) => {
})
} else {
this.$axios.get('/api/getRankingList')
.then((response) => {
console.log("Rankinglist: ");
console.log(response.data);
this.rankinglist = response.data;
}).catch((error) => {
})
}
},
fetchTeamRankinglist() {
this.$axios.get('/api/getTeamRankingList')
@ -97,6 +121,30 @@
}).catch((error) => {
})
},
gotoProfile(){
this.$router.push({path: `/Profile`})
},
resetRankingList(){
let token = JSON.parse(localStorage.getItem('userToken')).token;
this.$axios.get('/api/resetRankingList', {params: {token}})
.then((response) => {
console.log("Reset Rankinglist: ");
console.log(response.data);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
message: "Die Rangliste wurde erfolgreich zurückgesetzt",
color: "blue"
});
this.$axios.get('/api/getRankingList', {params: {token}})
.then((response) => {
console.log("Rankinglist: ");
console.log(response.data);
this.rankinglist = response.data;
}).catch((error) => {
})
}).catch((error) => {
}).then()
},
calculateRank() {
// TODO
// let rank = 0;

View File

@ -392,9 +392,11 @@ public class Controller {
logger.debug("/api/getRankingList create sendBackUsers");
List<Object[]> rankingUsers = userRepository.getRankingList();
logger.debug("/api/getRankingList got Object[] from DB");
int rank = 1;
for (Object[] obj : rankingUsers) {
RankingListHelper tmp = new RankingListHelper((String) obj[1], (Integer) obj[2]);
RankingListHelper tmp = new RankingListHelper((String) obj[1], (Integer) obj[2], rank);
sendBackUsers.add(tmp);
rank++;
}
logger.debug("/api/getRankingList Converted Objects to RankingListHelper");
logger.debug("/api/getRankingList RankingList: " + new GsonBuilder().setPrettyPrinting().create().toJson(sendBackUsers));
@ -419,11 +421,24 @@ public class Controller {
User user = (User) getUser.getBody();
ResponseEntity singlePlace = getRankingPlace(user.getEmail());
boolean userAlreadyInRankingList = false;
for (RankingListHelper rankingListHelper: sendBackUsers) {
logger.debug("RankingList Helper " + rankingListHelper.getUsername());
logger.debug("User: " + user.getUsername());
if(rankingListHelper.getUsername().equals(user.getUsername())){
userAlreadyInRankingList = true;
break;
}
}
if(singlePlace.getStatusCodeValue() == 200){
RankingListHelper rankingListHelper = new RankingListHelper(user.getEmail(), (Integer) singlePlace.getBody());
sendBackUsers.add(rankingListHelper);
if(!userAlreadyInRankingList) {
ResponseEntity singlePlace = getRankingPlace(user.getEmail());
if (singlePlace.getStatusCodeValue() == 200) {
RankingListHelper rankingListHelper = new RankingListHelper(user.getUsername(), (Integer) user_infoRepository.findUser_InfoByUser(user).getRankingPointsSum(), (Integer) getRankingPlace(user.getEmail()).getBody());
logger.debug(String.valueOf((Integer) singlePlace.getBody()));
sendBackUsers.add(rankingListHelper);
}
}
}
return ResponseEntity.status(200).body(new Gson().toJson(sendBackUsers));
@ -1153,7 +1168,7 @@ public class Controller {
@ApiResponse(code = 400, message = "Something went wrong at verification")
})
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/resetRankingList", method = RequestMethod.PUT, produces = "application/json")
@RequestMapping(value = "/api/resetRankingList", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity resetRankingList(@RequestParam String token) {
logger.warn("API CALL: /api/resetRankingList");

View File

@ -4,10 +4,12 @@ public class RankingListHelper {
private String username;
private int rankingPointsSum;
private int rank;
public RankingListHelper(String username, int ranking_Points) {
public RankingListHelper(String username, int ranking_Points, int rank) {
this.username = username;
this.rankingPointsSum = ranking_Points;
this.rank = rank;
}
public String getUsername() {
@ -26,6 +28,14 @@ public class RankingListHelper {
this.rankingPointsSum = ranking_Points;
}
public int getRank() {
return rank;
}
public void setRank(int rank) {
this.rank = rank;
}
@Override
public String toString() {
return "( " + username + " | " + rankingPointsSum + " )";