From e0697b2a6d3db8dda677f98c1b8d16c0b9c8cb82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Thu, 27 Feb 2020 21:54:28 +0100 Subject: [PATCH 1/3] finished ##172 --- src/components/pricelist/PriceList.vue | 125 +++++++++++++++++++++++++ src/plugins/routes.js | 1 + src/router/index.js | 6 ++ src/store/index.js | 4 +- src/store/modules/pricelist.js | 37 ++++++++ 5 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 src/components/pricelist/PriceList.vue create mode 100644 src/store/modules/pricelist.js diff --git a/src/components/pricelist/PriceList.vue b/src/components/pricelist/PriceList.vue new file mode 100644 index 0000000..5636d3b --- /dev/null +++ b/src/components/pricelist/PriceList.vue @@ -0,0 +1,125 @@ + + + + + diff --git a/src/plugins/routes.js b/src/plugins/routes.js index a9dd05f..67def58 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -5,6 +5,7 @@ const main = 'http://localhost:5000/' const url = { login: main + 'login', + pricelist: main + 'pricelist', getFinanzerMain: main + 'getFinanzerMain', bar: main + 'bar', barGetUser: main + 'barGetUser', diff --git a/src/router/index.js b/src/router/index.js index 8f46419..3e8c8ab 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -18,10 +18,16 @@ import ServiceManagement from '../components/vorstand/ServiceManagement' import Config from '@/components/user/Config' import Jobs from '@/components/user/Jobs' import JobRequests from '@/components/user/JobRequests' +import PriceList from "@/components/pricelist/PriceList"; Vue.use(VueRouter) const routes = [ + { + path: '/pricelist', + name: 'priceListNoLogin', + component: PriceList + }, { path: '/login', name: 'login', diff --git a/src/store/index.js b/src/store/index.js index 2890a75..0398961 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -7,6 +7,7 @@ import user from '@/store/modules/user' import sm from '@/store/modules/serviceManagement' import jobs from '@/store/modules/jobs' import requestJobs from '@/store/modules/jobRequests' +import priceList from '@/store/modules/pricelist' Vue.use(Vuex) @@ -18,6 +19,7 @@ export default new Vuex.Store({ user, sm, jobs, - requestJobs + requestJobs, + priceList } }) diff --git a/src/store/modules/pricelist.js b/src/store/modules/pricelist.js new file mode 100644 index 0000000..67f0461 --- /dev/null +++ b/src/store/modules/pricelist.js @@ -0,0 +1,37 @@ +import url from '@/plugins/routes' +import axios from 'axios' + +const state = { + priceList: [] +} + +const mutations = { + setPriceList: (state, priceList) => { + state.priceList = priceList + } +} + +const actions = { + async getPriceList({ commit }) { + try { + const response = await axios.get(url.pricelist) + commit('setPriceList', response.data) + } catch (e) { + console.log(e) + } + } +} + +const getters = { + priceList: state => { + return state.priceList + } +} + +export default { + namespaced: true, + state, + mutations, + actions, + getters +} From afa8945f66a3e44d1e7aa20f8adf76f4f3e90314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Thu, 27 Feb 2020 22:19:31 +0100 Subject: [PATCH 2/3] add Icon to go to pricelist --- src/components/TitleBar.vue | 16 ++++++++++------ src/plugins/routes.js | 4 ++-- src/router/index.js | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/components/TitleBar.vue b/src/components/TitleBar.vue index 78e580d..23ee238 100644 --- a/src/components/TitleBar.vue +++ b/src/components/TitleBar.vue @@ -1,25 +1,28 @@ + + diff --git a/src/components/pricelist/PriceList.vue b/src/components/pricelist/PriceList.vue index 5636d3b..25ec347 100644 --- a/src/components/pricelist/PriceList.vue +++ b/src/components/pricelist/PriceList.vue @@ -1,10 +1,10 @@ diff --git a/src/components/vorstand/ManagementNavigation.vue b/src/components/vorstand/ManagementNavigation.vue new file mode 100644 index 0000000..8db8cf6 --- /dev/null +++ b/src/components/vorstand/ManagementNavigation.vue @@ -0,0 +1,26 @@ + + + + + diff --git a/src/components/vorstand/ServiceManagement.vue b/src/components/vorstand/ServiceManagement.vue index d951ba3..1e4d562 100644 --- a/src/components/vorstand/ServiceManagement.vue +++ b/src/components/vorstand/ServiceManagement.vue @@ -1,51 +1,49 @@ @@ -100,7 +98,12 @@ export default { for (var week in this.month) { for (var dayint in this.month[week].days) { var day = this.month[week].days[dayint] - this.lockDay({year: day.date.getFullYear(), month: day.date.getMonth() + 1, day: day.date.getDate(), locked: value}) + this.lockDay({ + year: day.date.getFullYear(), + month: day.date.getMonth() + 1, + day: day.date.getDate(), + locked: value + }) } } } diff --git a/src/plugins/routes.js b/src/plugins/routes.js index c982777..86df7f1 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -1,11 +1,12 @@ //const main = 'https://192.168.5.128:5000/' //const main = 'http://localhost:5000/' -//const main = 'http://192.168.5.118:5000/' -const main = 'https://groeger-clan.duckdns.org:5000/' +const main = 'http://192.168.5.118:5000/' +//const main = 'https://groeger-clan.duckdns.org:5000/' const url = { login: main + 'login', pricelist: main + 'pricelist', + getTypes: main + 'drinkTypes', getFinanzerMain: main + 'getFinanzerMain', bar: main + 'bar', barGetUser: main + 'barGetUser', @@ -43,6 +44,14 @@ const url = { }, barU: { storno: main + 'bar/storno' + }, + gastro: { + setDrink: main + 'gastro/setDrink', + updateDrink: main + 'gastro/updateDrink', + deleteDrink: main + 'gastro/deleteDrink', + setType: main + 'gastro/setDrinkType', + updateType: main + 'gastro/updateDrinkType', + deleteType: main + 'gastro/deleteDrinkType' } } diff --git a/src/router/index.js b/src/router/index.js index a996d80..2a9774f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -18,7 +18,10 @@ import ServiceManagement from '../components/vorstand/ServiceManagement' import Config from '@/components/user/Config' import Jobs from '@/components/user/Jobs' import JobRequests from '@/components/user/JobRequests' -import PriceList from "@/components/pricelist/PriceList"; +import PriceList from '@/components/pricelist/PriceList' +import ManagementNavigation from "@/components/vorstand/ManagementNavigation"; +import GastroNavigation from "@/components/gastro/GastroNavigation"; +import PriceListView from "@/views/contents/PriceListView"; Vue.use(VueRouter) @@ -26,7 +29,7 @@ const routes = [ { path: '/pricelist', name: 'priceListNoLogin', - component: PriceList + component: PriceListView }, { path: '/login', @@ -38,10 +41,21 @@ const routes = [ name: 'main', component: MainView, children: [ + { + path: 'management', + name: 'management', + components: { nav: ManagementNavigation, default: BarView}, + children: [ + { + path: 'servicemanagement', + component: ServiceManagement + } + ] + }, { path: 'user', name: 'user', - components: { userNav: UserNavigation, default: UserView }, + components: { nav: UserNavigation, default: UserView }, children: [ { path: 'add', @@ -73,7 +87,7 @@ const routes = [ { path: 'bar', name: 'bar', - components: { userNav: BarNavigation, default: BarView }, + components: { nav: BarNavigation, default: BarView }, children: [ { path: 'geruecht', @@ -85,7 +99,7 @@ const routes = [ { path: 'finanzer', name: 'finanzer', - components: { default: FinanzerView, finanzerNav: FinanzerNavigation }, + components: { default: FinanzerView, nav: FinanzerNavigation }, children: [ { path: 'overview', @@ -96,10 +110,18 @@ const routes = [ name: 'activeUser', props: true, component: User - }, + } + ] + }, + { + path: 'gastro', + name: 'gastro', + components: { nav: GastroNavigation, default: BarView}, + children: [ { - path: 'servicemanagement', - component: ServiceManagement + path: 'pricelist', + name: 'gastroPricelist', + component: PriceList } ] } diff --git a/src/store/modules/login.js b/src/store/modules/login.js index 4f778a9..2575952 100644 --- a/src/store/modules/login.js +++ b/src/store/modules/login.js @@ -115,27 +115,41 @@ const getters = { }, isBar: state => { try { - return state.user.group.includes('bar') ? true : false + return state.user.group.includes('bar') } catch (e) { return false } }, isFinanzer: state => { try { - return state.user.group.includes('moneymaster') ? true : false + return state.user.group.includes('moneymaster') } catch (e) { return false } }, isUser: state => { try { - return state.user.group.includes('user') ? true : false + return state.user.group.includes('user') + } catch (e) { + return false + } + }, + isGastro: state => { + try { + return state.user.group.includes('gastro') + } catch (e) { + return false + } + }, + isManagement: state => { + try { + return state.user.group.includes('management') || state.user.group.includes('gastro') || state.user.group.includes('moneymaster') } catch (e) { return false } }, isLoggedIn: state => { - return state.user.accessToken ? true : false + return state.user.accessToken }, user: state => { return state.user diff --git a/src/store/modules/pricelist.js b/src/store/modules/pricelist.js index 67f0461..79df600 100644 --- a/src/store/modules/pricelist.js +++ b/src/store/modules/pricelist.js @@ -2,12 +2,87 @@ import url from '@/plugins/routes' import axios from 'axios' const state = { - priceList: [] + priceList: [], + types: [] } const mutations = { setPriceList: (state, priceList) => { state.priceList = priceList + }, + setTypes: (state, types) => { + state.types = types + state.types.sort((a, b) => { + const low = b.name.toLowerCase() + const high = a.name.toLowerCase() + if (high < low) return -1 + if (high > low) return 1 + return 0 + }) + }, + updatePriceList: (state, drink) => { + var a = state.priceList.find(b => { + return b.id === drink.id + }) + if (a) { + a.name = drink.name + a.type = drink.type + a.price = drink.price + a.price_big = drink.price_big + a.price_club = drink.price_club + a.price_club_big = drink.price_club_big + a.premium = drink.premium + a.premium_club = drink.premium_club + a.price_extern_club = drink.price_extern_club + } else { + state.priceList.push({ + id: drink.id, + name: drink.name, + type: drink.type, + price: drink.price, + price_big: drink.price_big, + price_club: drink.price_club, + price_club_big: drink.price_club_big, + premium: drink.premium, + premium_club: drink.premium_club, + price_extern_club: drink.price_extern_club + }) + } + }, + deleteDrinkPrice: (state, data) => { + var index = state.priceList.indexOf( + state.priceList.find(a => { + return a.id === data.id + }) + ) + state.priceList.splice(index, 1) + }, + updateDrinkType: (state, type) => { + var a = state.types.find(b => { + return b.id === type.id + }) + if (a) { + a.name = type.name + } else { + state.types.push({ + ...type + }) + } + state.types.sort((a, b) => { + const low = b.name.toLowerCase() + const high = a.name.toLowerCase() + if (high < low) return -1 + if (high > low) return 1 + return 0 + }) + }, + deleteDrinkType: (state, type) => { + var index = state.types.indexOf( + state.types.find(a => { + return a.id === type.id + }) + ) + state.types.splice(index, 1) } } @@ -19,12 +94,102 @@ const actions = { } catch (e) { console.log(e) } + }, + async getTypes({ commit, dispatch }) { + try { + const response = await axios.get(url.getTypes) + commit('setTypes', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async setDrink({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.gastro.setDrink, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updatePriceList', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async updateDrink({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.gastro.updateDrink, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updatePriceList', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async deleteDrink({ commit, rootState, dispatch }, data) { + try { + await axios.post( + url.gastro.deleteDrink, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('deleteDrinkPrice', data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async setDrinkType({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.gastro.setType, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updateDrinkType', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async updateDrinkType({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.gastro.updateType, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updateDrinkType', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async deleteDrinkType({ commit, rootState, dispatch }, data) { + try { + await axios.post( + url.gastro.deleteType, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('deleteDrinkType', data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } } } const getters = { priceList: state => { return state.priceList + }, + types: state => { + return state.types } } diff --git a/src/views/MainView.vue b/src/views/MainView.vue index 85b04f8..482c4ed 100644 --- a/src/views/MainView.vue +++ b/src/views/MainView.vue @@ -24,6 +24,22 @@ Bar + + + {{king}} + + + Vorstand + + + + + {{gastro}} + + + Gastro + + {{attach_money}} @@ -32,9 +48,7 @@ - - - +