finished ##197

This commit is contained in:
Tim Gröger 2020-03-04 23:10:18 +01:00
parent 586e1fdf64
commit 3893ab3851
10 changed files with 138 additions and 50 deletions

13
package-lock.json generated
View File

@ -10402,6 +10402,11 @@
"integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=", "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=",
"dev": true "dev": true
}, },
"tiny-cookie": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tiny-cookie/-/tiny-cookie-2.3.1.tgz",
"integrity": "sha512-C4x1e8dHfKf03ewuN9aIZzzOfN2a6QKhYlnHdzJxmmjMTLqcskI20F+EplszjODQ4SHmIGFJrvUUnBMS/bJbOA=="
},
"tmp": { "tmp": {
"version": "0.0.33", "version": "0.0.33",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
@ -10892,6 +10897,14 @@
} }
} }
}, },
"vue-cookie-law": {
"version": "1.12.0",
"resolved": "https://registry.npmjs.org/vue-cookie-law/-/vue-cookie-law-1.12.0.tgz",
"integrity": "sha512-Am8lHqGVD7P6iVkktVE7sZwqZz36oBBKJBBveXwCOOKA7U7XJNveO7kFxJPBrJwOzrsXjbxGIGibg5SpNlJkKg==",
"requires": {
"tiny-cookie": "^2.1.1"
}
},
"vue-eslint-parser": { "vue-eslint-parser": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-5.0.0.tgz", "resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-5.0.0.tgz",

View File

@ -12,6 +12,7 @@
"@mdi/js": "^4.8.95", "@mdi/js": "^4.8.95",
"core-js": "^3.4.3", "core-js": "^3.4.3",
"vue": "^2.6.10", "vue": "^2.6.10",
"vue-cookie-law": "^1.12.0",
"vue-router": "^3.1.3", "vue-router": "^3.1.3",
"vuetify": "^2.1.0", "vuetify": "^2.1.0",
"vuex": "^3.1.2" "vuex": "^3.1.2"

View File

@ -6,15 +6,30 @@
<span class="px-4" <span class="px-4"
>&copy; {{ new Date().getFullYear() }} Studentenclub Wu 5 e.v.</span >&copy; {{ new Date().getFullYear() }} Studentenclub Wu 5 e.v.</span
> >
<CookieLaw>
<template slot-scope="props">
<v-label>Diese Webseite benutzt Cookies in der Art von Local Storage. Dabei werden Daten auf ihrem Local Storage
gespeichert.
Diese Daten werden benutzt, damit Sie sich Anmelden können und sich gegen die REST-API hinter dieser
Webseite Authentifizieren können.
Dabei werden ihr Nutzername, ein AccessToken und ihre Gruppen (welche ihre Rechte sind) gespeichert. Diese
Daten sind Notwendig. Sollten Sie diese nicht Aktzeptieren, können Sie sich nicht Anmelden.</v-label>
<v-row>
<v-btn text color="primary" @click="props.accept">Akzeptieren</v-btn>
<v-btn text color="alert" @click="props.close">Nicht Aktzeptieren</v-btn>
</v-row>
</template>
</CookieLaw>
</v-footer> </v-footer>
</v-app> </v-app>
</template> </template>
<script> <script>
import TitleBar from './components/TitleBar' import TitleBar from './components/TitleBar'
import CookieLaw from 'vue-cookie-law'
export default { export default {
name: 'App', name: 'App',
components: { TitleBar }, components: { TitleBar, CookieLaw },
data: () => ({ data: () => ({
// //
}) })

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<v-data-table :headers="headers" :items="priceList" :search="search"> <v-data-table :headers="headers" :items="priceList" :search="search" :loading="priceListLoading || typesLoading">
<template v-slot:top> <template v-slot:top>
<v-toolbar flat color="white"> <v-toolbar flat color="white">
<v-toolbar-title>Preisliste</v-toolbar-title> <v-toolbar-title>Preisliste</v-toolbar-title>
@ -185,7 +185,7 @@
</v-icon> </v-icon>
</template> </template>
</v-data-table> </v-data-table>
<v-card tile v-if="isGastro"> <v-card tile v-if="isGastro" :loading="typesLoading">
<v-card-title> <v-card-title>
Kategorien Kategorien
<v-spacer /> <v-spacer />
@ -440,6 +440,8 @@ export default {
...mapGetters({ ...mapGetters({
priceList: 'priceList/priceList', priceList: 'priceList/priceList',
types: 'priceList/types', types: 'priceList/types',
priceListLoading: 'priceList/priceListLoading',
typesLoading: 'priceList/typesLoading',
isGastro: 'isGastro' isGastro: 'isGastro'
}), }),
formTitle() { formTitle() {

View File

@ -51,7 +51,7 @@
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</v-dialog> </v-dialog>
<v-data-table :headers="header" :items="users" :search="search"> <v-data-table :headers="header" :items="users" :search="search" :loading="usersLoading || statusLoading">
<template v-slot:top> <template v-slot:top>
<v-toolbar flat color="white"> <v-toolbar flat color="white">
<v-toolbar-title>Mitgliederliste</v-toolbar-title> <v-toolbar-title>Mitgliederliste</v-toolbar-title>
@ -219,7 +219,9 @@ export default {
computed: { computed: {
...mapGetters({ ...mapGetters({
users: 'usermanager/users', users: 'usermanager/users',
status: 'usermanager/status' status: 'usermanager/status',
usersLoading: 'usermanager/usersLoading',
statusLoading: 'usermanager/statusLoading'
}), }),
computeStatus() { computeStatus() {
return id => { return id => {

View File

@ -27,6 +27,11 @@ import UserManager from "@/components/vorstand/UserManager";
Vue.use(VueRouter) Vue.use(VueRouter)
const routes = [ const routes = [
{
path: '/cookies',
name: 'cookies',
},
{ {
path: '/pricelist', path: '/pricelist',
name: 'priceListNoLogin', name: 'priceListNoLogin',

View File

@ -50,7 +50,11 @@ const actions = {
commit('loginStart') commit('loginStart')
try { try {
const response = await axios.post(url.login, { ...loginData }) const response = await axios.post(url.login, { ...loginData })
console.log(response.data) const cookieA = localStorage.getItem('cookie:accepted')
if (!cookieA) {
commit('loginStop', 'Sie müssen die Cookies akzeptieren!')
return
}
localStorage.setItem( localStorage.setItem(
'user', 'user',
JSON.stringify({ JSON.stringify({
@ -88,6 +92,8 @@ const actions = {
}, },
logout({ commit }) { logout({ commit }) {
localStorage.removeItem('user') localStorage.removeItem('user')
localStorage.removeItem('cookie:accepted')
localStorage.removeItem('cookie:all')
commit('logout') commit('logout')
router.push('/login') router.push('/login')
}, },

View File

@ -2,6 +2,8 @@ import url from '@/plugins/routes'
import axios from 'axios' import axios from 'axios'
const state = { const state = {
priceListLoading: false,
typesLoading: false,
priceList: [], priceList: [],
types: [] types: []
} }
@ -83,101 +85,128 @@ const mutations = {
}) })
) )
state.types.splice(index, 1) state.types.splice(index, 1)
},
setPriceListLoading: (state, value) => {
state.priceListLoading = value
},
setTypesLoading: (state, value) => {
state.typesLoading = value
} }
} }
const actions = { const actions = {
async getPriceList({ commit }) { async getPriceList({ commit }) {
try { try {
commit('setPriceListLoading', true)
const response = await axios.get(url.pricelist) const response = await axios.get(url.pricelist)
commit('setPriceList', response.data) commit('setPriceList', response.data)
commit('setPriceListLoading', false)
} catch (e) { } catch (e) {
console.log(e) commit('setPriceListLoading', false)
} }
}, },
async getTypes({ commit, dispatch }) { async getTypes({ commit }) {
try { try {
commit('setTypesLoading', true)
const response = await axios.get(url.getTypes) const response = await axios.get(url.getTypes)
commit('setTypes', response.data) commit('setTypes', response.data)
commit('setTypesLoading', false)
} catch (e) { } catch (e) {
if (e.response) commit('setTypesLoading', false)
if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
}, },
async setDrink({ commit, rootState, dispatch }, data) { async setDrink({ commit, rootState, dispatch }, data) {
try { try {
commit('setPriceListLoading', true)
const response = await axios.post( const response = await axios.post(
url.gastro.setDrink, url.gastro.setDrink,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
commit('updatePriceList', response.data) commit('updatePriceList', response.data)
commit('setPriceListLoading', false)
} catch (e) { } catch (e) {
commit('setPriceListLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
}, },
async updateDrink({ commit, rootState, dispatch }, data) { async updateDrink({ commit, rootState, dispatch }, data) {
try { try {
commit('setPriceListLoading', true)
const response = await axios.post( const response = await axios.post(
url.gastro.updateDrink, url.gastro.updateDrink,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
commit('updatePriceList', response.data) commit('updatePriceList', response.data)
commit('setPriceListLoading', false)
} catch (e) { } catch (e) {
commit('setPriceListLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
}, },
async deleteDrink({ commit, rootState, dispatch }, data) { async deleteDrink({ commit, rootState, dispatch }, data) {
try { try {
commit('setPriceListLoading', true)
await axios.post( await axios.post(
url.gastro.deleteDrink, url.gastro.deleteDrink,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
commit('deleteDrinkPrice', data) commit('deleteDrinkPrice', data)
commit('setPriceListLoading', false)
} catch (e) { } catch (e) {
commit('setPriceListLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
}, },
async setDrinkType({ commit, rootState, dispatch }, data) { async setDrinkType({ commit, rootState, dispatch }, data) {
try { try {
commit('setTypesLoading', true)
const response = await axios.post( const response = await axios.post(
url.gastro.setType, url.gastro.setType,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
commit('updateDrinkType', response.data) commit('updateDrinkType', response.data)
commit('setTypesLoading', false)
} catch (e) { } catch (e) {
commit('setTypesLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
}, },
async updateDrinkType({ commit, rootState, dispatch }, data) { async updateDrinkType({ commit, rootState, dispatch }, data) {
try { try {
commit('setTypesLoading', true)
const response = await axios.post( const response = await axios.post(
url.gastro.updateType, url.gastro.updateType,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
commit('updateDrinkType', response.data) commit('updateDrinkType', response.data)
commit('setTypesLoading', false)
} catch (e) { } catch (e) {
commit('setTypesLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
}, },
async deleteDrinkType({ commit, rootState, dispatch }, data) { async deleteDrinkType({ commit, rootState, dispatch }, data) {
try { try {
commit('setTypesLoading', true)
await axios.post( await axios.post(
url.gastro.deleteType, url.gastro.deleteType,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
commit('deleteDrinkType', data) commit('deleteDrinkType', data)
commit('setTypesLoading', false)
} catch (e) { } catch (e) {
commit('setTypesLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -190,6 +219,12 @@ const getters = {
}, },
types: state => { types: state => {
return state.types return state.types
},
priceListLoading: state => {
return state.priceListLoading
},
typesLoading: state => {
return state.typesLoading
} }
} }

View File

@ -3,7 +3,9 @@ import axios from 'axios'
const state = { const state = {
users: [], users: [],
status: [] status: [],
usersLoading: false,
statusLoading: false,
} }
const mutations = { const mutations = {
@ -52,93 +54,72 @@ const mutations = {
}) })
) )
state.status.splice(index, 1) state.status.splice(index, 1)
},
setUsersLoading: (state, value) => {
state.usersLoading = value
},
setStatusLoading: (state, value) => {
state.statusLoading = value
} }
} }
const actions = { const actions = {
async getUsers({ commit, rootState, dispatch }) { async getUsers({ commit, rootState, dispatch }) {
try { try {
commit('setUsersLoading', true)
const response = await axios.get(url.getUsers, { const response = await axios.get(url.getUsers, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken }
}) })
commit('setUsers', response.data) commit('setUsers', response.data)
commit('setUsersLoading', false)
} catch (e) { } catch (e) {
commit('setUsersLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
}, },
async getStatus({ commit, rootState, dispatch }) { async getStatus({ commit, rootState, dispatch }) {
try { try {
commit('setStatusLoading', true)
const response = await axios.get(url.user.getAllStatus, { const response = await axios.get(url.user.getAllStatus, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken }
}) })
commit('setStatus', response.data) commit('setStatus', response.data)
commit('setStatusLoading', false)
} catch (e) { } catch (e) {
if (e.response) commit('setStatusLoading', false)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async updateStatus({ commit, rootState, dispatch }, data) {
try {
const response = await axios.post(
url.vorstand.um.updateStatus,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateStatus', response.data)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async setStatus({ commit, rootState, dispatch }, data) {
try {
const response = await axios.post(
url.vorstand.um.setStatus,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateStatus', response.data)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async deleteStatus({ commit, rootState, dispatch }, data) {
try {
await axios.post(
url.vorstand.um.deleteStatus,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('deleteStatus', data)
} catch (e) {
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
}, },
async updateStatusUser({ commit, rootState, dispatch }, data) { async updateStatusUser({ commit, rootState, dispatch }, data) {
try { try {
commit('setUsersLoading', true)
const response = await axios.post( const response = await axios.post(
url.vorstand.um.updateStatusUser, url.vorstand.um.updateStatusUser,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
commit('updateUser', response.data) commit('updateUser', response.data)
commit('setUsersLoading', false)
} catch (e) { } catch (e) {
commit('setUsersLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
}, },
async updateVoting({ commit, rootState, dispatch }, data) { async updateVoting({ commit, rootState, dispatch }, data) {
try { try {
commit('setUsersLoading', true)
const response = await axios.post( const response = await axios.post(
url.vorstand.um.updateVoting, url.vorstand.um.updateVoting,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
commit('updateUser', response.data) commit('updateUser', response.data)
commit('setUsersLoading', false)
} catch (e) { } catch (e) {
commit('setUsersLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -151,6 +132,12 @@ const getters = {
}, },
status: state => { status: state => {
return state.status return state.status
},
usersLoading: state => {
return state.usersLoading
},
statusLoading: state => {
return state.statusLoading
} }
} }

View File

@ -0,0 +1,22 @@
<template>
<v-content>
<v-container>
<v-card>
<v-card-title>Informationen zu Cookies</v-card-title>
<v-card-text>
Cookies sind dafür
</v-card-text>
</v-card>
</v-container>
</v-content>
</template>
<script>
export default {
name: "Cookies"
}
</script>
<style scoped>
</style>