implementation of some api calls finished

This commit is contained in:
rchrist 2019-05-08 16:15:44 +02:00
parent 20dfcd6ceb
commit 80459cd793
3 changed files with 33 additions and 19 deletions

View File

@ -109,8 +109,8 @@ module.exports = function (ctx) {
},
env: ctx.dev
? { // Base URL for API-Calls: DEV
//API: JSON.stringify('http://localhost:8080')
API: JSON.stringify('https://seserver.se.hs-heilbronn.de:8443/buga19geocaching'),
//API: JSON.stringify('https://seserver.se.hs-heilbronn.de:8443/buga19geocaching')
API: JSON.stringify('http://localhost:8080'),
USER_API: JSON.stringify('https://seserver.se.hs-heilbronn.de:8443/buga19usermanagement')
}
: { // Base URL for API-Calls: PRODUCTION (build)

View File

@ -35,7 +35,7 @@
<div class="q-pa-md" align="center">
<q-btn-dropdown color="primary" :label="dropDownSelectedItem" size="20px">
<q-list>
<q-item clickable v-close-popup @click="dropDownSelectItem('team')">
<q-item :clickable="boolAlreadyInTeam" v-close-popup @click="dropDownSelectItem('team')" :disabled="!boolAlreadyInTeam">
<q-item-section>
<q-item-label v-html="teamName"></q-item-label>
</q-item-section>
@ -50,7 +50,7 @@
</q-item-section>
</q-item>
<q-item clickable v-close-popup :disabled="boolAlreadyInTeam"
<q-item :clickable="!boolAlreadyInTeam" v-close-popup :disabled="boolAlreadyInTeam"
@click="dropDownSelectItem('Neues Team erstellen')">
<q-item-section avatar>
<q-avatar icon="add" color="primary" text-color="white"/>
@ -298,15 +298,8 @@
this.data[0].userData = this.userName;
this.email = JSON.parse(localStorage.getItem('userMail'));
this.data[1].userData = this.email;
this.userRanking = 1234;
this.data[2].userData = this.userRanking;
//this.getPersonalRanking();
this.getTeamData();
this.teamName = "BuGa19Community";
this.data[3].userData = this.teamName;
this.dropDownSelectedItem = this.teamName;
this.teamRanking = 2019;
this.data[4].userData = this.teamRanking;
this.currentTeamStatus = "Dienstag 15:00 Treffen zum Blumencache";
},
methods: {
validateEmail(email) {
@ -314,25 +307,45 @@
return re.test(String(email).toLowerCase());
},
getPersonalRanking() {
let token = JSON.parse(localStorage.getItem('userToken')).token;
this.$axios.get('/api/getRankingPlace', {token})
let token;
if (localStorage.getItem('userToken')) {
token = JSON.parse(localStorage.getItem('userToken')).token;
} else {
return;
}
this.$axios.get('/api/getRankingPlace', {params: {token}})
.then((response) => {
this.userRanking = response.data;
console.log(response.data);
this.data[2].userData = this.userRanking;
}).catch((error) => {
this.handleError(error);
})
},
getTeamData() {
let token = JSON.parse(localStorage.getItem('userToken')).token;
this.$axios.get('/api/getTeamOfUser', {token})
let token;
if (localStorage.getItem('userToken')) {
token = JSON.parse(localStorage.getItem('userToken')).token;
} else {
return;
}
this.$axios.get('/api/getTeamOfUser', {params: {token}})
.then(response => {
this.teamName = response.data;
if (this.teamName.length >= 3) {
if (response.data.trim() === '') {
this.boolAlreadyInTeam = false;
this.teamName = "Aktuell in keinem Team";
this.currentTeamStatus = "";
this.teamRanking = "-";
} else {
this.boolAlreadyInTeam = true;
this.teamName = response.data;
this.currentTeamStatus = response.data.teamStatus;
this.teamRanking = response.data.teamRanking;
}
this.data[3].userData = this.teamName;
this.dropDownSelectedItem = this.teamName;
this.data[4].userData = this.teamRanking;
console.log("getTeam: " + response);
this.currentTeamStatus = response.data.teamStatus;
}).catch((error) => {
this.handleError(error);
})

View File

@ -1041,6 +1041,7 @@ public class Controller {
@ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification")
})
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping(value = "/api/getTeamOfUser", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity getTeamOfUser(@RequestParam String token){