Merge branch 'develop' into frontend/robin
This commit is contained in:
commit
1427e4dcd2
@ -62,6 +62,7 @@ module.exports = function (ctx) {
|
||||
'QPageSticky',
|
||||
'QAvatar',
|
||||
'QSpinnerPuff',
|
||||
'QSpinnerOval',
|
||||
'QExpansionItem',
|
||||
'QParallax',
|
||||
'QEditor',
|
||||
@ -107,7 +108,6 @@ module.exports = function (ctx) {
|
||||
API: JSON.stringify('http://localhost:8080')
|
||||
}
|
||||
: { // Base URL for API-Calls: PRODUCTION (build)
|
||||
//API: JSON.stringify('http://se.hs-heilbronn.de:8090')
|
||||
//API: JSON.stringify('http://seserver.se.hs-heilbronn.de:8090/buga19geocaching')
|
||||
API: JSON.stringify('http://localhost:8080')
|
||||
}
|
||||
|
||||
@ -1,53 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
|
||||
<qrcode-drop-zone @decode="onDecode" @init="logErrors">
|
||||
<qrcode-stream @decode="onDecode" @init="onInit" />
|
||||
</qrcode-drop-zone>
|
||||
|
||||
<qrcode-capture v-if="noStreamApiSupport" @decode="onDecode" />
|
||||
<p class="decode-result">Last result: <b>{{ result }}</b></p>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
//import { QrcodeStream, QrcodeDropZone, QrcodeCapture } from 'vue-qrcode-reader'
|
||||
|
||||
export default {
|
||||
name: 'qrscanner',
|
||||
data () {
|
||||
return {
|
||||
result: '',
|
||||
noStreamApiSupport: false
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
onDecode (result) {
|
||||
this.result = result
|
||||
},
|
||||
|
||||
logErrors (promise) {
|
||||
promise.catch(console.error)
|
||||
},
|
||||
|
||||
async onInit (promise) {
|
||||
try {
|
||||
await promise
|
||||
} catch (error) {
|
||||
if (error.name === 'StreamApiNotSupportedError') {
|
||||
this.noStreamApiSupport = true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// components: {
|
||||
// QrcodeStream,
|
||||
// QrcodeDropZone,
|
||||
// QrcodeCapture
|
||||
// }
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
52
frontend/src/pages/CacheEnd.vue
Normal file
52
frontend/src/pages/CacheEnd.vue
Normal file
@ -0,0 +1,52 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="q-ma-md">
|
||||
<p class="text-h4">{{ data.cacheName }}</p>
|
||||
<p class="text-h5">{{ end1 + data.cachePoints + end2 }}</p>
|
||||
|
||||
<div class="column q-gutter-y-md">
|
||||
<q-btn unelevated v-if="IsLoggedIn" color="primary" label="Zur Rangliste" to="/ranking/"/>
|
||||
<q-btn unelevated v-if="isLoggedIn" color="primary" label="Zur Belohnung" @click="reward = true">
|
||||
<q-dialog v-model="reward">
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<div class="text-h6">Jetzt ist eine gute Zeit, etwas Neues zu beginnen.</div>
|
||||
</q-card-section>
|
||||
</card>
|
||||
</q-dialog>
|
||||
<q-btn unelevated color="primary" label="Zur Startseite" to="/"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
reward: false,
|
||||
end1: "Gut gemacht, Du hast alle Stationen dieses Cache gefunden. Dir wurden ",
|
||||
end2: " Punkte gutgeschrieben." //TODO Punkte wirklich gutschreiben, ggf. Cache auf erledigt setzen
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isLoggedIn() {
|
||||
return this.$store.getters['auth/GET_ADMINSTATE']; //TODO Methode umschreiben
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fetchData() {
|
||||
this.$axios.get('/api/allCaches')
|
||||
.then((response) => {
|
||||
console.log("/api/allCaches");
|
||||
console.log(JSON.stringify(this.data));
|
||||
console.log(this.data);
|
||||
console.log(response.data);
|
||||
const cache = response.data.find(cache => cache.id === Number(this.$route.params.cache));
|
||||
this.data.cacheName = cache.name;
|
||||
this.data.cachePoints = cache.rankingPoints;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
74
frontend/src/pages/CacheStart.vue
Normal file
74
frontend/src/pages/CacheStart.vue
Normal file
@ -0,0 +1,74 @@
|
||||
<template>
|
||||
<div>
|
||||
<q-img transition="fade"
|
||||
class="q-mb-md "
|
||||
:ratio="16/9"
|
||||
src="https://www.buga2019.de/we-bilder/3.Gartenausstellung/Gelaendeplan/190320_Gelaendeplan-quadratisch.jpg"
|
||||
></q-img>
|
||||
<div class="q-ma-md">
|
||||
<p class="text-h4">{{ cacheName }}</p>
|
||||
<p>{{ instruction }}</p>
|
||||
|
||||
<div class="column q-gutter-y-md">
|
||||
<q-input stack-label filled v-model="code" label="Code eingeben (wird mit Code scannen ersetzt)"/>
|
||||
<q-btn @click="checkStation()" unelevated color="primary" label="QR-Code scannen (absenden)"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return { //TODO Lageplan einbinden
|
||||
cacheID: "",
|
||||
cacheName: "",
|
||||
code: "8/6",
|
||||
instruction: "Bitte begib Dich zu der auf der Karte angezeigten Position. An dieser Position wirst Du einen QR-Code finden. Wenn du ihn gefunden hast, drücke den Knopf zum Starten des QR-Scanners und gib uns die Berechtigung, Deine Kamera zu öffnen. Nachdem Du den QR-Code gescannt hast, erhältst du ein Rätsel zur Position der nächsten Station. Die Lösung zu dem Rätsel ist also das Versteck des nächsten QR-Codes."
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchData();
|
||||
},
|
||||
methods: {
|
||||
fetchData() {
|
||||
this.$axios.get('/api/allCaches')
|
||||
.then((response) => {
|
||||
console.log("/api/allCaches");
|
||||
console.log(JSON.stringify(this.data));
|
||||
console.log(this.data);
|
||||
console.log(response.data);
|
||||
const cache = response.data.find(cache => cache.id === Number(this.$route.params.cache));
|
||||
this.cacheName = cache.name;
|
||||
this.cacheID = this.$route.params.cache;
|
||||
})
|
||||
},
|
||||
checkStation() {
|
||||
let params = this.setParams();
|
||||
console.log(params);
|
||||
this.$axios.get('/api/checkStation', {params})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
console.log("Anfrage erfolgreich");
|
||||
|
||||
}) .catch((error) => {
|
||||
console.log(error);
|
||||
console.log("Anfrage fehlgeschlagen");
|
||||
})
|
||||
this.$router.push({path: `/station/${params.cacheID}/${params.stationID}`})
|
||||
},
|
||||
setParams() {
|
||||
console.log("setParams: ");
|
||||
let params = {};
|
||||
params.cacheID = this.code.split('/')[0];
|
||||
params.stationID = this.code.split('/')[1];
|
||||
params.durchgefuehrterCacheID = this.cacheID;
|
||||
console.log(params.cacheID + " und " + params.stationID);
|
||||
if (localStorage.getItem('userToken')) {
|
||||
params.token = JSON.parse(localStorage.getItem('userToken')).token;
|
||||
}
|
||||
return params;
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -188,7 +188,7 @@
|
||||
let stationID = this.caches.find(x => x.id === cacheID).stationen[0].id;
|
||||
console.log(stationID);
|
||||
//this.$router.push({path: `/station/${stationID}`})
|
||||
this.$router.push({path: `/station/${cacheID}/${stationID}`})
|
||||
this.$router.push({path: `/CacheStart/${cacheID}`})
|
||||
}).catch((error) => {
|
||||
// Error
|
||||
let msg;
|
||||
|
||||
@ -1,17 +1,151 @@
|
||||
<template>
|
||||
<!-- <q-page padding>-->
|
||||
<qrscanner />
|
||||
<!-- </q-page>-->
|
||||
<div>
|
||||
<div v-if="askForPermission">
|
||||
<p>Um den QR-Code scannen zu können, müssen Sie den Zugriff auf Ihre Kamera erlauben.</p>
|
||||
|
||||
<q-btn @click="toggleCamera(!activateCamera)" :loading="loading" unelevated color="positive" stack
|
||||
icon="photo_camera"
|
||||
label="QR-Code scannen" class="full-width"/>
|
||||
</div>
|
||||
<div v-if="activateCamera">
|
||||
<qrcode-drop-zone @decode="onDecode" @init="logErrors">
|
||||
<qrcode-stream :paused="paused" @decode="onDecode" @init="onInit">
|
||||
<div v-if="validating" >
|
||||
<div class="light-dimmed fit">
|
||||
</div>
|
||||
<q-spinner-oval
|
||||
class="absolute-center"
|
||||
color="primary"
|
||||
size="10em"
|
||||
/>
|
||||
</div>
|
||||
</qrcode-stream>
|
||||
</qrcode-drop-zone>
|
||||
</div>
|
||||
<qrcode-capture v-if="noStreamApiSupport" @decode="onDecode"/>
|
||||
<p class="decode-result">Last result: <b>{{ result }}</b></p>
|
||||
<p class="validating">Validating: <b>{{ validating }}</b></p>
|
||||
<p class="validating">is Valid: <b>{{ isValid }}</b></p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import qrscanner from '../components/qr-scanner'
|
||||
export default {
|
||||
// name: 'PageName',
|
||||
components: {
|
||||
qrscanner
|
||||
export default {
|
||||
//name: 'qrscanner',
|
||||
data() {
|
||||
return {
|
||||
askForPermission: true,
|
||||
activateCamera: false,
|
||||
isValid: false,
|
||||
validating: false,
|
||||
loading: false,
|
||||
paused: false,
|
||||
result: null,
|
||||
params: null,
|
||||
noStreamApiSupport: false
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async onDecode(content) {
|
||||
this.result = content;
|
||||
|
||||
this.pauseCamera();
|
||||
|
||||
this.validating = true;
|
||||
this.isValid = await this.validate();
|
||||
this.validating = false;
|
||||
|
||||
this.unPauseCamera();
|
||||
// window.setTimeout(() => {
|
||||
// this.unPauseCamera();
|
||||
// }, 2000)
|
||||
},
|
||||
|
||||
validate() {
|
||||
return new Promise(resolve => {
|
||||
this.setParams(0);
|
||||
let params = this.params;
|
||||
this.$axios.get('/api/checkStation', {params})
|
||||
.then((response) => {
|
||||
console.log("resolve(true)");
|
||||
resolve(true)
|
||||
}).catch((error) => {
|
||||
console.log("resolve(false)");
|
||||
// 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.data.message
|
||||
? error.response.data.message
|
||||
: error.response.data;
|
||||
} else if (error.request) {
|
||||
// The request was made but no response was received
|
||||
title = "Problem with request!";
|
||||
msg = "Der Server antwortet nicht."
|
||||
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.data);
|
||||
}
|
||||
console.log(error.config);
|
||||
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
|
||||
resolve(false);
|
||||
});
|
||||
})
|
||||
},
|
||||
|
||||
setParams(cacheID) {
|
||||
console.log("setParams: ");
|
||||
let resCacheID = this.result.split('/')[0];
|
||||
let resStationID = this.result.split('/')[1];
|
||||
console.log(resCacheID + " und " + resStationID);
|
||||
this.params = {
|
||||
token: null,
|
||||
cacheID: resCacheID,
|
||||
stationID: resStationID,
|
||||
durchgefuehrterCacheID: cacheID
|
||||
};
|
||||
if (localStorage.getItem('userToken')) {
|
||||
this.params.token = JSON.parse(localStorage.getItem('userToken')).token;
|
||||
}
|
||||
},
|
||||
|
||||
pauseCamera() {
|
||||
this.paused = true
|
||||
},
|
||||
|
||||
unPauseCamera() {
|
||||
this.paused = false
|
||||
},
|
||||
|
||||
toggleCamera(bool) {
|
||||
this.activateCamera = bool
|
||||
},
|
||||
|
||||
logErrors(promise) {
|
||||
promise.catch(console.error)
|
||||
},
|
||||
|
||||
async onInit(promise) {
|
||||
this.loading = true;
|
||||
try {
|
||||
await promise
|
||||
} catch (error) {
|
||||
if (error.name === 'StreamApiNotSupportedError') {
|
||||
this.noStreamApiSupport = true
|
||||
}
|
||||
} finally {
|
||||
this.loading = false;
|
||||
this.askForPermission = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -50,6 +50,11 @@ const routes = [
|
||||
component: () => import("layouts/MyLayout.vue"),
|
||||
children: [{ path: "", component: () => import("pages/Login.vue") }]
|
||||
},
|
||||
{
|
||||
path: "/CacheStart/:cache/",
|
||||
component: () => import("layouts/MyLayout.vue"),
|
||||
children: [{ path: "", component: () => import("pages/CacheStart.vue") }]
|
||||
},
|
||||
{
|
||||
path: "/profile/",
|
||||
component: () => import("layouts/MyLayout.vue"),
|
||||
|
||||
@ -231,6 +231,9 @@ public class Controller {
|
||||
|
||||
int i = cache.getStationen().indexOf(station);
|
||||
|
||||
if (i == 0) {
|
||||
return ResponseEntity.status(400).body("The scanned station isn´t the correct following station");
|
||||
}
|
||||
|
||||
if (cache.getStationen().get(i - 1).equals(aktuelleStation)) {
|
||||
bearbeitet.setAktuelleStation(station);
|
||||
@ -398,7 +401,7 @@ public class Controller {
|
||||
}
|
||||
|
||||
@RequestMapping("/api/hello")
|
||||
public ResponseEntity hello(@RequestParam String name){
|
||||
public ResponseEntity hello(@RequestParam String name) {
|
||||
return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(name));
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,6 @@ public interface UserRepository extends CrudRepository<User, Integer> {
|
||||
" user_roles ur\n" +
|
||||
"WHERE u.id = ui.user_id\n" +
|
||||
"AND u.id = ur.user_id\n" +
|
||||
"AND (ur.roles_id = 7 OR ur.roles_id = 8)\n" +
|
||||
"order by ranking_points_sum DESC\n" +
|
||||
"LIMIT 100;", nativeQuery = true)
|
||||
List<Object[]> getRankingList();
|
||||
@ -32,7 +31,6 @@ public interface UserRepository extends CrudRepository<User, Integer> {
|
||||
" buga19geocaching.user_roles ur\n" +
|
||||
" WHERE u.id = ui.user_id\n" +
|
||||
" AND u.id = ur.user_id\n" +
|
||||
" AND (ur.roles_id = 7 OR ur.roles_id = 8)\n" +
|
||||
" order by ranking_points_sum DESC) as INR) as RN\n" +
|
||||
"WHERE Name = ?1", nativeQuery = true)
|
||||
int getRankingPlaceFromUser(String username);
|
||||
|
||||
@ -81,7 +81,7 @@ public class CacheConstructionUtil {
|
||||
|
||||
public static ResponseEntity createStationUtil(Station station) {
|
||||
|
||||
if (station.getDescription().length() == 0 || station.getLattitude() == 0.0 || station.getLongitude() == 0.0 || station.getSolution().length() == 0) {
|
||||
if (station.getDescription().length() == 0 || station.getLattitude() == 0.0 || station.getLongitude() == 0.0 /*|| station.getSolution().length() == 0*/) {
|
||||
return ResponseEntity.status(400).body("station fields can´t be empty");
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user