Merge branch 'feature/status' into develop

This commit is contained in:
Tim Gröger 2020-03-03 23:34:13 +01:00
commit c1d058f8c5
11 changed files with 569 additions and 51 deletions

View File

@ -64,7 +64,7 @@
<v-row>
<v-col cols="10">
<v-row>
<v-col>
<v-col cols="6" xs="5" sm="4">
<v-btn
class="creditBtn"
block
@ -77,10 +77,10 @@
"
:color="color"
:disabled="user.locked"
>2 </v-btn
>
>2
</v-btn>
</v-col>
<v-col>
<v-col cols="6" xs="5" sm="4">
<v-btn
class="creditBtn"
block
@ -93,10 +93,10 @@
"
:color="color"
:disabled="user.locked"
>1 </v-btn
>
>1
</v-btn>
</v-col>
<v-col>
<v-col cols="6" xs="5" sm="4">
<v-btn
class="creditBtn"
block
@ -109,12 +109,10 @@
"
:color="color"
:disabled="user.locked"
>0,50 </v-btn
>
>0,50
</v-btn>
</v-col>
</v-row>
<v-row>
<v-col>
<v-col cols="6" xs="5" sm="4">
<v-btn
class="creditBtn"
block
@ -127,10 +125,10 @@
"
:color="color"
:disabled="user.locked"
>0,40 </v-btn
>
>0,40
</v-btn>
</v-col>
<v-col>
<v-col cols="6" xs="5" sm="4">
<v-btn
class="creditBtn"
block
@ -143,10 +141,10 @@
"
:color="color"
:disabled="user.locked"
>0,20 </v-btn
>
>0,20
</v-btn>
</v-col>
<v-col>
<v-col cols="6" xs="5" sm="4">
<v-btn
class="creditBtn"
block
@ -159,8 +157,16 @@
"
:color="color"
:disabled="user.locked"
>0,10 </v-btn
>
>0,10
</v-btn>
</v-col>
<v-col cols="8">
<v-text-field outlined type="number" v-model="user.value" label="Benutzerdefinierter Betrag" :disabled="user.locked"></v-text-field>
</v-col>
<v-col cols="4">
<v-btn fab :color="color" @click="addAmountMore(user)" :disabled="user.locked">
<v-icon>{{plus}}</v-icon>
</v-btn>
</v-col>
</v-row>
</v-col>
@ -203,6 +209,7 @@
<script>
import { mapGetters, mapActions } from 'vuex'
import {mdiPlus} from '@mdi/js'
import AddAmountSkeleton from '../user/Skeleton/AddAmountSkeleton'
export default {
@ -211,6 +218,8 @@ export default {
props: {},
data() {
return {
plus: mdiPlus,
value: null,
color: 'green accent-4',
menu: true,
dialog: false,
@ -246,6 +255,12 @@ export default {
return true
}
},
addAmountMore(user) {
this.addAmount({username: user.username, amount: user.value * 100, user: user})
setTimeout(() => {
user.value = null
}, 300)
},
storno(message) {
console.log('storno')
if (!message.error) {
@ -343,7 +358,7 @@ export default {
this.menu = this.menu_from_store
}
},
beforeDestroy () {
beforeDestroy() {
clearInterval(this.timer)
}
}

View File

@ -60,7 +60,7 @@
<v-row>
<v-col cols="10">
<v-row>
<v-col>
<v-col cols="6" sm="4">
<v-btn
class="creditBtn"
block
@ -70,7 +70,7 @@
>2 </v-btn
>
</v-col>
<v-col>
<v-col cols="6" sm="4">
<v-btn
class="creditBtn"
block
@ -80,7 +80,7 @@
>1 </v-btn
>
</v-col>
<v-col>
<v-col cols="6" sm="4">
<v-btn
class="creditBtn"
block
@ -90,9 +90,7 @@
>0,50 </v-btn
>
</v-col>
</v-row>
<v-row>
<v-col>
<v-col cols="6" sm="4">
<v-btn
class="creditBtn"
block
@ -102,7 +100,7 @@
>0,40 </v-btn
>
</v-col>
<v-col>
<v-col cols="6" sm="4">
<v-btn
class="creditBtn"
block
@ -112,7 +110,7 @@
>0,20 </v-btn
>
</v-col>
<v-col>
<v-col cols="6" sm="4">
<v-btn
class="creditBtn"
block
@ -122,6 +120,14 @@
>0,10 </v-btn
>
</v-col>
<v-col cols="8">
<v-text-field outlined type="number" v-model="value" label="Benutzerdefinierter Betrag" :disabled="user.locked"></v-text-field>
</v-col>
<v-col cols="4">
<v-btn fab :color="color" @click="addAmountMore()" :disabled="user.locked">
<v-icon>{{plus}}</v-icon>
</v-btn>
</v-col>
</v-row>
</v-col>
<v-col align-self="center">
@ -160,7 +166,7 @@
<script>
import { mapGetters, mapActions } from 'vuex'
import { mdiMenu } from '@mdi/js'
import { mdiMenu, mdiPlus } from '@mdi/js'
import AddAmountSkeleton from './Skeleton/AddAmountSkeleton'
export default {
name: 'AddAmount',
@ -168,6 +174,8 @@ export default {
data() {
return {
color: 'green accent-4',
value: null,
plus: mdiPlus,
menu: false,
dialog: false,
componentRenderer: 0,
@ -209,6 +217,12 @@ export default {
})
}
}
},
addAmountMore() {
this.addAmount(this.value * 100)
setTimeout(() => {
this.value = null
}, 300)
}
},
computed: {

View File

@ -116,18 +116,26 @@
append-icon
>
<template v-slot:selection="data">
<v-icon>{{
<v-icon class="ma-2">{{
data.item === 'user'
? person
: data.item === 'bar'
? bar
: data.item === 'moneymaster'
? finanzer
: false
: data.item === 'gastro'
? gastro
: ''
}}</v-icon>
</template>
</v-combobox>
</v-col>
<v-col>
<v-text-field outlined :value="computeStatus" readonly label="Mitgliedsstatus"/>
</v-col>
<v-col>
<v-text-field outlined :value="user.voting ? 'ja' : 'nein'" readonly label="Stimmrecht" />
</v-col>
</v-row>
</v-card-text>
<v-card-actions>
@ -135,14 +143,19 @@
<v-btn @click="save">Save</v-btn>
</v-card-actions>
<v-expand-transition>
<v-alert type="error" v-if="error">{{error}}</v-alert>
<v-alert type="error" v-if="error">{{ error }}</v-alert>
</v-expand-transition>
</v-card>
</div>
</template>
<script>
import { mdiAccount, mdiGlassCocktail, mdiCurrencyEur } from '@mdi/js'
import {
mdiAccount,
mdiGlassCocktail,
mdiCurrencyEur,
mdiFoodForkDrink
} from '@mdi/js'
import { mapGetters, mapActions } from 'vuex'
export default {
name: 'Config',
@ -151,6 +164,7 @@ export default {
person: mdiAccount,
bar: mdiGlassCocktail,
finanzer: mdiCurrencyEur,
gastro: mdiFoodForkDrink,
username: null,
mail: null,
firstname: null,
@ -159,9 +173,9 @@ export default {
equal_password: value =>
this.password === value || 'Passwörter sind nicht identisch.',
email: value => {
if(value.length > 0) {
const pattern = /^(([^<>()[\]\\.,;:\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 pattern.test(value) || 'keine gültige E-Mail';
if (value.length > 0) {
const pattern = /^(([^<>()[\]\\.,;:\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 pattern.test(value) || 'keine gültige E-Mail'
}
return true
}
@ -169,7 +183,8 @@ export default {
},
methods: {
...mapActions({
saveConfig: 'user/saveConfig'
saveConfig: 'user/saveConfig',
getStatus: 'user/getStatus'
}),
save() {
let user = {}
@ -182,14 +197,15 @@ export default {
if (this.$refs.password.validate()) {
if (this.password) user.password = this.password
}
this.saveConfig({oldUsername: user.username, ...user})
this.saveConfig({ oldUsername: user.username, ...user })
}
},
computed: {
...mapGetters({
user: 'user/user',
error: 'user/error',
loading: 'user/loading'
loading: 'user/loading',
status: 'user/status'
}),
lock() {
return this.user.locked ? 'gesperrt' : 'nicht gesperrt'
@ -202,7 +218,13 @@ export default {
},
autoLockColor() {
return this.user.autoLock ? 'green' : 'red'
},
computeStatus() {
return this.status.find(a => a.id == this.user.statusgroup).name
}
},
created() {
this.getStatus()
}
}
</script>

View File

@ -8,16 +8,25 @@
Dienstverwaltung
</v-list-item-title>
</v-list-item>
<v-list-item link to="/main/management/usermanager">
<v-list-item-icon>
<v-icon>{{list}}</v-icon>
</v-list-item-icon>
<v-list-item-title>
Benutzerliste
</v-list-item-title>
</v-list-item>
</v-list>
</template>
<script>
import { mdiBriefcase } from '@mdi/js'
import { mdiBriefcase, mdiAccountMultiple } from '@mdi/js'
export default {
name: 'ManagementNavigation',
data() {
return {
work: mdiBriefcase
work: mdiBriefcase,
list: mdiAccountMultiple
}
}
}

View File

@ -0,0 +1,244 @@
<template>
<div>
<v-dialog v-model="editUser">
<v-card>
<v-card-title>
{{
this.editedItem.firstname +
' ' +
this.editedItem.lastname +
' bearbeiten'
}}
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col>
<v-autocomplete
v-model="editedItem.statusgroup"
label="Status"
outlined
:items="status"
item-value="id"
item-text="name"
return-object
@change="clickItem(editedItem.statusgroup)"
>
</v-autocomplete>
</v-col>
<v-col>
<v-autocomplete
v-model="editedItem.voting"
label="Stimmrecht"
outlined
:items="[
{ value: true, text: 'ja' },
{ value: false, text: 'nein' }
]"
item-text="text"
item-value="value"
:disabled="disableVoting"
return-object
/>
</v-col>
</v-row>
</v-container>
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn color="primary" text @click="close()">Abbrechen</v-btn>
<v-btn color="primary" text @click="save()">Speichern</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-data-table :headers="header" :items="users" :search="search">
<template v-slot:top>
<v-toolbar flat color="white">
<v-toolbar-title>Mitgliederliste</v-toolbar-title>
<v-spacer></v-spacer>
<v-text-field
v-model="search"
label="Sucher Mitglied"
single-line
hide-details
>
<template v-slot:append>
<v-icon>{{ searchIcon }}</v-icon>
</template>
</v-text-field>
</v-toolbar>
</template>
<template v-slot:item.statusgroup="{ item }">
{{ computeStatus(item.statusgroup) }}
</template>
<template v-slot:item.voting="{ item }">
<v-chip small :color="item.voting ? 'green' : 'red'">
{{ item.voting ? 'ja' : 'nein' }}
</v-chip>
</template>
<template v-slot:item.actions="{ item }">
<v-icon small @click="editItem(item)">{{ editIcon }}</v-icon>
</template>
</v-data-table>
<v-divider />
<v-card>
<v-card-text>
<v-container>
<v-row>
<v-col>
<v-text-field
outlined
:value="users.length"
label="Anzahl aller Mitglieder"
readonly
/>
</v-col>
<v-col>
<v-text-field
outlined
:value="allVotings"
label="Anzahl aller Stimmberechtigten"
readonly
/>
</v-col>
</v-row>
</v-container>
</v-card-text>
</v-card>
</div>
</template>
<script>
import { mdiPencil, mdiMagnify, } from '@mdi/js'
import { mapActions, mapGetters } from 'vuex'
export default {
name: 'UserManager',
data() {
return {
editIcon: mdiPencil,
searchIcon: mdiMagnify,
editUser: false,
disableVoting: null,
search: null,
header: [
{ text: 'Nachname', value: 'lastname' },
{ text: 'Vorname(n)', value: 'firstname' },
{ text: 'Status', value: 'statusgroup' },
{ text: 'Stimmrecht', value: 'voting' },
{
text: 'Aktionen',
value: 'actions',
sortable: false,
filterable: false
}
],
editedItem: {
id: -1,
firstname: null,
lastname: null,
username: null,
statusgroup: {
id: -1,
name: null
},
voting: {
value: false,
text: 'nein'
}
},
defaultItem: {
id: -1,
username: null,
statusgroup: {
id: -1,
name: null
},
voting: {
value: false,
text: 'nein'
}
}
}
},
methods: {
...mapActions({
getUsers: 'usermanager/getUsers',
getStatus: 'usermanager/getStatus',
updateStatusUser: 'usermanager/updateStatusUser',
updateVoting: 'usermanager/updateVoting'
}),
close() {
this.editUser = false
setTimeout(() => {
this.editedItem = Object.assign({}, this.defaultItem)
}, 300)
},
editItem(item) {
console.log('item', item)
this.editedItem = Object.assign({}, item)
console.log(this.editedItem)
this.editedItem.statusgroup = Object.assign(
{},
this.status.find(a => a.id == item.statusgroup)
)
this.editedItem.voting = Object.assign({},
item.voting ? {value: true, text: 'ja'} : {value: false, text: 'nein'})
this.clickItem(this.editedItem.statusgroup)
console.log(this.editedItem)
this.editUser = true
},
clickItem(item) {
switch (item.id) {
case 1:
this.editedItem.voting = { value: true, text: 'ja' }
this.disableVoting = true
break
case 2:
this.disableVoting = false
break
case 3:
this.disableVoting = true
this.editedItem.voting = { value: false, text: 'nein' }
break
case 4:
this.editedItem.voting = { value: false, text: 'nein' }
this.disableVoting = true
break
case 5:
this.editedItem.voting = { value: false, text: 'nein' }
this.disableVoting = true
break
}
},
save() {
this.updateStatusUser({username: this.editedItem.username, status: this.editedItem.statusgroup})
this.updateVoting({username: this.editedItem.username, voting: this.editedItem.voting.value})
this.close()
}
},
computed: {
...mapGetters({
users: 'usermanager/users',
status: 'usermanager/status'
}),
computeStatus() {
return id => {
return this.status.find(a => {
return a.id === id
}).name
}
},
allVotings() {
return this.users.filter(a => {
return a.voting
}).length
}
},
created() {
this.getUsers()
this.getStatus()
}
}
</script>
<style scoped></style>

View File

@ -1,10 +1,11 @@
//const main = 'https://192.168.5.128:5000/'
const main = 'http://localhost:5000/'
//const main = 'http://192.168.5.118:5000/'
//const main = 'http://localhost:5000/'
const main = 'http://192.168.5.118:5000/'
//const main = 'https://groeger-clan.duckdns.org:5000/'
const url = {
login: main + 'login',
getUsers: main + 'getUsers',
pricelist: main + 'pricelist',
getTypes: main + 'drinkTypes',
getFinanzerMain: main + 'getFinanzerMain',
@ -28,6 +29,13 @@ const url = {
deleteUser: main + 'sm/deleteUser',
getUser: main + 'sm/getUser',
lockDay: main + 'sm/lockDay'
},
um: {
setStatus: main + 'um/setStatus',
updateStatus: main + 'um/updateStatus',
deleteStatus: main + 'um/deleteStatus',
updateStatusUser: main + 'um/updateStatusUser',
updateVoting: main + 'um/updateVoting'
}
},
user: {
@ -40,7 +48,9 @@ const url = {
jobRequests: main + 'user/jobRequests',
getTransactJobs: main + 'user/getTransactJobs',
deleteTransactJobs: main + 'user/deleteTransactJob',
storno: main + 'user/storno'
storno: main + 'user/storno',
getAllStatus: main + 'getAllStatus',
getStatus: main + 'getStatus'
},
barU: {
storno: main + 'bar/storno'

View File

@ -22,6 +22,7 @@ import PriceList from '@/components/pricelist/PriceList'
import ManagementNavigation from "@/components/vorstand/ManagementNavigation";
import GastroNavigation from "@/components/gastro/GastroNavigation";
import PriceListView from "@/views/contents/PriceListView";
import UserManager from "@/components/vorstand/UserManager";
Vue.use(VueRouter)
@ -49,6 +50,10 @@ const routes = [
{
path: 'servicemanagement',
component: ServiceManagement
},
{
path: 'usermanager',
component: UserManager
}
]
},

View File

@ -8,6 +8,7 @@ import sm from '@/store/modules/serviceManagement'
import jobs from '@/store/modules/jobs'
import requestJobs from '@/store/modules/jobRequests'
import priceList from '@/store/modules/pricelist'
import usermanager from '@/store/modules/userManager'
Vue.use(Vuex)
@ -20,6 +21,7 @@ export default new Vuex.Store({
sm,
jobs,
requestJobs,
priceList
priceList,
usermanager
}
})

View File

@ -136,7 +136,11 @@ const actions = {
commit('setUsersLoading', false)
},
async addAmount({ commit, rootState, dispatch }, data) {
commit('updateUser', { username: data.username, loading: true })
try {
commit('updateUser', {username: data.username, loading: true})
} catch (e) {
console.log(e)
}
try {
const response = await axios.post(
url.barAddAmount,
@ -158,10 +162,18 @@ const actions = {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
commit('updateUser', { username: data.username, loading: false })
try {
commit('updateUser', {username: data.username, loading: false})
} catch (e) {
console.log(e)
}
},
async addCreditList({ commit, rootState, dispatch }, data) {
commit('updateUser', { username: data.username, loading: true })
try {
commit('updateUser', {username: data.username, loading: true})
} catch (e) {
console.log(e)
}
try {
const response = await axios.post(
url.barGetUser,
@ -173,7 +185,11 @@ const actions = {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
commit('updateUser', { username: data.username, loading: false })
try {
commit('updateUser', {username: data.username, loading: false})
} catch (e) {
console.log(e)
}
},
async getAllUsers({ commit, rootState, dispatch }) {
commit('setAllUsersLoading', true)

View File

@ -8,10 +8,14 @@ const state = {
addLoading: false,
error: '',
days: [],
message: []
message: [],
status: []
}
const mutations = {
setStatus: (state, status) => {
state.status = status
},
setUser: (state, user) => {
state.user = user
let list = {}
@ -311,6 +315,17 @@ const actions = {
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
commit('updateMessage', { date: data.date, loading: false })
},
async getStatus({commit, rootState, dispatch }) {
try {
const response = await axios.get(url.user.getAllStatus, {
headers: { Token: rootState.login.user.accessToken }
})
commit('setStatus', response.data)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
}
}
@ -340,6 +355,9 @@ const getters = {
},
messages: state => {
return state.message
},
status: state => {
return state.status
}
}

View File

@ -0,0 +1,163 @@
import url from '@/plugins/routes'
import axios from 'axios'
const state = {
users: [],
status: []
}
const mutations = {
setUsers: (state, users) => {
state.users = users
},
setStatus: (state, status) => {
state.status = status
},
updateUser: (state, user) => {
let exists = state.users.find(a => {
return a.username === user.username
})
if (exists) {
exists.firstname = user.firstname
exists.lastname = user.lastname
exists.mail = user.mail
exists.statusgroup = user.statusgroup
exists.voting = user.voting
} else {
state.users.push({
username: user.username,
firstname: user.firstname,
lastname: user.lastname,
mail: user.mail,
statusgroup: user.statusgroup,
voting: user.voting
})
}
},
updateStatus: (state, status) => {
let exists = state.status.find(a => {
return a.id === status.id
})
if (exists) {
exists.name = status.name
} else {
state.status.push(status)
}
},
deleteStatus: (state, status) => {
let index = state.status.indexOf(
state.status.find(a => {
return a.id === status.id
})
)
state.status.splice(index, 1)
}
}
const actions = {
async getUsers({ commit, rootState, dispatch }) {
try {
const response = await axios.get(url.getUsers, {
headers: { Token: rootState.login.user.accessToken }
})
commit('setUsers', response.data)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async getStatus({ commit, rootState, dispatch }) {
try {
const response = await axios.get(url.user.getAllStatus, {
headers: { Token: rootState.login.user.accessToken }
})
commit('setStatus', response.data)
} 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) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async updateStatusUser({ commit, rootState, dispatch }, data) {
try {
const response = await axios.post(
url.vorstand.um.updateStatusUser,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateUser', response.data)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async updateVoting({ commit, rootState, dispatch }, data) {
try {
const response = await axios.post(
url.vorstand.um.updateVoting,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateUser', response.data)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
}
}
const getters = {
users: state => {
return state.users
},
status: state => {
return state.status
}
}
export default {
namespaced: true,
state,
mutations,
actions,
getters
}