From 7ab0af4119cd3665405d0daf5f2aafe20afadfaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 3 Mar 2020 22:29:32 +0100 Subject: [PATCH 1/4] finished ##209 --- .../vorstand/ManagementNavigation.vue | 13 +- src/components/vorstand/UserManager.vue | 244 ++++++++++++++++++ src/plugins/routes.js | 16 +- src/router/index.js | 5 + src/store/index.js | 4 +- src/store/modules/user.js | 17 +- src/store/modules/userManager.js | 163 ++++++++++++ 7 files changed, 455 insertions(+), 7 deletions(-) create mode 100644 src/components/vorstand/UserManager.vue create mode 100644 src/store/modules/userManager.js diff --git a/src/components/vorstand/ManagementNavigation.vue b/src/components/vorstand/ManagementNavigation.vue index 8db8cf6..e44743d 100644 --- a/src/components/vorstand/ManagementNavigation.vue +++ b/src/components/vorstand/ManagementNavigation.vue @@ -8,16 +8,25 @@ Dienstverwaltung + + + {{list}} + + + Benutzerliste + + + + diff --git a/src/plugins/routes.js b/src/plugins/routes.js index dce9525..5353996 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -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' diff --git a/src/router/index.js b/src/router/index.js index 2a9774f..1f27c0e 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -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 } ] }, diff --git a/src/store/index.js b/src/store/index.js index 0398961..7af2bb4 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -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 } }) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index eb682d9..4036091 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -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.post(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 }) + } } } diff --git a/src/store/modules/userManager.js b/src/store/modules/userManager.js new file mode 100644 index 0000000..094cf7a --- /dev/null +++ b/src/store/modules/userManager.js @@ -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 +} From 11b8df2251fd1f76283be1ac06b89b89b4f01f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 3 Mar 2020 22:50:47 +0100 Subject: [PATCH 2/4] finished ##210 --- src/components/user/Config.vue | 42 ++++++++++++++++++++++++++-------- src/store/modules/user.js | 5 +++- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/components/user/Config.vue b/src/components/user/Config.vue index 160542c..a5c9dbf 100644 --- a/src/components/user/Config.vue +++ b/src/components/user/Config.vue @@ -116,18 +116,26 @@ append-icon > + + + + + + @@ -135,14 +143,19 @@ Save - {{error}} + {{ error }} diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 4036091..4d1e4d2 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -318,7 +318,7 @@ const actions = { }, async getStatus({commit, rootState, dispatch }) { try { - const response = await axios.post(url.user.getAllStatus, { + const response = await axios.get(url.user.getAllStatus, { headers: { Token: rootState.login.user.accessToken } }) commit('setStatus', response.data) @@ -355,6 +355,9 @@ const getters = { }, messages: state => { return state.message + }, + status: state => { + return state.status } } From 4316e1b79187577f2d3a23adafb283ff6116fccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 3 Mar 2020 23:28:05 +0100 Subject: [PATCH 3/4] add customfield for baruser to addAmount of a custom value --- src/components/baruser/CreditLists.vue | 57 ++++++++++++++++---------- src/store/modules/barUsers.js | 24 +++++++++-- 2 files changed, 56 insertions(+), 25 deletions(-) diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index 9f2e039..aaa6bf5 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -64,7 +64,7 @@ - + 2 € + >2 € + - + 1 € + >1 € + - + 0,50 € + >0,50 € + - - - + 0,40 € + >0,40 € + - + 0,20 € + >0,20 € + - + 0,10 € + >0,10 € + + + + + + + + {{plus}} + @@ -203,6 +209,7 @@