Merge branch 'develop' into frontend/timo2

# Conflicts:
#	frontend/src/pages/MyCaches.vue
This commit is contained in:
Timo Volkmann 2019-05-10 11:22:06 +02:00
commit 8857f886d9
10 changed files with 418 additions and 146 deletions

View File

@ -23,6 +23,7 @@ dependencies {
runtimeOnly 'org.springframework.boot:spring-boot-devtools' runtimeOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'mysql:mysql-connector-java' runtimeOnly 'mysql:mysql-connector-java'
testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.boot:spring-boot-starter-test'
compile 'org.springframework.boot:spring-boot-starter-web'
//JPA //JPA
compile 'org.springframework.boot:spring-boot-starter-data-jpa' compile 'org.springframework.boot:spring-boot-starter-data-jpa'
@ -40,7 +41,7 @@ dependencies {
compile 'org.springframework.boot:spring-boot-starter-tomcat' compile 'org.springframework.boot:spring-boot-starter-tomcat'
//compile 'org.springframework.boot:spring-boot-starter-security' //compile 'org.springframework.boot:spring-boot-starter-security'
compile 'org.springframework.boot:spring-boot-starter-actuator' //compile 'org.springframework.boot:spring-boot-starter-actuator'
//compile 'org.springframework.boot:spring-boot-starter-aop' //compile 'org.springframework.boot:spring-boot-starter-aop'
//ompile group: 'org.springframework.boot', name: 'spring-boot-starter-mail', version: '1.2.0.RELEASE' //ompile group: 'org.springframework.boot', name: 'spring-boot-starter-mail', version: '1.2.0.RELEASE'

View File

@ -101,7 +101,7 @@ module.exports = function (ctx) {
// extractCSS: false, // extractCSS: false,
//distDir: 'springwebdir/{ctx.modeName}', //distDir: 'springwebdir/{ctx.modeName}',
distDir: '../src/main/resources/public/', distDir: '../src/main/resources/public/',
extendWebpack (cfg) { extendWebpack(cfg) {
cfg.module.rules.push({ cfg.module.rules.push({
enforce: 'pre', enforce: 'pre',
test: /\.(js|vue)$/, test: /\.(js|vue)$/,
@ -112,12 +112,12 @@ module.exports = function (ctx) {
env: ctx.dev env: ctx.dev
? { // Base URL for API-Calls: DEV ? { // Base URL for API-Calls: DEV
API: JSON.stringify('http://localhost:8080'), 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:9443/buga19geocaching'),
USER_API: JSON.stringify('https://seserver.se.hs-heilbronn.de:9443/buga19usermanagement') USER_API: JSON.stringify('https://seserver.se.hs-heilbronn.de:9443/buga19usermanagement')
} }
: { // Base URL for API-Calls: PRODUCTION (build) : { // Base URL for API-Calls: PRODUCTION (build)
API: JSON.stringify('http://localhost:8080'), //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:9443/buga19geocaching'),
USER_API: JSON.stringify('https://seserver.se.hs-heilbronn.de:9443/buga19usermanagement') USER_API: JSON.stringify('https://seserver.se.hs-heilbronn.de:9443/buga19usermanagement')
} }
}, },
@ -183,7 +183,7 @@ module.exports = function (ctx) {
electron: { electron: {
// bundler: 'builder', // or 'packager' // bundler: 'builder', // or 'packager'
extendWebpack (cfg) { extendWebpack(cfg) {
// do something with Electron main process Webpack cfg // do something with Electron main process Webpack cfg
// chainWebpack also available besides this extendWebpack // chainWebpack also available besides this extendWebpack
}, },

View File

@ -35,7 +35,8 @@
<div class="q-pa-md" align="center"> <div class="q-pa-md" align="center">
<q-btn-dropdown color="primary" :label="dropDownSelectedItem" size="20px"> <q-btn-dropdown color="primary" :label="dropDownSelectedItem" size="20px">
<q-list> <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-section>
<q-item-label v-html="teamName"></q-item-label> <q-item-label v-html="teamName"></q-item-label>
</q-item-section> </q-item-section>
@ -50,46 +51,101 @@
</q-item-section> </q-item-section>
</q-item> </q-item>
<q-item clickable v-close-popup @click="dropDownSelectItem('Neues Team erstellen')"> <q-item :clickable="!boolAlreadyInTeam" v-close-popup :disabled="boolAlreadyInTeam"
@click="dropDownSelectItem('Neues Team erstellen')">
<q-item-section avatar> <q-item-section avatar>
<q-avatar icon="add" color="primary" text-color="white"/> <q-avatar icon="add" color="primary" text-color="white"/>
</q-item-section> </q-item-section>
<q-item-section> <q-item-section>
<q-item-label>Neues Team erstellen</q-item-label> <q-item-label v-show="!boolAlreadyInTeam">Neues Team erstellen</q-item-label>
<q-item-label v-show="boolAlreadyInTeam">Neues Team erstellen<br/>(Team verlassen um Option zu
nutzen)
</q-item-label>
</q-item-section> </q-item-section>
</q-item> </q-item>
</q-list> </q-list>
</q-btn-dropdown> </q-btn-dropdown>
</div> </div>
<p class="text-h5"> Teammitglieder </p> <div v-show="boolMyTeam">
<q-table <p class="text-h5"> Teammitglieder </p>
:data="teamData" <q-table
:columns="teamColumns" :data="teamData"
row-key="name" :columns="teamColumns"
table-class="my-custom" row-key="name"
hide-bottom table-class="my-custom"
:pagination.sync="pagination" hide-bottom
/> :pagination.sync="pagination"
<br/> />
<p class="text-h5"> Einladungen </p> <br/>
<q-input outlined filled stack-label v-model="inviteMail" <p class="text-h5"> Einladungen </p>
type="text" label="Email des Nutzers" <q-input lazy-rules outlined filled stack-label v-model="inviteMail"
:rules="[val=>validateEmail(val)||'Bitte Email verwenden']"/> type="text" label="Email des Nutzers"
<div align="center"> :rules="[val=>validateEmail(val)||'Bitte Email verwenden']"/>
<q-btn label="Einladung versenden" <div align="center">
color="primary" <q-btn label="Einladung versenden"
type="submit"/> @click="sendTeamInvite()"
:disabled="!teamInviteChecked"
color="primary"
type="submit"/>
</div>
<br/>
<p class="text-h5"> Teamstatus </p>
<p>{{currentTeamStatus}}</p>
<q-input lazy-rules outlined filled stack-label v-model="teamStatus"
type="text" label="Neuer Teamstatus"
:rules="[val=>val.length<=160||'Status zu lang!']"/>
<div align="center">
<q-btn label="Teamstatus aktualisieren"
:disabled="!teamStatusChecked"
@click="setTeamStatus()"
color="primary"
type="submit"/>
</div>
<br/>
<q-input lazy-rules outlined filled stack-label v-model="leaveTeamCheck"
type="text" label="BESTÄTIGEN eingeben um das Team zu verlassen"
:rules="[val=>val==='BESTÄTIGEN'||'Schreibweise beachten']"/>
<div align="center">
<q-btn label="Team verlassen"
:disabled="!leaveConfirmed"
@click="leaveTeam()"
color="negative"
type="submit"/>
</div>
</div> </div>
<br/> <div v-show="boolInvites">
<p class="text-h5"> Teamstatus </p> <q-list>
<p>{{currentTeamStatus}}</p> <q-card class="q-mb-md" v-for="teamInvite in teamInvites" :key="teamInvite.id">
<q-input outlined filled stack-label v-model="teamStatus" <q-expansion-item
type="text" label="Neuer Teamstatus" class=""
:rules="[val=>val.length<=160||'Status zu lang!']"/> expand-icon-toggle
<div align="center"> expand-separator
<q-btn label="Teamstatus aktualisieren" icon="group"
color="primary" :label="teamInvite.team.name"
type="submit"/> :caption="teamInvite.team.teamStatus"
>
<q-item class="q-pr-sm reverse q-gutter-x-sm">
<q-btn @click="joinTeam(teamInvite)" unelevated color="positive" stack icon="arrow_forward"
label="Anfrage annehmen" size="sm"/>
<q-btn @click="deleteTeamInvite(teamInvite)" unelevated color="negative" stack icon="delete"
label="Anfrage ablehnen" size="sm"/>
</q-item>
</q-expansion-item>
</q-card>
</q-list>
</div>
<div v-show="boolCreateTeam">
<q-input lazy-rules outlined filled stack-label v-model="newTeamName" type="text"
label="Teamname eingeben"
:rules="[val=>val.length>=2||'Name muss mindestens 5 Zeichen lang sein!']"/>
<q-btn
:disabled="!newTeamNameValidationSuccesful"
label="Team anlegen"
color="primary"
class="full-width"
@click="createTeam()"
unelevated
/>
</div> </div>
</q-tab-panel> </q-tab-panel>
@ -119,15 +175,23 @@
data() { data() {
return { return {
tab: 'profile', tab: 'profile',
startedCaches: [],
inviteMail: "", inviteMail: "",
currentTeamStatus: "Dienstag 15:00 Treffen zum Blumencache", currentTeamStatus: "",
teamStatus: "", teamStatus: "",
userName: "",
email: null, email: null,
userRanking: null, userRanking: null,
teamName: null, teamName: null,
boolAlreadyInTeam: false,
teamRanking: null, teamRanking: null,
dropDownSelectedItem: null, dropDownSelectedItem: null,
boolMyTeam: true,
boolInvites: false,
boolCreateTeam: false,
newTeamName: "",
leaveTeamCheck: "",
teamMembers: [],
teamInvites: [],
columns: [ columns: [
{ {
name: 'desc', name: 'desc',
@ -144,6 +208,10 @@
} }
], ],
data: [ data: [
{
name: 'Benutzername',
userData: this.userName,
},
{ {
name: 'E-Mail', name: 'E-Mail',
userData: this.email, userData: this.email,
@ -170,43 +238,25 @@
field: row => row.name, field: row => row.name,
format: val => `${val}`, format: val => `${val}`,
}, },
{
name: 'email',
label: 'Email',
required: true,
align: 'left',
field: 'email',
},
{ {
name: 'ranking', name: 'ranking',
label: 'Solo-Ranglistenpunkte', label: 'Rangliste (Solo)',
required: true, required: true,
align: 'left', align: 'left',
field: 'ranking', field: 'ranking',
sortable: true, sortable: true,
} }
], ],
teamData: [ teamData: [],
{
name: 'BuGaCacher2019',
ranking: 10,
},
{
name: 'Max',
ranking: 5,
},
{
name: 'Timo',
ranking: 4,
},
{
name: 'Katharina',
ranking: 3,
},
{
name: 'Michael',
ranking: 2,
},
{
name: 'Robin',
ranking: 1,
},
],
pagination: { pagination: {
sortBy: 'name', sortBy: 'ranking',
descending: false, descending: false,
page: 1, page: 1,
rowsPerPage: 10 rowsPerPage: 10
@ -220,19 +270,41 @@
hasAdminState() { hasAdminState() {
return this.$store.getters['auth/GET_ADMINSTATE']; return this.$store.getters['auth/GET_ADMINSTATE'];
}, },
newTeamNameValidationSuccesful() {
if (this.newTeamName.length >= 5) {
return true;
}
return false;
},
teamInviteChecked() {
if (this.validateEmail(this.inviteMail)) {
return true;
}
return false;
},
teamStatusChecked() {
if (this.teamStatus.length <= 160) {
return true;
}
return false;
},
leaveConfirmed() {
if (this.leaveTeamCheck === 'BESTÄTIGEN'){
return true;
}
return false;
}
}, },
created: function () { created: function () {
this.$store.commit('auth/SET_AUTHENTICATED'); this.$store.commit('auth/SET_AUTHENTICATED');
this.$store.commit('auth/SET_USER'); 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.email = JSON.parse(localStorage.getItem('userMail'));
this.data[0].userData = this.email; this.data[1].userData = this.email;
this.userRanking = "1234"; this.getPersonalRanking();
this.data[1].userData = this.userRanking; this.getTeamData();
this.teamName = "BuGa19Community"; this.fetchTeamInvites();
this.data[2].userData = this.teamName;
this.dropDownSelectedItem = this.teamName;
this.teamRanking = "2019";
this.data[3].userData = this.teamRanking;
}, },
methods: { methods: {
validateEmail(email) { validateEmail(email) {
@ -240,72 +312,243 @@
return re.test(String(email).toLowerCase()); return re.test(String(email).toLowerCase());
}, },
getPersonalRanking() { getPersonalRanking() {
const name = JSON.parse(localStorage.getItem('userToken')).name; let email = this.email;
console.log(JSON.parse(localStorage.getItem('userToken')).name); this.$axios.get('/api/getRankingPlace', {params: {email}})
this.$axios.get('/api/hello', {params: {name}})
.then((response) => { .then((response) => {
this.userRanking = response.data; this.userRanking = response.data;
console.log(response.data); this.data[2].userData = this.userRanking;
}).catch((error) => { }).catch((error) => {
// Error this.handleError(error);
let msg;
let title;
if (error.response) {
// The request was made and the server responded with a status code
title = "Problem with response!";
msg = error.response;
} else if (error.request) {
// The request was made but no response was received
title = "Problem with request!";
msg = "Error occured due to wrong server request!"
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
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,});
}) })
}, },
getTeamData() { getTeamData() {
const userName = {name: JSON.parse(localStorage.getItem('userToken')).name}; let token;
this.$axios.get('/api/getTeam', {params: userName}) if (localStorage.getItem('userToken')) {
token = JSON.parse(localStorage.getItem('userToken')).token;
} else {
return;
}
this.$axios.get('/api/getTeamOfUser', {params: {token}})
.then(response => { .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.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); console.log("getTeam: " + response);
}).catch((error) => { }).catch((error) => {
// Error this.handleError(error);
let msg;
let title;
if (error.response) {
// The request was made and the server responded with a status code
title = "Problem with response!";
msg = error.response;
} else if (error.request) {
// The request was made but no response was received
title = "Problem with request!";
msg = "Error occured due to wrong server request!"
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
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,});
}) })
}, },
dropDownSelectItem(item) { dropDownSelectItem(item) {
if (item === 'team') { if (item === 'team') {
this.dropDownSelectedItem = this.teamName; 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 { } else {
this.dropDownSelectedItem = item; this.dropDownSelectedItem = item;
this.boolMyTeam = false;
this.boolInvites = false;
this.boolCreateTeam = true;
} }
}, },
createTeam() {
let params = {};
if (localStorage.getItem('userToken')) {
params.token = JSON.parse(localStorage.getItem('userToken')).token;
} else {
return;
}
params.name = this.newTeamName;
this.$axios.post('/api/createTeam', null, {params})
.then((response) => {
console.log("createTeam: " + response);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
message: "Das Team " + this.newTeamName + " wurde erfolgreich erstellt!",
title: "Teamerstellung",
color: "blue"
});
}).catch((error) => {
this.handleError(error);
})
},
leaveTeam() {
let params = {};
if (localStorage.getItem('userToken')) {
params.token = JSON.parse(localStorage.getItem('userToken')).token;
} else {
return;
}
this.$axios.put('/api/leaveTeam', null, {params})
.then((response) => {
console.log("createTeam: " + response);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
message: "Dus hast das Team " + this.teamName + " verlassen!",
title: "Team verlassen",
color: "blue"
});
this.getTeamData();
}).catch((error) => {
this.handleError(error);
})
},
fetchTeamMembers() {
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);
})
},
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);
});
},
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);
})
},
joinTeam(teamInvite) {
let params = {};
if (localStorage.getItem('userToken')) {
params.token = JSON.parse(localStorage.getItem('userToken')).token;
} else {
return;
}
params.teamID = teamInvite.team.id;
this.$axios.put('/api/joinTeam', null, {params})
.then((response) => {
console.log(response.data);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
message: "Du bist dem Team " + teamInvite.team.name + " erfolgreich beigetreten!",
title: "Teambeitrittsanfrage",
color: "blue"
});
this.getTeamData();
}).catch((error) => {
this.handleError(error);
})
},
deleteTeamInvite(teamInvite) {
let params = {};
if (localStorage.getItem('userToken')) {
params.token = JSON.parse(localStorage.getItem('userToken')).token;
} else {
return;
}
params.teamInviteID = teamInvite.id;
this.$axios.delete('/api/deleteTeamInvite', {params})
.then((response) => {
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
message: "Du hast die Anfrage von Team " + teamInvite.team.name + " gelöscht!",
title: "Teambeitrittsanfrage",
color: "blue"
});
this.getTeamData();
}).catch((error) => {
this.handleError(error);
})
},
sendTeamInvite() {
let params = {};
if (localStorage.getItem('userToken')) {
params.token = JSON.parse(localStorage.getItem('userToken')).token;
} else {
return;
}
params.invitedUserEmail = this.inviteMail;
this.$axios.post('/api/sendTeamInvite', null, {params})
.then((response) => {
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
message: "Du hast " + params.invitedUserEmail + " eingeladen!",
title: "Einladung ins Team",
color: "blue"
});
}).catch((error) => {
this.handleError(error);
})
},
setTeamStatus() {
let params = {};
if (localStorage.getItem('userToken')) {
params.token = JSON.parse(localStorage.getItem('userToken')).token;
} else {
return;
}
params.teamStatus = this.teamStatus;
this.$axios.put('/api/setTeamStatus', null, {params})
.then((response) => {
this.getTeamData();
}).catch((error) => {
this.handleError(error);
})
},
handleError(error) {
// Error
let msg;
let title;
if (error.response) {
// The request was made and the server responded with a status code
title = "Problem with response!";
msg = error.response;
} else if (error.request) {
// The request was made but no response was received
title = "Problem with request!";
msg = "Error occured due to wrong server request!";
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
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,});
}
} }
} }
</script> </script>

View File

@ -3,6 +3,14 @@
<form class="register" autocomplete="off"> <form class="register" autocomplete="off">
<div class="q-pa-md"> <div class="q-pa-md">
<div class="column q-gutter-lg" style=""> <div class="column q-gutter-lg" style="">
<div class="col">
<div class="">
<div class="" style="max-width: 440px">
<q-input lazy-rules outlined filled stack-label v-model="user.name" type="text" label="Benutzername"
:rules="[val=>val.length>=2||'Name muss mindestens 2 Zeichen lang sein!']"/>
</div>
</div>
</div>
<div class="col"> <div class="col">
<div class=""> <div class="">
<div class="" style="max-width: 440px"> <div class="" style="max-width: 440px">
@ -63,6 +71,7 @@
data() { data() {
return { return {
user: { user: {
name: "",
email: "", email: "",
checkemail: "", checkemail: "",
password: "", password: "",
@ -72,7 +81,8 @@
}, },
computed: { computed: {
validationSuccesful() { validationSuccesful() {
if (this.validateEmail(this.user.email) if (this.user.name.length >= 2
&& this.validateEmail(this.user.email)
&& this.user.email === this.user.checkemail && this.user.email === this.user.checkemail
&& this.user.password.length >= 8 && this.user.password.length >= 8
&& this.user.password === this.user.checkpassword) { && this.user.password === this.user.checkpassword) {
@ -93,7 +103,7 @@
if (this.user.email === this.user.checkemail && this.user.password === this.user.checkpassword) { if (this.user.email === this.user.checkemail && this.user.password === this.user.checkpassword) {
const data = { const data = {
name: this.user.email, name: this.user.name,
password: this.user.password, password: this.user.password,
email: this.user.email, email: this.user.email,
roles: [ roles: [
@ -111,7 +121,7 @@
'Authorization': 'Bearer ' + token, 'Authorization': 'Bearer ' + token,
} }
}) })
.then((response) => { .then((response) => {
console.log(response.data); console.log(response.data);
if (response.status === 201) { if (response.status === 201) {
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
@ -121,20 +131,20 @@
}); });
this.autoLogin(); this.autoLogin();
} }
}) })
.catch((error) => { .catch((error) => {
let message; let message;
let header = "Unbekannter Fehler..."; let header = "Unbekannter Fehler...";
if (error.response) { if (error.response) {
console.log(error.response) console.log(error.response)
if (error.response.status === 409) { if (error.response.status === 409) {
message= "Die E-Mail-Adresse wird bereits verwendet!"; message= "Die E-Mail-Adresse wird bereits verwendet!";
header= "Anmeldedaten überprüfen!"; header= "Anmeldedaten überprüfen!";
} }
} else if (error.request) { } else if (error.request) {
console.log(error.request); console.log(error.request);
header = "Anfrage fehlgeschlagen!"; header = "Anfrage fehlgeschlagen!";
message = "Die Verbindung zum Server ist gestört. Versuchen Sie es später noch einmal."; message = "Die Verbindung zum Server ist gestört. Versuchen Sie es später noch einmal.";
} }
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: message, title: header}); this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: message, title: header});
}); });

View File

@ -1,7 +1,6 @@
package hhn.labsw.bugageocaching.controller; package hhn.labsw.bugageocaching.controller;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.mashape.unirest.http.exceptions.UnirestException;
import hhn.labsw.bugageocaching.entities.*; import hhn.labsw.bugageocaching.entities.*;
import hhn.labsw.bugageocaching.helper.POI; import hhn.labsw.bugageocaching.helper.POI;
import hhn.labsw.bugageocaching.helper.RankingListHelper; import hhn.labsw.bugageocaching.helper.RankingListHelper;
@ -602,15 +601,17 @@ public class Controller {
int i = 0; int i = 0;
// zählt teammitglieder // zählt teammitglieder
for (User_Info userInfo1 : user_infoRepository.findAll()) { List<User_Info> user_infos = user_infoRepository.findByTeam(team);
/*for (User_Info userInfo1 : user_infoRepository.findAll()) {
if (userInfo1.getTeam().equals(team)) { if (userInfo1.getTeam().equals(team)) {
i++; i++;
} }
} }*/
// wenn maximalanzahl der teammitglieder erreicht... // wenn maximalanzahl der teammitglieder erreicht...
if (i >= 10) { if (user_infos.size() >= 10) {
return ResponseEntity.status(400).body("The team already has 10 members"); return ResponseEntity.status(400).body("The team already has 10 members");
} }
@ -618,6 +619,8 @@ public class Controller {
user_info.setTeam(team); user_info.setTeam(team);
user_infoRepository.save(user_info); user_infoRepository.save(user_info);
TeamInvite teamInvite = teamInviteRepository.findByUserAndTeam(user, team);
teamInviteRepository.delete(teamInvite);
return ResponseEntity.status(200).body(new Gson().toJson(team)); return ResponseEntity.status(200).body(new Gson().toJson(team));
} }
@ -784,13 +787,20 @@ public class Controller {
User user = (User) getUser.getBody(); User user = (User) getUser.getBody();
List<TeamInvite> teamInvitesList = new ArrayList<>(); List<TeamInvite> teamInvitesList = teamInviteRepository.findByUser(user);
for (TeamInvite teamInvite : teamInviteRepository.findAll()) { for (TeamInvite tmp : teamInvitesList){
tmp.setUser(null);
}
/*for (TeamInvite teamInvite : teamInviteRepository.findAll()) {
if (teamInvite.getUser() == user) { if (teamInvite.getUser() == user) {
teamInvitesList.add(teamInvite); teamInvitesList.add(teamInvite);
} }
} }+/
*/
return ResponseEntity.status(200).body(new Gson().toJson(teamInvitesList)); return ResponseEntity.status(200).body(new Gson().toJson(teamInvitesList));
} }
@ -950,7 +960,7 @@ public class Controller {
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getRankingPlace", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/getRankingPlace", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity getRankingPlace(@RequestParam String email) { public ResponseEntity getRankingPlace(@RequestParam String email) {
return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(email)); return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(email));
@ -1028,6 +1038,7 @@ public class Controller {
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @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") @RequestMapping(value = "/api/getTeamOfUser", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity getTeamOfUser(@RequestParam String token) { public ResponseEntity getTeamOfUser(@RequestParam String token) {

View File

@ -6,6 +6,9 @@ import hhn.labsw.bugageocaching.entities.TeamInvite;
import hhn.labsw.bugageocaching.entities.User; import hhn.labsw.bugageocaching.entities.User;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface TeamInviteRepository extends JpaRepository<TeamInvite, Integer> { public interface TeamInviteRepository extends JpaRepository<TeamInvite, Integer> {
TeamInvite findByUserAndTeam(User user, Team team); TeamInvite findByUserAndTeam(User user, Team team);
List<TeamInvite> findByUser(User user);
} }

View File

@ -15,9 +15,9 @@ public interface TeamRepository extends JpaRepository<Team, Integer> {
@Query(value = "SELECT *\n" + @Query(value = "SELECT *\n" +
"FROM user\n" + "FROM user\n" +
"WHERE id IN (\n" + "WHERE id IN (\n" +
" SELECT user_id\n" + "SELECT user_id\n" +
" FROM user_info\n" + "FROM user_info\n" +
" WHERE team_id = (SELECT team_id FROM team WHERE name = ?1))", nativeQuery = true) "WHERE team_id = (SELECT team.id FROM team WHERE name = ?1));", nativeQuery = true)
List<Object[]> getTeammembers(String name); List<Object[]> getTeammembers(String name);

View File

@ -9,7 +9,7 @@ import java.util.List;
public interface UserRepository extends CrudRepository<User, Integer> { public interface UserRepository extends CrudRepository<User, Integer> {
User findByEmail(String email); User findByEmail(String email);
@Query(value = "SELECT DISTINCT u.id AS ID, SUBSTRING_INDEX(u.email, '@', 1) AS Name, ui.ranking_points_sum AS Ranglistenpunkte\n" + @Query(value = "SELECT DISTINCT u.id AS ID, username AS Name, ui.ranking_points_sum AS Ranglistenpunkte\n" +
"FROM user u,\n" + "FROM user u,\n" +
" user_info ui,\n" + " user_info ui,\n" +
" user_roles ur\n" + " user_roles ur\n" +

View File

@ -1,5 +1,6 @@
package hhn.labsw.bugageocaching.repositories; package hhn.labsw.bugageocaching.repositories;
import hhn.labsw.bugageocaching.entities.Team;
import hhn.labsw.bugageocaching.entities.User; import hhn.labsw.bugageocaching.entities.User;
import hhn.labsw.bugageocaching.entities.User_Info; import hhn.labsw.bugageocaching.entities.User_Info;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
@ -10,4 +11,5 @@ import java.util.Optional;
public interface User_InfoRepository extends CrudRepository<User_Info, Integer> { public interface User_InfoRepository extends CrudRepository<User_Info, Integer> {
User_Info findUser_InfoByUser(User user); User_Info findUser_InfoByUser(User user);
List<User_Info> findByTeam(Team team);
} }

View File

@ -1,5 +1,6 @@
package hhn.labsw.bugageocaching.util; package hhn.labsw.bugageocaching.util;
import com.google.gson.Gson;
import hhn.labsw.bugageocaching.entities.*; import hhn.labsw.bugageocaching.entities.*;
import hhn.labsw.bugageocaching.repositories.*; import hhn.labsw.bugageocaching.repositories.*;
import io.jsonwebtoken.Claims; import io.jsonwebtoken.Claims;
@ -181,11 +182,12 @@ public class FinderUtil {
list) { list) {
User tmp = new User(); User tmp = new User();
tmp.setUsername((String) obj[3]); tmp.setUsername((String) obj[3]);
tmp.setEmail((String) obj[1]);
sendBack.add(tmp); sendBack.add(tmp);
} }
return ResponseEntity.status(200).body(list); return ResponseEntity.status(200).body(new Gson().toJson(sendBack));
} else { } else {
return ResponseEntity.status(404).body("Couldnt find Team member of Team " + name); return ResponseEntity.status(404).body("Couldnt find Team member of Team " + name);
} }