diff --git a/src/App.vue b/src/App.vue index c7f8c6a..82cdfcc 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,6 +1,11 @@ diff --git a/src/components/TitleBar.vue b/src/components/TitleBar.vue index 8786ea9..4f42380 100644 --- a/src/components/TitleBar.vue +++ b/src/components/TitleBar.vue @@ -13,7 +13,10 @@ WU5-Dashboard - + + attach_money + + local_bar Logout @@ -26,8 +29,19 @@ export default { name: "TitleBar", computed: { + isBar() { + try { + return this.$store.getters.getGroup.includes('bar') ? true : false + } catch (e) { + return false + } + }, isFinanzer() { - return this.$store.getters.getGroup === 'moneymaster' ? true : false + try { + return this.$store.getters.getGroup.includes('moneymaster') ? true : false + } catch (e) { + return false + } }, isLoggedIn() { return this.$store.getters.getToken diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index 3c5bf21..4ddf330 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -1,72 +1,68 @@ diff --git a/src/components/baruser/SearchBar.vue b/src/components/baruser/SearchBar.vue new file mode 100644 index 0000000..c5708ca --- /dev/null +++ b/src/components/baruser/SearchBar.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/src/components/finanzer/Overview.vue b/src/components/finanzer/Overview.vue index 11a1c8b..a853c77 100644 --- a/src/components/finanzer/Overview.vue +++ b/src/components/finanzer/Overview.vue @@ -1,16 +1,207 @@ diff --git a/src/components/finanzer/Table.vue b/src/components/finanzer/Table.vue new file mode 100644 index 0000000..2890c27 --- /dev/null +++ b/src/components/finanzer/Table.vue @@ -0,0 +1,118 @@ + + + + + diff --git a/src/components/finanzer/User.vue b/src/components/finanzer/User.vue new file mode 100644 index 0000000..34c4b46 --- /dev/null +++ b/src/components/finanzer/User.vue @@ -0,0 +1,78 @@ + + + + + diff --git a/src/plugins/restService.js b/src/plugins/restService.js index 376f79b..8afa437 100644 --- a/src/plugins/restService.js +++ b/src/plugins/restService.js @@ -19,8 +19,22 @@ class Service { console.log("addAmountdata: ", data) return axios.post(this.url+'baradd', {...data}, {headers: {Token: token}}) } + addAmountFinanzer(token, data) { + return axios.post(this.url+'finanzerAddAmount', {...data}, {headers: {Token: token}}) + } + addCreditFinanzer(token, data) { + // eslint-disable-next-line no-console + console.log('data', data) + return axios.post(this.url+'finanzerAddCredit', {...data}, {headers: {Token: token}}) + } + searchUser(token, data) { + return axios.post(this.url+'search', {...data}, {headers: {Token: token}}) + } + getAllUser(token) { + return axios.get(this.url+'barGetUsers', {headers: {Token: token}}) + } } -const httpClient = new Service("http://192.168.5.118:5000/") +const httpClient = new Service("http://localhost:5000/") export default httpClient diff --git a/src/router/index.js b/src/router/index.js index 62d9f01..7bea60f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -41,14 +41,30 @@ const router = new VueRouter({ router.beforeEach((to, from, next) => { store.dispatch('fetchAccessToken'); - if (to.fullPath === '/finanzer') { + let sites = ['/finanzer', '/bar'] + if (sites.includes(to.fullPath)) { + if (to.fullPath === '/finanzer') { + if (!store.state.user.group.includes('moneymaster')) { + next('/login') + } + } + if (to.fullPath === '/bar') { + if (!store.state.user.group.includes('bar')) { + next('/login') + } + } if (!store.state.user.accessToken) { next('/login') } } if (to.fullPath === '/login') { if (store.state.user.accessToken) { - next('/finanzer') + if (store.state.user.group.includes('moneymaster')) { + next('/finanzer') + } else if (store.state.user.group.includes('bar')) { + next('/bar') + } + } } next(); diff --git a/src/store/index.js b/src/store/index.js index b4e0d3e..4c6153b 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -56,10 +56,10 @@ export default new Vuex.Store({ localStorage.setItem('user', JSON.stringify({ username: response.data.username, accessToken: response.data.token, group: response.data.group})); commit('loginStop', null); commit('updateAccessToken', response.data) - if (this.state.user.group === 'moneymaster') { + if (this.state.user.group.includes('moneymaster')) { router.push('/finanzer'); } - if (this.state.user.group === 'bar') { + else if (this.state.user.group.includes('bar')) { router.push('/bar') } }) diff --git a/src/views/BarView.vue b/src/views/BarView.vue index cbdc99e..3b70549 100644 --- a/src/views/BarView.vue +++ b/src/views/BarView.vue @@ -1,7 +1,10 @@ @@ -11,9 +14,10 @@ import httpClient from "../plugins/restService"; // eslint-disable-next-line no-unused-vars import axios from "axios"; + import SearchBar from "../components/baruser/SearchBar"; export default { name: "BarView", - components: {CreditLists, TitleBar}, + components: {SearchBar, CreditLists, TitleBar}, created() { this.getUser() }, @@ -48,6 +52,11 @@ this.$store.dispatch("logout") this.users = [] }) + this.users = this.users.sort((a,b) => { + if (a.username > b.username) return 1 + if (a.username < b.username) return -1 + return 0 + }) }, // eslint-disable-next-line no-unused-vars addAmount(username, amount) { @@ -64,6 +73,23 @@ }) user.amount = response.data.amount }) + }, + addCreditList(user) { + // eslint-disable-next-line no-console + console.log('addCreditlist: ', user) + if (!this.users.find(user1 => { + return user1.username === user.username + })) { + const lastId = this.users.length > 0 ? this.users[this.users.length - 1].id : 0 + this.users.push({ + id: lastId + 1, + username: user.username, + firstname: user.firstname, + lastname: user.lastname, + amount: 0, + type: null + }) + } } } } diff --git a/src/views/FinanzerView.vue b/src/views/FinanzerView.vue index 2a80ef1..05f0f9f 100644 --- a/src/views/FinanzerView.vue +++ b/src/views/FinanzerView.vue @@ -1,15 +1,30 @@ @@ -17,19 +32,33 @@