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=",
"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": {
"version": "0.0.33",
"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": {
"version": "5.0.0",
"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",
"core-js": "^3.4.3",
"vue": "^2.6.10",
"vue-cookie-law": "^1.12.0",
"vue-router": "^3.1.3",
"vuetify": "^2.1.0",
"vuex": "^3.1.2"

View File

@ -6,15 +6,30 @@
<span class="px-4"
>&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-app>
</template>
<script>
import TitleBar from './components/TitleBar'
import CookieLaw from 'vue-cookie-law'
export default {
name: 'App',
components: { TitleBar },
components: { TitleBar, CookieLaw },
data: () => ({
//
})

View File

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

View File

@ -51,7 +51,7 @@
</v-card-actions>
</v-card>
</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>
<v-toolbar flat color="white">
<v-toolbar-title>Mitgliederliste</v-toolbar-title>
@ -219,7 +219,9 @@ export default {
computed: {
...mapGetters({
users: 'usermanager/users',
status: 'usermanager/status'
status: 'usermanager/status',
usersLoading: 'usermanager/usersLoading',
statusLoading: 'usermanager/statusLoading'
}),
computeStatus() {
return id => {

View File

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

View File

@ -50,7 +50,11 @@ const actions = {
commit('loginStart')
try {
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(
'user',
JSON.stringify({
@ -88,6 +92,8 @@ const actions = {
},
logout({ commit }) {
localStorage.removeItem('user')
localStorage.removeItem('cookie:accepted')
localStorage.removeItem('cookie:all')
commit('logout')
router.push('/login')
},

View File

@ -2,6 +2,8 @@ import url from '@/plugins/routes'
import axios from 'axios'
const state = {
priceListLoading: false,
typesLoading: false,
priceList: [],
types: []
}
@ -83,101 +85,128 @@ const mutations = {
})
)
state.types.splice(index, 1)
},
setPriceListLoading: (state, value) => {
state.priceListLoading = value
},
setTypesLoading: (state, value) => {
state.typesLoading = value
}
}
const actions = {
async getPriceList({ commit }) {
try {
commit('setPriceListLoading', true)
const response = await axios.get(url.pricelist)
commit('setPriceList', response.data)
commit('setPriceListLoading', false)
} catch (e) {
console.log(e)
commit('setPriceListLoading', false)
}
},
async getTypes({ commit, dispatch }) {
async getTypes({ commit }) {
try {
commit('setTypesLoading', true)
const response = await axios.get(url.getTypes)
commit('setTypes', response.data)
commit('setTypesLoading', false)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
commit('setTypesLoading', false)
}
},
async setDrink({ commit, rootState, dispatch }, data) {
try {
commit('setPriceListLoading', true)
const response = await axios.post(
url.gastro.setDrink,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updatePriceList', response.data)
commit('setPriceListLoading', false)
} catch (e) {
commit('setPriceListLoading', false)
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async updateDrink({ commit, rootState, dispatch }, data) {
try {
commit('setPriceListLoading', true)
const response = await axios.post(
url.gastro.updateDrink,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updatePriceList', response.data)
commit('setPriceListLoading', false)
} catch (e) {
commit('setPriceListLoading', false)
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async deleteDrink({ commit, rootState, dispatch }, data) {
try {
commit('setPriceListLoading', true)
await axios.post(
url.gastro.deleteDrink,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('deleteDrinkPrice', data)
commit('setPriceListLoading', false)
} catch (e) {
commit('setPriceListLoading', false)
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async setDrinkType({ commit, rootState, dispatch }, data) {
try {
commit('setTypesLoading', true)
const response = await axios.post(
url.gastro.setType,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateDrinkType', response.data)
commit('setTypesLoading', false)
} catch (e) {
commit('setTypesLoading', false)
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async updateDrinkType({ commit, rootState, dispatch }, data) {
try {
commit('setTypesLoading', true)
const response = await axios.post(
url.gastro.updateType,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateDrinkType', response.data)
commit('setTypesLoading', false)
} catch (e) {
commit('setTypesLoading', false)
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async deleteDrinkType({ commit, rootState, dispatch }, data) {
try {
commit('setTypesLoading', true)
await axios.post(
url.gastro.deleteType,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('deleteDrinkType', data)
commit('setTypesLoading', false)
} catch (e) {
commit('setTypesLoading', false)
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
@ -190,6 +219,12 @@ const getters = {
},
types: state => {
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 = {
users: [],
status: []
status: [],
usersLoading: false,
statusLoading: false,
}
const mutations = {
@ -52,93 +54,72 @@ const mutations = {
})
)
state.status.splice(index, 1)
},
setUsersLoading: (state, value) => {
state.usersLoading = value
},
setStatusLoading: (state, value) => {
state.statusLoading = value
}
}
const actions = {
async getUsers({ commit, rootState, dispatch }) {
try {
commit('setUsersLoading', true)
const response = await axios.get(url.getUsers, {
headers: { Token: rootState.login.user.accessToken }
})
commit('setUsers', response.data)
commit('setUsersLoading', false)
} catch (e) {
commit('setUsersLoading', false)
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async getStatus({ commit, rootState, dispatch }) {
try {
commit('setStatusLoading', true)
const response = await axios.get(url.user.getAllStatus, {
headers: { Token: rootState.login.user.accessToken }
})
commit('setStatus', response.data)
commit('setStatusLoading', false)
} catch (e) {
if (e.response)
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) {
commit('setStatusLoading', false)
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async updateStatusUser({ commit, rootState, dispatch }, data) {
try {
commit('setUsersLoading', true)
const response = await axios.post(
url.vorstand.um.updateStatusUser,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateUser', response.data)
commit('setUsersLoading', false)
} catch (e) {
commit('setUsersLoading', false)
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async updateVoting({ commit, rootState, dispatch }, data) {
try {
commit('setUsersLoading', true)
const response = await axios.post(
url.vorstand.um.updateVoting,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateUser', response.data)
commit('setUsersLoading', false)
} catch (e) {
commit('setUsersLoading', false)
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
@ -151,6 +132,12 @@ const getters = {
},
status: state => {
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>