Merge branch 'develop' into backend/michael

This commit is contained in:
Michael 2019-03-26 22:33:34 +01:00
commit bf7f178d17
17 changed files with 380 additions and 266 deletions

13
.idea/compiler.xml generated
View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel>
<module name="de.hhn.labsw.BuGaGeocaching.main" target="1.8" />
<module name="de.hhn.labsw.BuGaGeocaching.test" target="1.8" />
<module name="de.hhn.labsw.labswp_2019_sose_geocaching.main" target="1.8" />
<module name="de.hhn.labsw.labswp_2019_sose_geocaching.test" target="1.8" />
<module name="labswp_2019_sose_geocaching.de.hhn.labsw.labswp_2019_sose_geocaching.main" target="1.8" />
<module name="labswp_2019_sose_geocaching.de.hhn.labsw.labswp_2019_sose_geocaching.test" target="1.8" />
</bytecodeTargetLevel>
</component>
</project>

View File

@ -14,7 +14,7 @@ module.exports = {
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
extends: [
'plugin:vue/essential',
'@vue/prettier'
// '@vue/prettier'
],
// required to lint *.vue files

View File

@ -47,6 +47,7 @@ module.exports = function (ctx) {
'QCardActions',
'QCheckbox',
'QSeparator',
'QImg',
'QTabs',
'QTab',
'QRouteTab',
@ -54,11 +55,13 @@ module.exports = function (ctx) {
'QTabPanel',
'QInput',
'QFab',
'QFabAction'
'QFabAction',
'QDialog'
],
directives: [
'Ripple'
'Ripple',
'ClosePopup'
],
// Quasar plugins
@ -93,7 +96,7 @@ module.exports = function (ctx) {
devServer: {
// https: true,
// port: 8080,
port: 8081,
open: true // opens browser window automatically
},

View File

@ -1,7 +1,7 @@
<template>
<q-layout view="hhh Lpr lFf">
<q-header elevated class="bg-white text-green-8 shadow-2">
<q-toolbar class="">
<q-header elevated class="bg-white text-green-8">
<q-toolbar class="q-pa-md">
<q-btn
flat
dense
@ -13,7 +13,7 @@
</q-btn>
<q-toolbar-title>
BuGa Geocaching SPA
BuGa Geocaching
</q-toolbar-title>
<!--<div>Quasar v{{ $q.version }}</div>-->
@ -24,10 +24,7 @@
v-model="leftDrawerOpen"
bordered
show-if-above
:mini="miniState"
@mouseover="miniState = false"
@mouseout="miniState = true"
content-class="bg-green-1">
content-class="">
<q-list>
<q-item-label header>Essential Links</q-item-label>
<q-item
@ -116,9 +113,9 @@ export default {
name: "MyLayout",
data() {
return {
//leftDrawerOpen: this.$q.platform.is.desktop,
leftDrawerOpen: true,
miniState: true
leftDrawerOpen: this.$q.platform.is.desktop,
//leftDrawerOpen: true,
//miniState: true
};
},
methods: {

View File

@ -1,14 +1,4 @@
<template>
<div class="q-pa-md">
<q-table
title="Treats"
:data="data"
:columns="columns"
row-key="name"
selection="single"
:selected.sync="selected"
/>
<div class="q-mt-md">Selected: {{ JSON.stringify(selected) }}</div>
</div>
</template>

View File

@ -1,185 +1,54 @@
<template>
<div class="q-pa-md">
<q-table
title="Treats"
:data="data"
:columns="columns"
row-key="name"
selection="single"
:selected.sync="selected"
:filter="filter"
grid
hide-header
<div class="q-pa-md row items-start q-gutter-md">
<q-card class="my-card">
<q-card-section>
{{ lorem }}
</q-card-section>
</q-card>
<q-card
class="my-card text-white"
style="background: radial-gradient(circle, #35a2ff 0%, #014a88 100%)"
>
<template v-slot:top-right>
<q-input borderless dense debounce="300" v-model="filter" placeholder="Search">
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
</template>
<q-card-section>
<div class="text-h6">Our Changing Planet</div>
<div class="text-subtitle2">by John Doe</div>
</q-card-section>
<template v-slot:item="props">
<div
class="q-pa-xs col-xs-12 col-sm-6 col-md-4 col-lg-3 grid-style-transition"
:style="props.selected ? 'transform: scale(0.95);' : ''"
>
<q-card :class="props.selected ? 'bg-grey-2' : ''">
<q-card-section>
<q-checkbox :dense="denseOn" v-model="props.selected" :label="props.row.name" />
</q-card-section>
<q-separator />
<q-list dense>
<q-item v-for="col in props.cols.filter(col => col.name !== 'desc')" :key="col.name">
<q-item-section>
<q-item-label>{{ col.label }}</q-item-label>
</q-item-section>
<q-item-section side>
<q-item-label caption>{{ col.value }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-card>
</div>
</template>
<q-card-section>
{{ lorem }}
</q-card-section>
</q-card>
</q-table>
<q-card dark bordered class="bg-grey-9 my-card">
<q-card-section>
<div class="text-h6">Our Changing Planet</div>
<div class="text-subtitle2">by John Doe</div>
</q-card-section>
<q-separator dark inset />
<q-card-section>
{{ lorem }}
</q-card-section>
</q-card>
<q-card flat bordered class="my-card">
<q-card-section>
<div class="text-h6">Our Changing Planet</div>
</q-card-section>
<q-card-section>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.
</q-card-section>
<q-separator inset />
<q-card-section>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.
</q-card-section>
</q-card>
</div>
</template>
<style lang="stylus">
.grid-style-transition
transition transform .3s
</style>
<script>
export default {
data () {
return {
denseOn: true,
filter: '',
selected: [],
columns: [
{
name: 'desc',
required: true,
label: 'Dessert (100g serving)',
align: 'left',
field: row => row.name,
format: val => `${val}`,
sortable: true
},
{ name: 'calories', align: 'center', label: 'Calories', field: 'calories', sortable: true },
{ name: 'fat', label: 'Fat (g)', field: 'fat', sortable: true },
{ name: 'carbs', label: 'Carbs (g)', field: 'carbs' },
{ name: 'protein', label: 'Protein (g)', field: 'protein' },
{ name: 'sodium', label: 'Sodium (mg)', field: 'sodium' },
{ name: 'calcium', label: 'Calcium (%)', field: 'calcium', sortable: true, sort: (a, b) => parseInt(a, 10) - parseInt(b, 10) },
{ name: 'iron', label: 'Iron (%)', field: 'iron', sortable: true, sort: (a, b) => parseInt(a, 10) - parseInt(b, 10) }
],
data: [
{
name: 'Frozen Yogurt',
calories: 159,
fat: 6.0,
carbs: 24,
protein: 4.0,
sodium: 87,
calcium: '14%',
iron: '1%'
},
{
name: 'Ice cream sandwich',
calories: 237,
fat: 9.0,
carbs: 37,
protein: 4.3,
sodium: 129,
calcium: '8%',
iron: '1%'
},
{
name: 'Eclair',
calories: 262,
fat: 16.0,
carbs: 23,
protein: 6.0,
sodium: 337,
calcium: '6%',
iron: '7%'
},
{
name: 'Cupcake',
calories: 305,
fat: 3.7,
carbs: 67,
protein: 4.3,
sodium: 413,
calcium: '3%',
iron: '8%'
},
{
name: 'Gingerbread',
calories: 356,
fat: 16.0,
carbs: 49,
protein: 3.9,
sodium: 327,
calcium: '7%',
iron: '16%'
},
{
name: 'Jelly bean',
calories: 375,
fat: 0.0,
carbs: 94,
protein: 0.0,
sodium: 50,
calcium: '0%',
iron: '0%'
},
{
name: 'Lollipop',
calories: 392,
fat: 0.2,
carbs: 98,
protein: 0,
sodium: 38,
calcium: '0%',
iron: '2%'
},
{
name: 'Honeycomb',
calories: 408,
fat: 3.2,
carbs: 87,
protein: 6.5,
sodium: 562,
calcium: '0%',
iron: '45%'
},
{
name: 'Donut',
calories: 452,
fat: 25.0,
carbs: 51,
protein: 4.9,
sodium: 326,
calcium: '2%',
iron: '22%'
},
{
name: 'KitKat',
calories: 518,
fat: 26.0,
carbs: 65,
protein: 7,
sodium: 54,
calcium: '12%',
iron: '6%'
}
]
}
}
}
</script>

View File

@ -1,52 +1,129 @@
<template>
<div class="q-pa-md">
<q-layout view="lhh LpR lff" container style="height: 350px" class="shadow-2 rounded-borders">
<q-header reveal class="bg-white" text="green-8">
<q-toolbar>
<q-toolbar-title class="bg-white text-green-8">Login</q-toolbar-title>
</q-toolbar>
</q-header>
<q-page-container>
<q-page padding>
<template>
<div class="q-pa-md">
<div class="column" style="height: 150px">
<div class="col">
<template>
<div class="q-pa-md">
<div class="q-gutter-md" style="max-width: 300px">
<q-input v-model="text" label="Benutzername" />
</div>
</div>
</template>
</div>
<div class="col">
<template>
<div class="q-pa-md">
<div class="q-gutter-md" style="max-width: 300px">
<q-input v-model="text" label="Passwort" />
</div>
</div>
</template>
<form class="login" @submit.prevent="login">
<div class="q-pa-md">
<div class="column q-gutter-lg" style="">
<div class="col">
<div class="">
<div class="" style="max-width: 300px">
<q-input outlined filled stack-label v-model="user.username" type="text" label="Benutzername" autocomplete="username"/>
</div>
</div>
</div>
</template>
<q-page-sticky position="bottom-right" :offset="[18, 18]">
<q-btn fab color="bg-white" text-color="green-8" @click="onClick" icon="keyboard_arrow_right"/>
</q-page-sticky>
</q-page>
</q-page-container>
</q-layout>
</div>
<div class="col">
<div class="">
<div class="" style="max-width: 300px">
<q-input outlined filled stack-label v-model="user.password" type="password" label="Passwort" autocomplete="current-password"/>
</div>
</div>
</div>
<div class="col">
<div class="">
<div class="" style="max-width: 300px">
<q-btn
:outline="this.user.isAuthenticated"
:disabled="this.user.isAuthenticated"
label="Login"
color="primary"
class="full-width"
type="submit"
unelevated
/>
<q-btn
:outline="!this.user.isAuthenticated"
:disabled="!this.user.isAuthenticated"
label="Logout"
color="red"
class="full-width q-mt-md"
unelevated
@click="logout"
/>
</div>
</div>
</div>
</div>
</div>
</form>
<q-dialog v-model="credentialsDialog" persistent transition-show="scale" transition-hide="scale">
<q-card class="bg-red-9 text-white" style="">
<q-card-section>
<div class="text-h6">Fehler</div>
</q-card-section>
<q-card-section>
Es konnten keine übereinstimmenden Zugangsdaten in der Datenbank gefunden werden.
</q-card-section>
<q-card-actions align="right" class="bg-white text-teal">
<q-btn flat label="OK" color="red-9" v-close-popup />
</q-card-actions>
</q-card>
</q-dialog> </div>
</template>
<script>
export default {
data () {
return {
text: ''
}
}
}
export default {
data() {
return {
user: {
username: "moximoti",
password: "1234",
//token: "",
isAuthenticated: false
},
credentialsDialog: false,
};
},
// beforeMount: {
// init: function () {
// this.isAuthenticated();
// console.log("initiated");
// }
// },
mounted () {
this.isAuthenticated();
//this.pollData();
console.log("mounted: initiated");
},
methods: {
login: function () {
// const { username, password } = this;
// this.$store.dispatch(AUTH_REQUEST, { username, password }).then(() => {
// this.$router.push('/')
// })
const data = {
username: this.user.username,
password: this.user.password
} //JSON.stringify(this.user);
console.log("GET http://localhost:8080/api/login/ - json: " + JSON.stringify(data));
this.$axios.post('http://localhost:8080/api/login', data) // TODO muss GET mit AUTH Header werden
.then((response) => {
console.log("GET/POST http://localhost:8080/api/login/ - response: " + response.data);
//this.user.token = response.data;
localStorage.setItem('userToken', JSON.stringify(response));
this.isAuthenticated();
})
.catch((error) => {
console.log("error: " + error);
this.credentialsDialog=true;
})
},
isAuthenticated: function () {
console.log("isAuthenticated()");
console.log(localStorage.getItem('userToken'));
if (localStorage.getItem('userToken')) { // TODO hier muss Abfrage mit API, z.B. /api/user?token="ME" stattfinden.
this.user.isAuthenticated = true;
} else {
this.user.isAuthenticated = false;
}
},
logout: function () {
console.log("logout()");
console.log(localStorage.getItem('userToken'));
localStorage.removeItem('userToken');
console.log(localStorage.getItem('userToken'));
this.isAuthenticated()
},
},
};
</script>

View File

@ -0,0 +1,86 @@
<template>
<div class="q-pa-md row items-start q-col-gutter-md">
<div class="col col-sm-6" v-for="cache in caches" :key="cache.id">
<q-card flat bordered class="my-card bg-grey-1">
<q-img :ratio="16/9" src="https://cdn.quasar-framework.org/img/parallax2.jpg">
<div class="absolute-bottom">
<div class="text-h6">
<span>{{ cache.name }}</span>
<span v-if="cache.stationen.length > 2"> (Multicache)</span>
<span v-else> (Singlecache)</span>
</div>
</div>
</q-img>
<q-card-section>
{{ cache.description }}
</q-card-section>
<q-separator inset />
<q-card-actions align="around">
<q-btn flat color="green" class="btn-fixed-width" >Cache starten</q-btn>
<q-btn flat outline class="btn-fixed-width">Ansehen</q-btn>
</q-card-actions>
</q-card>
</div>
<a href="/">Hallo</a>
</div>
</template>
<style lang="stylus">
.grid-style-transition
transition transform .3s
.btn-fixed-width
width: 48%
</style>
<script>
export default {
data () {
return {
denseOn: true,
filter: '',
selected: [],
caches: [],
columns: [
{
name: 'desc',
required: true,
label: 'Dessert (100g serving)',
align: 'left',
field: row => row.title,
format: val => `${val}`,
sortable: true
},
{ name: 'userId', align: 'center', label: 'ID', field: 'userId', sortable: true },
{ name: 'id', label: 'fID', field: 'id', sortable: true },
{ name: 'title', label: 'Titel', field: 'title' },
{ name: 'completed', label: 'Komplett', field: 'completed' },
],
// data: [
// {
// "userId": 1,
// "id": 1,
// "title": "delectus aut autem",
// "completed": false
// }
// ]
}
},
created: function() {
console.log("created(): " + this.caches);
this.fetchTodos();
},
methods: {
fetchTodos () {
this.$axios.get('http://localhost:8080/allCaches')
.then((response) => {
console.log("Caches: " + this.caches);
this.caches = response.data;
})
}
}
}
</script>

View File

@ -9,6 +9,11 @@ const routes = [
component: () => import("layouts/MyLayout.vue"),
children: [{ path: "", component: () => import("pages/Dashboard.vue") }]
},
{
path: "/testcaches/",
component: () => import("layouts/MyLayout.vue"),
children: [{path: "", component: () => import("pages/TestCaches.vue")}]
},
{
path: "/cacheview/",
component: () => import("layouts/MyLayout.vue"),

View File

@ -0,0 +1,4 @@
/*
export function someAction (context) {
}
*/

View File

@ -0,0 +1,4 @@
/*
export function someGetter (state) {
}
*/

View File

@ -0,0 +1,12 @@
import state from './state'
import * as getters from './getters'
import * as mutations from './mutations'
import * as actions from './actions'
export default {
namespaced: true,
state,
getters,
mutations,
actions
}

View File

@ -0,0 +1,38 @@
import axios from 'axios'
/*
export function someMutation (state) {
}
*/
export const evalAuth = (state) => {
console.log("isAuthenticated()");
console.log(localStorage.getItem('userToken'));
if (localStorage.getItem('userToken')) { // TODO hier muss Abfrage mit API, z.B. /api/user?token="ME" stattfinden.
state.user.isAuthenticated = true;
} else {
state.user.isAuthenticated = false;
}
};
export const logout = (state) => {
console.log("logout()");
console.log(localStorage.getItem('userToken'));
localStorage.removeItem('userToken');
console.log(localStorage.getItem('userToken'));
state.commit(evalAuth(state));
};
export const login = (state) => {
const data = {
username: state.user.username,
password: state.user.password
};
console.log("GET http://localhost:8080/api/login/ - json: " + JSON.stringify(data));
this.state.$axios.post('http://localhost:8080/api/login', data) // TODO muss GET mit AUTH Header werden
.then((response) => {
console.log("GET/POST http://localhost:8080/api/login/ - response: " + response.data);
localStorage.setItem('userToken', JSON.stringify(response));
state.commit(evalAuth(state));
})
.catch((error) => {
console.log("error: " + error);
//errorDialog = true;
})
};

View File

@ -0,0 +1,7 @@
export default {
user: {
username: "moximoti",
password: "1234",
isAuthenticated: false
},
}

View File

@ -1,25 +1,54 @@
import Vue from "vue";
import Vuex from "vuex";
import Axios from "axios";
import auth from "./auth"
// import example from './module-example'
Vue.use(Vuex);
Vue.use(Vuex, Axios);
/*
* If not building with SSR mode, you can
* directly export the Store instantiation
*/
export default function(/* { ssrContext } */) {
// export default function(/* { ssrContext } */) {
// const Store = new Vuex.Store({
// modules: {
// // example
// },
//
// // enable strict mode (adds overhead!)
// // for dev mode only
// strict: process.env.DEV
// });
//
// return Store;
// }
export default function (/* { ssrContext } */) {
const Store = new Vuex.Store({
modules: {
// example
auth
},
// enable strict mode (adds overhead!)
// for dev mode only
strict: process.env.DEV
});
})
return Store;
}
/*
if we want some HMR magic for it, we handle
the hot update like below. Notice we guard this
code with "process.env.DEV" -- so this doesn't
get into our production build (and it shouldn't).
*/
if (process.env.DEV && module.hot) {
module.hot.accept(['./auth'], () => {
const newShowcase = require('./auth').default;
store.hotUpdate({ modules: { showcase: newShowcase } })
})
}
return Store
};

View File

@ -40,16 +40,20 @@ public class Controller {
private AtomicLong counter = new AtomicLong();
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/allCaches")
@ResponseBody
public String getAllCaches() {
return new Gson().toJson(cacheRepository.findAll());
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/login")
@ResponseBody
public ResponseEntity<Object> login(@RequestBody User user){
if(user.getUsername() == null || user.getPassword() == null){
System.out.println(user.getUsername());
System.out.println(user.getPassword());
return ResponseEntity.status(401).body(null);
}
if(userRepository.findByUsername(user.getUsername()) == null){
@ -66,6 +70,7 @@ public class Controller {
return ResponseEntity.status(HttpStatus.BAD_GATEWAY).body(null);
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/startCache")
public @ResponseBody
String startCache(@RequestParam(value = "userID", defaultValue = "-1") String userID,

View File

@ -2,4 +2,5 @@ spring.datasource.url=jdbc:mariadb://seserver.se.hs-heilbronn.de:3406/buga19Geoc
spring.datasource.username=BuGa19GeocachingUser
spring.datasource.password=GeocachingPw
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true