Rankinglist now highlights your name

This commit is contained in:
Maximilian Leopold 2019-05-24 21:38:01 +02:00
parent 81a4d7303c
commit 986b7fbba2
2 changed files with 43 additions and 15 deletions

View File

@ -21,10 +21,11 @@
<q-tab-panels v-model="tab" animated swipeable class="col"> <q-tab-panels v-model="tab" animated swipeable class="col">
<q-tab-panel name="solo" class="q-pa-md fit"> <q-tab-panel name="solo" class="q-pa-md fit">
<q-list> <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, index) in rankinglist" :key="user.id">
<q-item class="q-pr-sm "> <q-item class="q-pr-sm ">
<q-item-section> <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-label v-if="username === user.username"><a class="text-green" style="text-decoration: none"><span>{{index+1}}. {{user.username}}</span></a></q-item-label>
<q-item-label v-if="username !== user.username"><a class="text-black" style="text-decoration: none"><span>{{index+1}}. {{user.username}}</span></a></q-item-label>
</q-item-section> </q-item-section>
<q-item-section side> <q-item-section side>
<span class="text-grey">{{user.rankingPointsSum}} Punkte </span> <span class="text-grey">{{user.rankingPointsSum}} Punkte </span>
@ -69,7 +70,8 @@
return { return {
tab: 'solo', tab: 'solo',
rankinglist: [], rankinglist: [],
teamRankinglist: [] teamRankinglist: [],
username: null
} }
}, },
created: function() { created: function() {
@ -77,9 +79,21 @@
console.log("created(): " + this.teamRankinglist); console.log("created(): " + this.teamRankinglist);
this.fetchRankinglist(); this.fetchRankinglist();
this.fetchTeamRankinglist(); this.fetchTeamRankinglist();
this.username = JSON.parse(localStorage.getItem('userToken')).name;
}, },
methods: { methods: {
fetchRankinglist() { fetchRankinglist() {
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') this.$axios.get('/api/getRankingList')
.then((response) => { .then((response) => {
console.log("Rankinglist: "); console.log("Rankinglist: ");
@ -87,6 +101,7 @@
this.rankinglist = response.data; this.rankinglist = response.data;
}).catch((error) => { }).catch((error) => {
}) })
}
}, },
fetchTeamRankinglist() { fetchTeamRankinglist() {
this.$axios.get('/api/getTeamRankingList') this.$axios.get('/api/getTeamRankingList')

View File

@ -419,13 +419,26 @@ public class Controller {
User user = (User) getUser.getBody(); User user = (User) getUser.getBody();
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(!userAlreadyInRankingList) {
ResponseEntity singlePlace = getRankingPlace(user.getEmail()); ResponseEntity singlePlace = getRankingPlace(user.getEmail());
if(singlePlace.getStatusCodeValue() == 200){ if (singlePlace.getStatusCodeValue() == 200) {
RankingListHelper rankingListHelper = new RankingListHelper(user.getEmail(), (Integer) singlePlace.getBody()); RankingListHelper rankingListHelper = new RankingListHelper(user.getUsername(), (Integer) user_infoRepository.findUser_InfoByUser(user).getRankingPointsSum());
logger.debug(String.valueOf((Integer) singlePlace.getBody()));
sendBackUsers.add(rankingListHelper); sendBackUsers.add(rankingListHelper);
} }
} }
}
return ResponseEntity.status(200).body(new Gson().toJson(sendBackUsers)); return ResponseEntity.status(200).body(new Gson().toJson(sendBackUsers));
} }