Merge branch 'develop' into frontend/timo_neu

This commit is contained in:
Timo Volkmann 2019-06-19 12:29:53 +02:00
commit 43d6cc7909
11 changed files with 2001 additions and 130 deletions

View File

@ -1,6 +1,7 @@
plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
id 'java'
id 'org.asciidoctor.jvm.convert' version '2.2.0'
}
apply plugin: 'io.spring.dependency-management'
@ -13,6 +14,8 @@ sourceCompatibility = '1.8'
repositories {
mavenCentral()
jcenter()
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/' }
}
bootWar{
@ -73,6 +76,6 @@ dependencies {
testCompile group: 'junit', name: 'junit', version: '4.+'
compile "io.github.swagger2markup:swagger2markup:1.3.1"
}

View File

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac"/>
<resourceExtensions>
<entry name=".+\.(properties|xml|html|dtd|tld)"/>
<entry name=".+\.(gif|png|jpeg|jpg)"/>
</resourceExtensions>
<wildcardResourcePatterns>
<entry name="!?*.class"/>
<entry name="!?*.scala"/>
<entry name="!?*.groovy"/>
<entry name="!?*.java"/>
</wildcardResourcePatterns>
<annotationProcessing enabled="false" useClasspath="true"/>
<bytecodeTargetLevel target="1.8"/>
</component>
<component name="CopyrightManager" default="">
<module2copyright/>
</component>
<component name="DependencyValidationManager">
<option name="SKIP_IMPORT_STATEMENTS" value="false"/>
</component>
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false"/>
<component name="GradleUISettings">
<setting name="root"/>
</component>
<component name="GradleUISettings2">
<setting name="root"/>
</component>
<component name="IdProvider" IDEtalkID="11DA1DB66DD62DDA1ED602B7079FE97C"/>
<component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY"/>
<option name="OPTION_SCOPE" value="protected"/>
<option name="OPTION_HIERARCHY" value="true"/>
<option name="OPTION_NAVIGATOR" value="true"/>
<option name="OPTION_INDEX" value="true"/>
<option name="OPTION_SEPARATE_INDEX" value="true"/>
<option name="OPTION_DOCUMENT_TAG_USE" value="false"/>
<option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false"/>
<option name="OPTION_DOCUMENT_TAG_VERSION" value="false"/>
<option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true"/>
<option name="OPTION_DEPRECATED_LIST" value="true"/>
<option name="OTHER_OPTIONS" value=""/>
<option name="HEAP_SIZE"/>
<option name="LOCALE"/>
<option name="OPEN_IN_BROWSER" value="true"/>
</component>
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/labswp_2019_sose_geocaching.iml" filepath="$PROJECT_DIR$/labswp_2019_sose_geocaching.iml"/>
</modules>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="false" jdk-15="true" project-jdk-type="JavaSDK" assert-jdk-15="false" project-jdk-name="1.10">
<output url="file://$PROJECT_DIR$/out"/>
</component>
<component name="SvnBranchConfigurationManager">
<option name="mySupportsUserInfoFilter" value="true"/>
</component>
<component name="VcsDirectoryMappings">
<mapping directory="" vcs=""/>
</component>
<component name="masterDetails">
<states>
<state key="ArtifactsStructureConfigurable.UI">
<UIState>
<splitter-proportions>
<SplitterProportionsDataImpl/>
</splitter-proportions>
<settings/>
</UIState>
</state>
<state key="Copyright.UI">
<UIState>
<splitter-proportions>
<SplitterProportionsDataImpl/>
</splitter-proportions>
</UIState>
</state>
<state key="ProjectJDKs.UI">
<UIState>
<splitter-proportions>
<SplitterProportionsDataImpl>
<option name="proportions">
<list>
<option value="0.2"/>
</list>
</option>
</SplitterProportionsDataImpl>
</splitter-proportions>
<last-edited>1.6</last-edited>
</UIState>
</state>
<state key="ScopeChooserConfigurable.UI">
<UIState>
<splitter-proportions>
<SplitterProportionsDataImpl/>
</splitter-proportions>
<settings/>
</UIState>
</state>
</states>
</component>
</project>

View File

@ -9,7 +9,7 @@
<vl-geom-point :coordinates="[lon, lat]"></vl-geom-point>
<vl-style-box>
<vl-style-icon src="./statics/map-marker.svg" :scale="2.0" :anchor="[0.5, 1]"></vl-style-icon>
<vl-style-icon src="./statics/map-marker_red.svg" :scale="2.0" :anchor="[0.5, 1]"></vl-style-icon>
</vl-style-box>
</template>
</vl-feature>
@ -87,6 +87,7 @@ Vue.use(VueLayers);
this.stationID = cache.stationen[0];
this.lon = this.stationID.longitude;
this.lat = this.stationID.lattitude;
this.center = [this.lon, this.lat]
})
},
checkStation() {

View File

@ -32,6 +32,7 @@
<q-input lazy-rules outlined filled stack-label v-model="newTeamName"
type="text"
label="Teamname eingeben"
color="black"
:rules="[val=>val.length>=2||'Name muss mindestens 5 Zeichen lang sein!']"/>
<q-btn
:disabled="!newTeamNameValidationSuccesful"
@ -64,18 +65,20 @@
</q-expansion-item>
</q-card>
</q-list>
<!--<div v-show="hasAdminState">-->
<!--<p class="text-h5 q-mt-sm"> Neuen Admin hinzufügen </p>-->
<!--<q-input lazy-rules outlined filled stack-label v-model="newAdminMail"-->
<!--type="text" label="Email des Nutzers" class="col-9"-->
<!--:rules="[val=>validateEmail(val)||'Bitte Email verwenden']"/>-->
<!--<q-btn class="col-3"-->
<!--icon="arrow_right_alt"-->
<!--@click="getUser()"-->
<!--:disabled="!adminInviteChecked"-->
<!--color="positive"-->
<!--type="submit"/>-->
<!--</div>-->
<p class="text-h5 q-pt-lg" v-show="hasAdminState"> Nutzer zu Administrator befördern </p>
<div v-show="hasAdminState" align="center" class="row q-mt-sm justify-between">
<q-input lazy-rules outlined filled stack-label v-model="newAdminMail"
type="text" label="Email des Nutzers" color="black" class="col q-mr-sm"
:rules="[val=>validateEmail(val)||'Bitte Email verwenden']"/>
<div class="row" style="padding-bottom: 20px">
<q-btn label="Nutzer befördern"
unelevated
@click="getUser()"
:disabled="!adminInviteChecked"
color="primary"
type="submit"/>
</div>
</div>
</div>
</q-tab-panel>
<q-tab-panel v-if="boolAlreadyInTeam" name="teams" class="q-pa-none">
@ -191,6 +194,7 @@
boolStatus: false,
boolTable: true,
boolMemberTableUpdating: false,
newAdminMail: "",
teamColumns: [
{
name: 'desc',
@ -216,7 +220,6 @@
page: 1,
rowsPerPage: 10
},
// newAdminMail: "",
}
},
mounted: function () {
@ -279,6 +282,20 @@
}).onDismiss(() => {
})
},
confirmAddAdmin(newAdmin) {
this.$q.dialog({
title: 'Administrator hinzufügen',
message: 'Willst du den Nutzer ' + newAdmin.name + ' mit der Email ' + newAdmin.email + ' wirklich zum Administrator befördern?',
persistent: true,
cancel: true,
}).onOk(() => {
console.log('>>>> OK');
this.addAdmin(newAdmin);
}).onCancel(() => {
console.log('>>>> Cancel')
}).onDismiss(() => {
})
},
activateInvite() {
if (this.inviteActivated) {
this.inviteActivated = false;
@ -516,73 +533,69 @@
});
this.updateStatus();
},
// getUser() {
// const data = {
// "email" : this.newAdminMail
// }
// JSON.stringify(data);
// const token = JSON.parse(localStorage.getItem('userToken')).token;
// this.$axios.get(process.env.USER_API + '/account/email', data, {
// headers: {
// 'Authorization': 'Bearer ' + token,
// }
// }).then((response) => {
// let newAdminAccount = response.data;
// if (response.status === 200) {
// this.addAdmin(JSON.parse(response).data);
// }
// })
// .catch((error) => {
// let message;
// let header = "Unbekannter Fehler...";
// if (error.response) {
// console.log(error.response)
// if (error.response.status === 400) {
// message = "Es gibt keinen Nutzer mit dieser Email!";
// header = "Email überprüfen!";
// }
// } else if (error.request) {
// console.log(error.request);
// header = "Anfrage fehlgeschlagen!";
// 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});
// });
// },
// addAdmin(newAdmin) {
// const token = JSON.parse(localStorage.getItem('userToken')).token;
// newAdmin.roles.role = "ADMIN";
// JSON.stringify(newAdmin);
// this.$axios.patch(process.env.USER_API, '/account', newAdmin, {
// headers: {
// 'Authorization': 'Bearer ' + token,
// }
// }).then((response) => {
// if (response.status === 200) {
// this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
// message: "Du hast den Nutzer mit der Email " + this.newAdminMail + " als Admin freigeschalten!",
// title: "Nutzerverwaltung",
// color: "blue"
// });
// }
// })
// .catch((error) => {
// let message;
// let header = "Unbekannter Fehler...";
// if (error.response) {
// console.log(error.response)
// if (error.response.status === 400) {
// message = JSON.parse(error).error;
// header = "Probleme mit dem zu bearbeitenden Nutzeraccount!";
// }
// } else if (error.request) {
// console.log(error.request);
// header = "Anfrage fehlgeschlagen!";
// 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});
// });
// },
getUser() {
const token = JSON.parse(localStorage.getItem('userToken')).token;
this.$axios.get(process.env.USER_API + '/account/email/' + this.newAdminMail, {
headers: {
'Authorization': 'Bearer ' + token,
}
}).then((response) => {
let newAdminAccount = response.data;
if (response.status === 200) {
this.confirmAddAdmin(response.data);
}
})
.catch((error) => {
let message;
let header = "Unbekannter Fehler...";
if (error.response) {
console.log(error.response)
if (error.response.status === 400) {
message = "Es gibt keinen Nutzer mit dieser Email!";
header = "Email überprüfen!";
}
} else if (error.request) {
console.log(error.request);
header = "Anfrage fehlgeschlagen!";
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});
});
},
addAdmin(newAdmin) {
const token = JSON.parse(localStorage.getItem('userToken')).token;
newAdmin.roles.role = "ADMIN";
JSON.stringify(newAdmin);
this.$axios.patch(process.env.USER_API, '/account', newAdmin, {
headers: {
'Authorization': 'Bearer ' + token,
}
}).then((response) => {
if (response.status === 200) {
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
message: "Du hast den Nutzer mit der Email " + this.newAdminMail + " als Admin freigeschalten!",
title: "Nutzerverwaltung",
color: "blue"
});
}
})
.catch((error) => {
let message;
let header = "Unbekannter Fehler...";
if (error.response) {
console.log(error.response)
if (error.response.status === 400) {
message = JSON.parse(error).error;
header = "Probleme mit dem zu bearbeitenden Nutzeraccount!";
}
} else if (error.request) {
console.log(error.request);
header = "Anfrage fehlgeschlagen!";
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});
});
},
handleError(error) {
let msg;
let title;

View File

@ -98,7 +98,7 @@
methods: {
validateEmail(email) {
//var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
let re = new RegExp('^[a-zA-Z0-9.!#$%&\'*+/=?^_`{|}~-]+@[A-Z0-9.-]+\\.[A-Z]{2,}$');
let re = new RegExp('/^(([^<>()\\[\\]\\\\.,;:\\s@"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@"]+)*)|(".+"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/');
return re.test(String(email).toLowerCase());
},
register: function () {

View File

@ -4,12 +4,21 @@
data-projection="EPSG:4326" style="height: 200px" v-if="!cameraActive">
<vl-view :zoom.sync="zoom" :center.sync="center" :rotation.sync="rotation"></vl-view>
<vl-feature ref="marker" v-for="station in cache.stationen" :key="station.id">
<vl-feature ref="marker">
<template>
<vl-geom-point :coordinates="[station.longitude, station.lattitude]"></vl-geom-point>
<vl-style-box>
<vl-style-icon :src="getMarkerURL(station)" :scale="2.0" :anchor="[0.5, 1]"></vl-style-icon>
<vl-style-icon src="./statics/map-marker_red.svg" :scale="2.0" :anchor="[0.5, 1]"></vl-style-icon>
</vl-style-box>
</template>
</vl-feature>
<vl-feature ref="marker" v-for="station in filteredStations" :key="station.id">
<template>
<vl-geom-point :coordinates="[station.longitude, station.lattitude]"></vl-geom-point>
<vl-style-box>
<vl-style-icon src="./statics/map-marker_grey.svg" :scale="2.0" :anchor="[0.5, 1]"></vl-style-icon>
</vl-style-box>
</template>
</vl-feature>
@ -57,13 +66,14 @@ Vue.use(VueLayers);
stationen: [],
},
station: {},
markercolor: "red",
markercolor: "grey",
cameraActive: false,
result: null,
zoom: 15,
center: [ 9.208858198755664, 49.14785422283188],
rotation: 0,
geolocPosition: undefined,
filteredStations: [],
}
},
beforeRouteUpdate(to, from, next) {
@ -105,24 +115,28 @@ Vue.use(VueLayers);
},
methods: {
fetchData() {
this.$axios.get('/api/allCaches')
.then((response) => {
console.log("/api/allCaches");
console.log(response.data);
const cache = response.data.find(cache => cache.id === Number(this.$route.params.cache));
this.cache = cache;
this.station = cache.stationen.find(station => station.id === Number(this.$route.params.id));
this.cacheName = cache.name;
this.cacheID = this.$route.params.cache;
console.log(JSON.stringify(this.cache));
console.log(JSON.stringify(this.station));
console.log(this.cache);
if (localStorage.getItem('userToken')) {
let params = {cacheID: this.$route.params.cache};
params.token = JSON.parse(localStorage.getItem('userToken')).token;
this.$axios.get('/api/getCurrentStation',{params})
.then((response) => {
console.log("/api/getCurrentStation");
console.log(response.data);
const cache = response.data.cache;
this.cache = cache;
this.station = response.data.aktuelleStation;
this.cacheName = cache.name;
this.cacheID = this.$route.params.cache;
console.log(JSON.stringify(this.cache));
console.log(JSON.stringify(this.station));
console.log(this.cache);
let stationIndex = this.cache.stationen.findIndex(s => s.id === this.station.id);
for( let i=0; i< stationIndex; i++){
this.filteredStations.push(this.cache.stationen[i])
}
this.center = [this.station.longitude, this.station.lattitude]
})
},
getMarkerURL(station) {
console.log(station);
return `./statics/map-marker_${this.markercolor}.svg`
}
},
updateResult(event) {

View File

@ -24,11 +24,11 @@
<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 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 v-if="email === 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 v-if="email !== 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>
@ -39,19 +39,18 @@
<div class="column q-gutter-lg" style="">
<div v-if="hasAdminState" class="col">
<div class="">
<div class="" style="max-width: 440px">
<q-input lazy-rules outlined filled stack-label
type="text"
label="Username eingeben"
unelevated color="negative"
v-model="deleteUser"
></q-input>
</div>
<q-input lazy-rules outlined filled stack-label
type="text"
label="Email eingeben"
unelevated color="black"
v-model="deleteUser"
:rules="[val=>validateEmail(val)||'Bitte Email verwenden']"
></q-input>
</div>
</div>
<div v-if="hasAdminState" class="row">
<q-btn
label="Punkte des Nutzer zurücksetzen"
label="Punkte des Nutzers zurücksetzen"
color="negative"
class="full-width"
@click="resetPoints()"
@ -105,7 +104,8 @@
rankinglist: [],
teamRankinglist: [],
username: null,
deleteUser: null
deleteUser: null,
email: null,
}
},
created: function () {
@ -114,6 +114,7 @@
this.fetchRankinglist();
this.fetchTeamRankinglist();
this.username = JSON.parse(localStorage.getItem('userToken')).name;
this.email = JSON.parse(localStorage.getItem('userMail'));
},
computed: {
hasAdminState() {
@ -162,6 +163,7 @@
console.log(response.data);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
message: "Die Rangliste wurde erfolgreich zurückgesetzt",
title: "Zurücksetzen",
color: "blue"
});
this.$axios.get('/api/getRankingList', {params: {token}})
@ -186,18 +188,48 @@
// lastSum = ranking.rankingPointsSum;
// }
},
resetPoints(){
if(this.deleteUser != null){
resetPoints() {
if (this.deleteUser != null) {
let username = this.deleteUser;
let token = JSON.parse(localStorage.getItem('userToken')).token;
if (this.validateEmail(this.email)) {
console.log(this.validateEmail(this.email));
this.$axios.put('/api/resetSingleUser',null, {params: {token, username}})
.then((response) => {
console.log("Rankinglist: ");
console.log(response.data);
this.fetchRankinglist();
}).catch((error) => {
})
this.$axios.put('/api/resetSingleUser', null, {params: {token, username}})
.then((response) => {
console.log("Rankinglist: ");
console.log(response.data);
this.fetchRankinglist();
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
message: "Die Ranglistenpunkte des Benutzers wurden erfolgreich zurückgesetzt!",
title: "Zurücksetzen",
color: "blue"
});
}).catch((error) => {
let msg;
let title;
if (error.response) {
title = "Bitte Eingaben überprüfen!";
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,});
})
} else {
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
message: "Bitte geben Sie eine gültige Email ein",
title: "Ungültige Email",
color: "negative"
});
}
} else {
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
message: "Zum zurücksetzen der Punkte eines Nutzers gib bitte einen Usernamen ein",
@ -207,6 +239,11 @@
}
},
validateEmail(email) {
let re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
},
}
}
</script>

View File

@ -0,0 +1,18 @@
package hhn.labsw.bugageocaching;
import io.github.swagger2markup.Swagger2MarkupConverter;
import java.nio.file.Path;
import java.nio.file.Paths;
public class SwaggerMarkup {
public static void main(String[] args) {
Path localSwaggerFile = Paths.get("swagger.json");
Path outputDirectory = Paths.get("build/asciidoc");
Swagger2MarkupConverter.from(localSwaggerFile)
.build()
.toFolder(outputDirectory);
}
}

View File

@ -425,7 +425,7 @@ public class Controller {
for (RankingListHelper rankingListHelper: sendBackUsers) {
logger.debug("RankingList Helper " + rankingListHelper.getUsername());
logger.debug("User: " + user.getUsername());
if(rankingListHelper.getUsername().equals(user.getUsername())){
if(rankingListHelper.getUsername().equals(user.getEmail())){
userAlreadyInRankingList = true;
break;
}
@ -435,7 +435,7 @@ public class Controller {
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());
RankingListHelper rankingListHelper = new RankingListHelper(user.getEmail(), (Integer) user_infoRepository.findUser_InfoByUser(user).getRankingPointsSum(), (Integer) getRankingPlace(user.getEmail()).getBody());
logger.debug(String.valueOf((Integer) singlePlace.getBody()));
sendBackUsers.add(rankingListHelper);
}
@ -1323,7 +1323,12 @@ public class Controller {
if (isAdmin) {
User deleteUser = userRepository.findByUsername(username);
User deleteUser = userRepository.findByEmail(username);
if(deleteUser == null) {
return ResponseEntity.status(400).body("Es wurde kein User mit dieser Email gefunden.");
}
User_Info user_info = user_infoRepository.findUser_InfoByUser(deleteUser);
user_info.setRankingPointsSum(0);

View File

@ -20,7 +20,7 @@ public interface UserRepository extends CrudRepository<User, Integer> {
// "LIMIT 10;", nativeQuery = true)
// List<Object[]> getRankingList();
@Query(value = "SELECT DISTINCT u.id AS ID, username AS Name, ui.ranking_points_sum AS Ranglistenpunkte, email Email\n" +
@Query(value = "SELECT DISTINCT u.id AS ID, u.email AS Name, ui.ranking_points_sum AS Ranglistenpunkte, email Email\n" +
"FROM user u,\n" +
" user_info ui,\n" +
" user_roles ur\n" +

1676
swagger.json Normal file

File diff suppressed because it is too large Load Diff