Rankinglist now highlights your name
This commit is contained in:
parent
81a4d7303c
commit
986b7fbba2
@ -21,11 +21,12 @@
|
||||
<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, index) 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"><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 side>
|
||||
<span class="text-grey">{{user.rankingPointsSum}} Punkte </span>
|
||||
</q-item-section>
|
||||
@ -69,7 +70,8 @@
|
||||
return {
|
||||
tab: 'solo',
|
||||
rankinglist: [],
|
||||
teamRankinglist: []
|
||||
teamRankinglist: [],
|
||||
username: null
|
||||
}
|
||||
},
|
||||
created: function() {
|
||||
@ -77,16 +79,29 @@
|
||||
console.log("created(): " + this.teamRankinglist);
|
||||
this.fetchRankinglist();
|
||||
this.fetchTeamRankinglist();
|
||||
this.username = JSON.parse(localStorage.getItem('userToken')).name;
|
||||
},
|
||||
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')
|
||||
|
||||
@ -419,11 +419,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());
|
||||
logger.debug(String.valueOf((Integer) singlePlace.getBody()));
|
||||
sendBackUsers.add(rankingListHelper);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ResponseEntity.status(200).body(new Gson().toJson(sendBackUsers));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user