From d53f17ef3b7c054f685ca47a2bf6d21e13ad1bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sat, 21 Dec 2019 10:51:41 +0100 Subject: [PATCH 001/117] added exported httpClient for axios --- src/plugins/restService.js | 18 ++++++++++++++++++ src/store/index.js | 6 ++---- src/views/FinanzerView.vue | 24 ++++++++++++++---------- 3 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 src/plugins/restService.js diff --git a/src/plugins/restService.js b/src/plugins/restService.js new file mode 100644 index 0000000..f66b65e --- /dev/null +++ b/src/plugins/restService.js @@ -0,0 +1,18 @@ +import axios from 'axios' + +class Service { + constructor(url) { + this.url = url + } + getFinanzerMain(token) { + return axios.get(this.url + "getFinanzerMain", {headers: {Token: token}}) + + } + login(loginData) { + return axios.post(this.url+'login', {...loginData}) + } +} + +const httpClient = new Service("http://192.168.5.118:5000/") + +export default httpClient diff --git a/src/store/index.js b/src/store/index.js index bbf678d..b4e0d3e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,12 +1,10 @@ import Vue from 'vue' import Vuex from 'vuex' import router from "@/router"; -import axios from 'axios' +import httpClient from "../plugins/restService"; Vue.use(Vuex) -const url = 'http://localhost:5000/' - export default new Vuex.Store({ state: { user: { @@ -53,7 +51,7 @@ export default new Vuex.Store({ // eslint-disable-next-line no-console console.log("loginData:", loginData) commit('loginStart'); - axios.post(url+'login', {...loginData}) + httpClient.login(loginData) .then(response => { localStorage.setItem('user', JSON.stringify({ username: response.data.username, accessToken: response.data.token, group: response.data.group})); commit('loginStop', null); diff --git a/src/views/FinanzerView.vue b/src/views/FinanzerView.vue index d4205ed..2a80ef1 100644 --- a/src/views/FinanzerView.vue +++ b/src/views/FinanzerView.vue @@ -16,7 +16,7 @@ diff --git a/src/plugins/restService.js b/src/plugins/restService.js index f66b65e..15a1e01 100644 --- a/src/plugins/restService.js +++ b/src/plugins/restService.js @@ -11,6 +11,12 @@ class Service { login(loginData) { return axios.post(this.url+'login', {...loginData}) } + getUserBar(token) { + return axios.get(this.url+'bar', {headers: {Token: token}}) + } + addAmountBar(token, data) { + return axios.post(this.url+'baradd', ...data, {headers: {Token: token}}) + } } const httpClient = new Service("http://192.168.5.118:5000/") diff --git a/src/views/BarView.vue b/src/views/BarView.vue index deb8c9b..a9cf34c 100644 --- a/src/views/BarView.vue +++ b/src/views/BarView.vue @@ -1,33 +1,61 @@ diff --git a/src/plugins/restService.js b/src/plugins/restService.js index 15a1e01..376f79b 100644 --- a/src/plugins/restService.js +++ b/src/plugins/restService.js @@ -15,7 +15,9 @@ class Service { return axios.get(this.url+'bar', {headers: {Token: token}}) } addAmountBar(token, data) { - return axios.post(this.url+'baradd', ...data, {headers: {Token: token}}) + // eslint-disable-next-line no-console + console.log("addAmountdata: ", data) + return axios.post(this.url+'baradd', {...data}, {headers: {Token: token}}) } } diff --git a/src/views/BarView.vue b/src/views/BarView.vue index a9cf34c..cbdc99e 100644 --- a/src/views/BarView.vue +++ b/src/views/BarView.vue @@ -9,6 +9,7 @@ import TitleBar from "@/components/TitleBar"; import CreditLists from "@/components/baruser/CreditLists"; import httpClient from "../plugins/restService"; + // eslint-disable-next-line no-unused-vars import axios from "axios"; export default { name: "BarView", @@ -24,6 +25,7 @@ methods: { getUser() { // eslint-disable-next-line no-console + this. users = [] httpClient.getUserBar(this.$store.getters.getToken) .then(response => { // eslint-disable-next-line no-console @@ -35,27 +37,33 @@ username: response.data[user].username, firstname: response.data[user].firstname, lastname: response.data[user].lastname, - amount: response.data[user].amount + amount: response.data[user].amount, + type: response.data[user].type }) } }) .catch(error => { // eslint-disable-next-line no-console console.log(error) + this.$store.dispatch("logout") this.users = [] }) }, + // eslint-disable-next-line no-unused-vars addAmount(username, amount) { - axios.post('http://192.168.5.118:5000/baradd', {userId: username, amount: amount}, {headers: {Token: this.$store.getters.getToken}}) - //httpClient.addAmountBar(this.$store.getters.getToken, {username: username, amount: amount}) - /*.then(response => { + httpClient.addAmountBar(this.$store.getters.getToken, {userId: username, amount: amount}) + .then((response) => { + // eslint-disable-next-line no-console - console.log("responsedata: ", response.data) + console.log(response.data) + + let user = this.users.find(user => { + // eslint-disable-next-line no-console + console.log(user) + return user.username === username ? user : false + }) + user.amount = response.data.amount }) - .catch(error => { - // eslint-disable-next-line no-console - console.log("error: ", error.response.data.error) - })*/ } } } From 3e081f2bb547bb9896c499c5e93f5708afc2bbc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Thu, 26 Dec 2019 10:31:36 +0100 Subject: [PATCH 004/117] first useable site barview and finanzerview bar : can add new person to geruecht finanzer: can see overview can see view for 1 person --- src/App.vue | 5 + src/components/TitleBar.vue | 18 ++- src/components/baruser/CreditLists.vue | 126 ++++++++-------- src/components/baruser/SearchBar.vue | 68 +++++++++ src/components/finanzer/Overview.vue | 197 ++++++++++++++++++++++++- src/components/finanzer/Table.vue | 118 +++++++++++++++ src/components/finanzer/User.vue | 78 ++++++++++ src/plugins/restService.js | 16 +- src/router/index.js | 20 ++- src/store/index.js | 4 +- src/views/BarView.vue | 30 +++- src/views/FinanzerView.vue | 133 +++++++++++++++-- 12 files changed, 727 insertions(+), 86 deletions(-) create mode 100644 src/components/baruser/SearchBar.vue create mode 100644 src/components/finanzer/Table.vue create mode 100644 src/components/finanzer/User.vue 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 @@ diff --git a/src/plugins/restService.js b/src/plugins/restService.js index aeacc95..ddcb951 100644 --- a/src/plugins/restService.js +++ b/src/plugins/restService.js @@ -15,16 +15,12 @@ class Service { return axios.get(this.url+'bar', {headers: {Token: token}}) } addAmountBar(token, data) { - // eslint-disable-next-line no-console - 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) { @@ -33,9 +29,16 @@ class Service { getAllUser(token) { return axios.get(this.url+'barGetUsers', {headers: {Token: token}}) } + lockUser(token, data) { + return axios.post(this.url+'finanzerLock', {...data}, {headers: {Token: token}}) + } + finanzerSetConfig(token, data) { + return axios.post(this.url+'finanzerSetConfig', {...data}, {headers: {Token: token}}) + } } +const httpClient = new Service("http://localhost:5000/") //const httpClient = new Service("http://192.168.5.118:5000/") -const httpClient = new Service("http://groeger-clan.duckdns.org:5000/") +//const httpClient = new Service("http://groeger-clan.duckdns.org:5000/") export default httpClient diff --git a/src/store/index.js b/src/store/index.js index 4c6153b..8d4f7b4 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -26,8 +26,6 @@ export default new Vuex.Store({ if (typeof(data) === typeof("")) { data = JSON.parse(data) } - // eslint-disable-next-line no-console - console.log("updateAccessToken data:", typeof (data), data) if (data === null || data === undefined) { state.user.username = null; state.user.accessToken = null; @@ -36,8 +34,6 @@ export default new Vuex.Store({ this.state.user.username = data.username; state.user.accessToken = data.accessToken; state.user.group = data.group; - // eslint-disable-next-line no-console - console.log("state: ", state.user) } }, logout (state) { @@ -48,8 +44,6 @@ export default new Vuex.Store({ }, actions: { doLogin({ commit }, loginData) { - // eslint-disable-next-line no-console - console.log("loginData:", loginData) commit('loginStart'); httpClient.login(loginData) .then(response => { @@ -69,8 +63,6 @@ export default new Vuex.Store({ }) }, fetchAccessToken({ commit }) { - // eslint-disable-next-line no-console - console.log("localStorage: ", localStorage.getItem('user')) commit('updateAccessToken', localStorage.getItem('user')) }, logout({ commit }) { diff --git a/src/views/BarView.vue b/src/views/BarView.vue index 2f1723e..f01e384 100644 --- a/src/views/BarView.vue +++ b/src/views/BarView.vue @@ -32,8 +32,6 @@ this. users = [] httpClient.getUserBar(this.$store.getters.getToken) .then(response => { - // eslint-disable-next-line no-console - console.log(response.data) for (let user in response.data) { const lastId = this.users.length > 0 ? this.users[this.users.length - 1].id : 0 this.users.push({ @@ -41,6 +39,7 @@ username: response.data[user].username, firstname: response.data[user].firstname, lastname: response.data[user].lastname, + locked: response.data[user].locked, amount: response.data[user].amount, type: response.data[user].type }) @@ -48,7 +47,7 @@ }) .catch(error => { if (error.response) { - if (error.response.status == 401) { + if (error.response.status === 401) { this.$store.dispatch('logout') } } @@ -64,20 +63,14 @@ addAmount(username, amount) { httpClient.addAmountBar(this.$store.getters.getToken, {userId: username, amount: amount}) .then((response) => { - - // eslint-disable-next-line no-console - console.log(response.data) - let user = this.users.find(user => { - // eslint-disable-next-line no-console - console.log(user) return user.username === username ? user : false }) user.amount = response.data.amount }) .catch(error => { if (error.response) { - if (error.response.status == 401) { + if (error.response.status === 401) { this.$store.dispatch('logout') } } @@ -85,8 +78,6 @@ }) }, addCreditList(user) { - // eslint-disable-next-line no-console - console.log('addCreditlist: ', user) if (!this.users.find(user1 => { return user1.username === user.username })) { diff --git a/src/views/FinanzerView.vue b/src/views/FinanzerView.vue index 88a4794..70ddb36 100644 --- a/src/views/FinanzerView.vue +++ b/src/views/FinanzerView.vue @@ -24,7 +24,7 @@ - + @@ -51,8 +51,6 @@ }, methods: { test (e) { - // eslint-disable-next-line no-console - console.log("event: ", e) if (this.activeUser.username === e.username) { this.activeUser = {username: null} } else { @@ -121,31 +119,25 @@ getUser() { httpClient.getFinanzerMain(this.$store.getters.getToken) .then(response => { - // eslint-disable-next-line no-console - console.log("ich bin hier. response: ", response.data) for (let user in response.data) { - // eslint-disable-next-line no-console - console.log("user: ", user) const lastId = this.users.length > 0 ? this.users[this.users.length - 1].id : 0 // eslint-disable-next-line no-unused-vars let list = {} for (let creditList in response.data[user]['creditList']) { - // eslint-disable-next-line no-unused-vars - // eslint-disable-next-line no-console - console.log('creditList: ', creditList, response.data[user]['creditList']) let amount = this.createAmount(response.data[user]['creditList'][creditList]) let credit = this.createCredit(response.data[user]['creditList'][creditList]) let sum = this.createSum(credit, amount) list[creditList] = [{...credit}, {...amount}, {...sum}] - // eslint-disable-next-line no-console - console.log("creditList list:", creditList, list) } this.users.push({ id: lastId + 1, username: response.data[user].username, firstname: response.data[user].firstname, lastname: response.data[user].lastname, + limit: response.data[user].limit, + locked: response.data[user].locked, + autoLock: response.data[user].autoLock, creditList: list, expand: false, active: false @@ -153,7 +145,7 @@ }}) .catch(error => { if (error.response) { - if (error.response.status == 401) { + if (error.response.status === 401) { this.$store.dispatch('logout') } } @@ -169,34 +161,27 @@ }) // eslint-disable-next-line no-console - console.log("this.users: ", this.users) + console.log(this.users) }, addAmount(data) { httpClient.addAmountFinanzer(this.$store.getters.getToken, {userId: data.user.username, amount: data.amount * 100, year: data.year, month: data.month}) .then(response => { - // eslint-disable-next-line no-console - console.log(response.data) let user = this.users.find(user => {return user.username === data.user.username}) let index = this.users.indexOf(user) let list = {} for (let creditList in response.data) { - // eslint-disable-next-line no-unused-vars - // eslint-disable-next-line no-console - console.log('creditList: ', creditList, response.data[creditList]) let amount = this.createAmount(response.data[creditList]) let credit = this.createCredit(response.data[creditList]) let sum = this.createSum(credit, amount) list[creditList] = [{...credit}, {...amount}, {...sum}] - // eslint-disable-next-line no-console - console.log("creditList list:", creditList, list) } this.users[index].creditList = list }) .catch(error => { if (error.response) { - if (error.response.status == 401) { + if (error.response.status === 401) { this.$store.dispatch('logout') } } @@ -207,29 +192,22 @@ httpClient.addCreditFinanzer(this.$store.getters.getToken, {userId: data.user.username, credit: data.credit * 100, year: data.year, month: data.month}) .then(response => { - // eslint-disable-next-line no-console - console.log(response.data) let user = this.users.find(user => {return user.username === data.user.username}) let index = this.users.indexOf(user) let list = {} for (let creditList in response.data) { - // eslint-disable-next-line no-unused-vars - // eslint-disable-next-line no-console - console.log('creditList: ', creditList, response.data[creditList]) let amount = this.createAmount(response.data[creditList]) let credit = this.createCredit(response.data[creditList]) let sum = this.createSum(credit, amount) list[creditList] = [{...credit}, {...amount}, {...sum}] - // eslint-disable-next-line no-console - console.log("creditList list:", creditList, list) } this.users[index].creditList = list }) .catch(error => { if (error.response) { - if (error.response.status == 401) { + if (error.response.status === 401) { this.$store.dispatch('logout') } } @@ -240,6 +218,37 @@ for (let user in this.users) { user.active = false } + }, + doLock(data) { + httpClient.lockUser(this.$store.getters.getToken, {userId: data.user.username, locked: data.locked}) + .then(response => { + let user = this.users.find(user => {return user.username === data.user.username}) + let index = this.users.indexOf(user) + this.users[index].locked = response.data.locked + }) + .catch(error => { + if (error.response) { + if (error.response.status === 401) { + this.$store.dispatch('logout') + } + } + }) + }, + saveConfig(data) { + httpClient.finanzerSetConfig(this.$store.getters.getToken, {userId: data.user.username, limit: data.limit * 100, autoLock: data.autoLock}) + .then(response => { + let user = this.users.find(user => {return user.username === data.user.username}) + let index = this.users.indexOf(user) + this.users[index].limit = response.data.limit + this.users[index].autoLock = response.data.autoLock + }) + .catch(error => { + if (error.response) { + if (error.response.status === 401) { + this.$store.dispatch('logout') + } + } + }) } } From da26270a61148c8149cf36cadeda6c5e510673e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 29 Dec 2019 17:56:50 +0100 Subject: [PATCH 008/117] show and disable locked user in barview --- src/components/baruser/CreditLists.vue | 17 +++++++++++------ src/plugins/restService.js | 3 +++ src/views/BarView.vue | 22 ++++++++++++++-------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index 4ddf330..ff69bab 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -12,17 +12,17 @@ 2 € + :color="color" :disabled="user.locked">2 € 1 € + :color="color" :disabled="user.locked">1 € + :color="color" :disabled="user.locked"> 0,50 € @@ -30,19 +30,19 @@ + :color="color" :disabled="user.locked"> 0,40 € + :color="color" :disabled="user.locked"> 0,20 € + :color="color" :disabled="user.locked"> 0,10 € @@ -58,6 +58,7 @@ + Gesperrt @@ -77,6 +78,10 @@ color: 'green accent-4' } }, + created() { + // eslint-disable-next-line no-console + console.log(this.users) + }, methods: { addAmount(username, amount) { this.$emit("add:amount", username, amount) diff --git a/src/plugins/restService.js b/src/plugins/restService.js index ddcb951..8116027 100644 --- a/src/plugins/restService.js +++ b/src/plugins/restService.js @@ -14,6 +14,9 @@ class Service { getUserBar(token) { return axios.get(this.url+'bar', {headers: {Token: token}}) } + getOneUserBar(token, data) { + return axios.post(this.url+'barGetUser', {...data}, {headers: {Token: token}}) + } addAmountBar(token, data) { return axios.post(this.url+'baradd', {...data}, {headers: {Token: token}}) } diff --git a/src/views/BarView.vue b/src/views/BarView.vue index f01e384..4ade2f8 100644 --- a/src/views/BarView.vue +++ b/src/views/BarView.vue @@ -67,6 +67,7 @@ return user.username === username ? user : false }) user.amount = response.data.amount + user.locked = response.data.locked }) .catch(error => { if (error.response) { @@ -81,15 +82,20 @@ 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 + httpClient.getOneUserBar(this.$store.getters.getToken, {userId: user.username}) + .then(response => { + const lastId = this.users.length > 0 ? this.users[this.users.length - 1].id : 0 + this.users.push({ + id: lastId + 1, + username: response.data.username, + firstname: response.data.firstname, + lastname: response.data.lastname, + locked: response.data.locked, + amount: 0, + type: null + }) }) + } } } From 88abb2599a32c3f7fdf41d7bb78de77c8bdb649f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 29 Dec 2019 21:35:32 +0100 Subject: [PATCH 009/117] finanzer can add useres to DB in usercontent for finanzer, he can add amount or credit too bug fixes --- src/components/baruser/CreditLists.vue | 2 - src/components/finanzer/Overview.vue | 13 +++- src/components/finanzer/User.vue | 78 +++++++++++++++++++ src/plugins/restService.js | 3 + src/store/index.js | 1 - src/views/BarView.vue | 1 - src/views/FinanzerView.vue | 100 +++++++++++++++++++++---- src/views/Login.vue | 1 - 8 files changed, 178 insertions(+), 21 deletions(-) diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index ff69bab..bf0627d 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -79,8 +79,6 @@ } }, created() { - // eslint-disable-next-line no-console - console.log(this.users) }, methods: { addAmount(username, amount) { diff --git a/src/components/finanzer/Overview.vue b/src/components/finanzer/Overview.vue index 188b024..3521d18 100644 --- a/src/components/finanzer/Overview.vue +++ b/src/components/finanzer/Overview.vue @@ -45,6 +45,14 @@ + + + Status: + + + {{user.locked ? 'Gesperrt': 'nicht Gesperrt'}} + + Geld transferieren @@ -144,7 +152,7 @@ return lastYear + sum }, createYears() { - for (let year = 2000; year <= new Date().getFullYear(); year++) { + for (let year = new Date().getFullYear(); year >= 2000; year--) { this.years.push({value: year, text: year}) } }, @@ -185,6 +193,9 @@ this.filteredUsers = [...this.filteredUsers.filter(user => { return user.firstname.toLowerCase().includes(this.filter.toLowerCase()) || user.lastname.toLowerCase().includes(this.filter.toLowerCase()) })] + }, + getLockedColor (value) { + return value ? 'red' : 'green' } }, computed: { diff --git a/src/components/finanzer/User.vue b/src/components/finanzer/User.vue index 422bcc9..3b7de68 100644 --- a/src/components/finanzer/User.vue +++ b/src/components/finanzer/User.vue @@ -34,6 +34,37 @@ + + Geld transferieren + + + + + + + + + + + + + + + + + + + + Hinzufügen + +
{{year}} @@ -80,12 +111,36 @@ isNumber: value => !isNaN(value) || 'Betrag muss eine Zahl sein.', limit: null, autoLock: null, + amount: null, + selectYears: [], + months: [ + {value: 1, text: 'Januar'}, + {value: 2, text: 'Februar'}, + {value: 3, text: 'März'}, + {value: 4, text:'April'}, + {value: 5, text: 'Mai'}, + {value: 6, text: 'Juni'}, + {value: 7, text: 'Juli'}, + {value: 8, text: 'August'}, + {value: 9, text: 'September'}, + {value: 10, text: 'Oktober'}, + {value: 11, text: 'November'}, + {value: 12, text: 'Dezember'} + ], + type: {value: 'credit', text: 'Guthaben'}, + selectedYear: {value: new Date().getFullYear(), text: new Date().getFullYear()}, + selectedMonth: {value: new Date().getMonth() + 1, text: ["Januar", "Februar", "März", "April", "Mai", "Juni", + "Juli", "August", "September", "Oktober", "November", "Dezember" + ][new Date().getMonth()]} } }, created() { this.limit = (this.user.limit / 100).toFixed(2) this.autoLock = {value: this.user.autoLock, text: this.user.autoLock? "Aktiviert" : "Deaktiviert"} + for (let year = new Date().getFullYear(); year >= 2000; year--) { + this.selectYears.push({value: year, text: year}) + } }, methods: { getLastColor (value) { @@ -103,6 +158,29 @@ }, saveConfig() { this.$emit("save:config", {user: this.user, limit: this.limit, autoLock: this.autoLock.value}) + }, + add() { + if (this.type.value === 'amount') { + this.$emit("add:amount", {user: this.user, amount: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value}) + } + if (this.type.value === 'credit') { + this.$emit("add:credit", {user: this.user, credit: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value}) + } + + this.createDefault() + + }, + createDefault() { + // eslint-disable-next-line no-unused-vars + let year = new Date().getFullYear() + // eslint-disable-next-line no-unused-vars + let month = new Date().getMonth() + this.amount = null + this.type = {value: 'credit', text: 'Guthaben'} + this.selectedYear = {value: new Date().getFullYear(), text: new Date().getFullYear()} + this.selectedMonth = {value: new Date().getMonth() + 1, text: ["Januar", "Februar", "März", "April", "Mai", "Juni", + "Juli", "August", "September", "Oktober", "November", "Dezember" + ][new Date().getMonth()]} } }, computed: { diff --git a/src/plugins/restService.js b/src/plugins/restService.js index 8116027..ebb646f 100644 --- a/src/plugins/restService.js +++ b/src/plugins/restService.js @@ -38,6 +38,9 @@ class Service { finanzerSetConfig(token, data) { return axios.post(this.url+'finanzerSetConfig', {...data}, {headers: {Token: token}}) } + finanzerAddUser(token, data) { + return axios.post(this.url+'finanzerAddUser', {...data}, {headers: {Token: token}}) + } } const httpClient = new Service("http://localhost:5000/") diff --git a/src/store/index.js b/src/store/index.js index 8d4f7b4..c62f69d 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -22,7 +22,6 @@ export default new Vuex.Store({ state.loginError = errorMessage; }, updateAccessToken (state, data) { - // eslint-disable-next-line no-console if (typeof(data) === typeof("")) { data = JSON.parse(data) } diff --git a/src/views/BarView.vue b/src/views/BarView.vue index 4ade2f8..1605cda 100644 --- a/src/views/BarView.vue +++ b/src/views/BarView.vue @@ -28,7 +28,6 @@ }, methods: { getUser() { - // eslint-disable-next-line no-console this. users = [] httpClient.getUserBar(this.$store.getters.getToken) .then(response => { diff --git a/src/views/FinanzerView.vue b/src/views/FinanzerView.vue index 70ddb36..262b6da 100644 --- a/src/views/FinanzerView.vue +++ b/src/views/FinanzerView.vue @@ -19,12 +19,32 @@ {{user.lastname}}, {{user.firstname}} + - +
@@ -40,6 +60,14 @@ components: {User, Overview, TitleBar}, created() { this.getUser() + httpClient.searchUser(this.$store.getters.getToken, {searchString: ""}) + .then(response => { + this.allUsers = response.data + + for (let i = 0; i < this.allUsers.length; i++) { + this.allUsers[i].fullName = this.allUsers[i].firstname + " " + this.allUsers[i].lastname + } + }) }, data () { return { @@ -47,6 +75,8 @@ activeUser: { username: null, }, + allUsers: [], + user: null } }, methods: { @@ -54,7 +84,7 @@ if (this.activeUser.username === e.username) { this.activeUser = {username: null} } else { - this.activeUser = {...e} + this.activeUser = e } }, createAmount(creditList) { @@ -159,9 +189,6 @@ if (a.firstname < b.firstname) return -1 return 0 }) - - // eslint-disable-next-line no-console - console.log(this.users) }, addAmount(data) { httpClient.addAmountFinanzer(this.$store.getters.getToken, {userId: data.user.username, amount: data.amount * 100, year: data.year, month: data.month}) @@ -171,13 +198,15 @@ let index = this.users.indexOf(user) let list = {} for (let creditList in response.data) { - - let amount = this.createAmount(response.data[creditList]) - let credit = this.createCredit(response.data[creditList]) - let sum = this.createSum(credit, amount) - list[creditList] = [{...credit}, {...amount}, {...sum}] + if (creditList !== 'locked') { + let amount = this.createAmount(response.data[creditList]) + let credit = this.createCredit(response.data[creditList]) + let sum = this.createSum(credit, amount) + list[creditList] = [{...credit}, {...amount}, {...sum}] + } } this.users[index].creditList = list + this.users[index].locked = response.data.locked }) .catch(error => { if (error.response) { @@ -187,6 +216,7 @@ } this.users = [] }) + this.users.find(a => {return a.username === this.activeUser.username}) }, addCredit(data) { @@ -197,13 +227,15 @@ let index = this.users.indexOf(user) let list = {} for (let creditList in response.data) { - - let amount = this.createAmount(response.data[creditList]) - let credit = this.createCredit(response.data[creditList]) - let sum = this.createSum(credit, amount) - list[creditList] = [{...credit}, {...amount}, {...sum}] + if (creditList !== 'locked') { + let amount = this.createAmount(response.data[creditList]) + let credit = this.createCredit(response.data[creditList]) + let sum = this.createSum(credit, amount) + list[creditList] = [{...credit}, {...amount}, {...sum}] + } } this.users[index].creditList = list + this.users[index].locked = response.data.locked }) .catch(error => { if (error.response) { @@ -213,6 +245,7 @@ } this.users = [] }) + this.users.find(a => {return a.username === this.activeUser.username}) }, deactivateAllUser() { for (let user in this.users) { @@ -249,6 +282,43 @@ } } }) + }, + addUser() { + httpClient.finanzerAddUser(this.$store.getters.getToken, {userId: this.user.username}) + .then(response => { + for (let username in response.data) { + let existUser = this.users.find(a => {return a.username === username}) + let list = {} + for (let creditList in response.data[username]['creditList']) { + let amount = this.createAmount(response.data[username]['creditList'][creditList]) + let credit = this.createCredit(response.data[username]['creditList'][creditList]) + let sum = this.createSum(credit, amount) + list[creditList] = [{...credit}, {...amount}, {...sum}] + } + if (existUser) { + existUser.firstname = response.data[username].firstname + existUser.lastname = response.data[username].lastname + existUser.limit = response.data[username].limit + existUser.locked = response.data[username].locked + existUser.autoLock = response.data[username].autoLock + existUser.creditList = list + } else { + const lastId = this.users.length > 0 ? this.users[this.users.length - 1].id : 0 + this.users.push({ + id: lastId + 1, + username: response.data[username].username, + firstname: response.data[username].firstname, + lastname: response.data[username].lastname, + limit: response.data[username].limit, + locked: response.data[username].locked, + autoLock: response.data[username].autoLock, + creditList: list, + expand: false, + active: false + }) + } + } + }) } } diff --git a/src/views/Login.vue b/src/views/Login.vue index fe1ec02..8d68a0e 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -75,7 +75,6 @@ }, methods: { login() { - // eslint-disable-next-line no-console let o = {username: this.username, password: this.password} this.$store.dispatch("doLogin", o) }, From 32a01cb5e3b2ef88c531b24d44ea92c3b1559bcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 29 Dec 2019 21:57:18 +0100 Subject: [PATCH 010/117] bug fixes, that baruser see endsum of user not only month --- src/components/baruser/CreditLists.vue | 2 +- src/views/BarView.vue | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index bf0627d..d521dfa 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -58,7 +58,7 @@
- Gesperrt + {{user.firstname}} darf nicht mehr anschreiben. {{user.firstname}} sollte sich lieber mal beim Finanzer melden. diff --git a/src/views/BarView.vue b/src/views/BarView.vue index 1605cda..8d15574 100644 --- a/src/views/BarView.vue +++ b/src/views/BarView.vue @@ -67,6 +67,7 @@ }) user.amount = response.data.amount user.locked = response.data.locked + user.type = response.data.type }) .catch(error => { if (error.response) { From bb400f29d05842f0fb587182beea10570e71f6b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 5 Jan 2020 14:17:06 +0100 Subject: [PATCH 011/117] added actions for finanzer to send automaticly emails some bugfixes --- src/components/finanzer/Overview.vue | 31 ++++++++++++++++++++++++++++ src/components/finanzer/User.vue | 27 ++++++++++++++++++++++++ src/plugins/restService.js | 11 ++++++++-- src/views/BarView.vue | 4 ++-- src/views/FinanzerView.vue | 22 ++++++++++++++++++-- 5 files changed, 89 insertions(+), 6 deletions(-) diff --git a/src/components/finanzer/Overview.vue b/src/components/finanzer/Overview.vue index 3521d18..8c9168f 100644 --- a/src/components/finanzer/Overview.vue +++ b/src/components/finanzer/Overview.vue @@ -10,9 +10,26 @@ + Emails senden + + + + + + $expand + + + {{errorMessage(error)}} + + +
@@ -107,10 +124,13 @@ components: {Table}, props: { users: Array, + emailErrors: Array, }, data () { return { + errorExpand: false, + year: new Date().getFullYear(), filter: "", filteredUsers: [], @@ -196,6 +216,17 @@ }, getLockedColor (value) { return value ? 'red' : 'green' + }, + sendMails() { + this.$emit("send:mails") + }, + computeError(error) { + if (error) return 'error' + else return 'success' + }, + errorMessage(error) { + if (error.error) return 'Konnte Email an ' + error.user.firstname + ' ' + error.user.lastname + ' nicht senden!' + else return 'Email wurde an ' + error.user.firstname + ' ' + error.user.lastname + ' versandt.' } }, computed: { diff --git a/src/components/finanzer/User.vue b/src/components/finanzer/User.vue index 3b7de68..3330ed2 100644 --- a/src/components/finanzer/User.vue +++ b/src/components/finanzer/User.vue @@ -2,7 +2,18 @@
{{user.lastname}}, {{user.firstname}} + + + Email senden + + + + + {{errorMessage(emailError)}} + + + Konfiguration @@ -105,6 +116,7 @@ components: {Table}, props: { user: Object, + emailError: null, }, data () { return { @@ -181,6 +193,21 @@ this.selectedMonth = {value: new Date().getMonth() + 1, text: ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember" ][new Date().getMonth()]} + }, + sendEmail() { + this.$emit("send:mail", {username: this.user.username}) + }, + computeError(error) { + if (error) { + if (error.error) return 'error' + else return 'success' + } + }, + errorMessage(error) { + if (error) { + if (error.error) return 'Konnte Email an ' + error.user.firstname + ' ' + error.user.lastname + ' nicht senden!' + else return 'Email wurde an ' + error.user.firstname + ' ' + error.user.lastname + ' versandt.' + } } }, computed: { diff --git a/src/plugins/restService.js b/src/plugins/restService.js index ebb646f..6ad61c6 100644 --- a/src/plugins/restService.js +++ b/src/plugins/restService.js @@ -41,10 +41,17 @@ class Service { finanzerAddUser(token, data) { return axios.post(this.url+'finanzerAddUser', {...data}, {headers: {Token: token}}) } + finanzerSendAllMail(token) { + return axios.get(this.url+"finanzerSendAllMail", {headers: {Token: token}}) + } + finanzerSendOneMail(token, data) { + return axios.post(this.url+"finanzerSendOneMail", {...data}, {headers: {Token: token}}) + } } -const httpClient = new Service("http://localhost:5000/") +//const httpClient = new Service("http://localhost:5000/") //const httpClient = new Service("http://192.168.5.118:5000/") -//const httpClient = new Service("http://groeger-clan.duckdns.org:5000/") +//const httpClient = new Service("http://192.168.5.128:5000/") +const httpClient = new Service("http://groeger-clan.duckdns.org:5000/") export default httpClient diff --git a/src/views/BarView.vue b/src/views/BarView.vue index 8d15574..0cfadd3 100644 --- a/src/views/BarView.vue +++ b/src/views/BarView.vue @@ -91,8 +91,8 @@ firstname: response.data.firstname, lastname: response.data.lastname, locked: response.data.locked, - amount: 0, - type: null + amount: response.data.amount, + type: response.data.type }) }) diff --git a/src/views/FinanzerView.vue b/src/views/FinanzerView.vue index 262b6da..5c6d143 100644 --- a/src/views/FinanzerView.vue +++ b/src/views/FinanzerView.vue @@ -39,10 +39,12 @@ - + @@ -76,15 +78,19 @@ username: null, }, allUsers: [], - user: null + user: null, + errorMails: null, + errorMail: null, } }, methods: { test (e) { if (this.activeUser.username === e.username) { this.activeUser = {username: null} + this.errorMail = null } else { this.activeUser = e + this.errorMail = null } }, createAmount(creditList) { @@ -319,6 +325,18 @@ } } }) + }, + sendMails() { + httpClient.finanzerSendAllMail(this.$store.getters.getToken) + .then(response => { + this.errorMails = response.data + }) + }, + sendMail(data) { + httpClient.finanzerSendOneMail(this.$store.getters.getToken, {userId: data.username}) + .then(response => { + this.errorMail = response.data + }) } } From 398c7d7defd1c3a5104666b2a91804e1e68432b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 5 Jan 2020 23:39:30 +0100 Subject: [PATCH 012/117] start change commandlayout for vuex, FinanzerView.vue is ready next steps: overview, table, user ... --- src/components/finanzer/Overview.vue | 9 +- src/plugins/restService.js | 4 +- src/plugins/routes.js | 20 ++ src/router/index.js | 12 +- src/store/index.js | 86 +------- src/store/modules/login.js | 98 +++++++++ src/store/modules/users.js | 274 +++++++++++++++++++++++++ src/views/FinanzerView.vue | 287 +-------------------------- src/views/Login.vue | 31 +-- 9 files changed, 433 insertions(+), 388 deletions(-) create mode 100644 src/plugins/routes.js create mode 100644 src/store/modules/login.js create mode 100644 src/store/modules/users.js diff --git a/src/components/finanzer/Overview.vue b/src/components/finanzer/Overview.vue index 8c9168f..824c189 100644 --- a/src/components/finanzer/Overview.vue +++ b/src/components/finanzer/Overview.vue @@ -2,13 +2,13 @@
Gesamtübersicht - + keyboard_arrow_left {{year}} keyboard_arrow_right - + Emails senden @@ -119,11 +119,11 @@ diff --git a/src/views/Login.vue b/src/views/Login.vue index 8d68a0e..35bbf8a 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -33,8 +33,8 @@ type="text" v-model="username" ref="first" - @keyup.enter="login" - @change="resetError" + @keyup.enter="doLogin({username: username, password: password})" + @input="resetLoginError" /> - {{ loginFail }} + {{ loginError }} - Login + Login @@ -64,6 +64,9 @@ From 9ba50a429ca47bd21d0da07963e60ccf4dd81673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 14 Jan 2020 18:20:05 +0100 Subject: [PATCH 013/117] set namespaced in module finanzerUsers.js todos: barview --- src/components/finanzer/Overview.vue | 113 ++++++++---------- src/components/finanzer/User.vue | 78 ++++-------- src/store/index.js | 7 +- src/store/modules/barUsers.js | 32 +++++ .../modules/{users.js => finanzerUsers.js} | 59 +++++++-- src/views/FinanzerView.vue | 17 +-- 6 files changed, 166 insertions(+), 140 deletions(-) create mode 100644 src/store/modules/barUsers.js rename src/store/modules/{users.js => finanzerUsers.js} (88%) diff --git a/src/components/finanzer/Overview.vue b/src/components/finanzer/Overview.vue index 824c189..cee5221 100644 --- a/src/components/finanzer/Overview.vue +++ b/src/components/finanzer/Overview.vue @@ -4,18 +4,18 @@ Gesamtübersicht - keyboard_arrow_left + keyboard_arrow_left {{year}} - keyboard_arrow_right + keyboard_arrow_right Emails senden - + - + $expand - {{errorMessage(error)}} - + +
+ {{errorMessage(error)}} + +
+
-
- + {{user.lastname}}, {{user.firstname}} @@ -119,39 +123,21 @@ From 42996d8ad121a9adbd7fcd1daf278af003a07bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 14 Jan 2020 19:57:45 +0100 Subject: [PATCH 014/117] finish to use Vuex --- src/components/baruser/CreditLists.vue | 29 ++++---- src/components/baruser/SearchBar.vue | 30 +++----- src/components/finanzer/User.vue | 7 +- src/plugins/restService.js | 57 --------------- src/store/modules/barUsers.js | 97 ++++++++++++++++++++++++-- src/store/modules/finanzerUsers.js | 2 +- src/views/BarView.vue | 77 +------------------- 7 files changed, 125 insertions(+), 174 deletions(-) delete mode 100644 src/plugins/restService.js diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index d521dfa..4a0fc08 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -11,17 +11,17 @@ - 2 € - 1 € - 0,50 € @@ -29,19 +29,19 @@ - 0,40 € - 0,20 € - 0,10 € @@ -67,30 +67,35 @@ diff --git a/src/components/baruser/SearchBar.vue b/src/components/baruser/SearchBar.vue index 1735cbe..14d75e6 100644 --- a/src/components/baruser/SearchBar.vue +++ b/src/components/baruser/SearchBar.vue @@ -13,7 +13,7 @@ diff --git a/src/components/finanzer/User.vue b/src/components/finanzer/User.vue index 3e0d11a..452484a 100644 --- a/src/components/finanzer/User.vue +++ b/src/components/finanzer/User.vue @@ -134,7 +134,12 @@ this.autoLock = {value: this.activeUser.autoLock, text: this.activeUser.autoLock? "Aktiviert" : "Deaktiviert"} }, methods: { - ...mapActions(['finanzerUsers/addAmount', 'finanzerUsers/addCredit', 'finanzerUsers/sendMail', 'finanzerUsers/doLock', 'finanzerUsers/saveConfig']), + ...mapActions({ + addAmount: 'finanzerUsers/addAmount', + addCredit: 'finanzerUsers/addCredit', + sendMail: 'finanzerUsers/sendMail', + doLock: 'finanzerUsers/doLock', + saveConfig: 'finanzerUsers/saveConfig'}), getLastColor (value) { return value < 0 ? 'red' : 'green' }, diff --git a/src/plugins/restService.js b/src/plugins/restService.js deleted file mode 100644 index 01a694f..0000000 --- a/src/plugins/restService.js +++ /dev/null @@ -1,57 +0,0 @@ -import axios from 'axios' - -class Service { - constructor(url) { - this.url = url - } - getFinanzerMain(token) { - return axios.get(this.url + "getFinanzerMain", {headers: {Token: token}}) - - } - login(loginData) { - return axios.post(this.url+'login', {...loginData}) - } - getUserBar(token) { - return axios.get(this.url+'bar', {headers: {Token: token}}) - } - getOneUserBar(token, data) { - return axios.post(this.url+'barGetUser', {...data}, {headers: {Token: token}}) - } - addAmountBar(token, 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) { - 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}}) - } - lockUser(token, data) { - return axios.post(this.url+'finanzerLock', {...data}, {headers: {Token: token}}) - } - finanzerSetConfig(token, data) { - return axios.post(this.url+'finanzerSetConfig', {...data}, {headers: {Token: token}}) - } - finanzerAddUser(token, data) { - return axios.post(this.url+'finanzerAddUser', {...data}, {headers: {Token: token}}) - } - finanzerSendAllMail(token) { - return axios.get(this.url+"finanzerSendAllMail", {headers: {Token: token}}) - } - finanzerSendOneMail(token, data) { - return axios.post(this.url+"finanzerSendOneMail", {...data}, {headers: {Token: token}}) - } -} - -//const httpClient = new Service("http://localhost:5000/") -const httpClient = new Service("http://192.168.5.118:5000/") -//const httpClient = new Service("http://192.168.5.128:5000/") -//const httpClient = new Service("http://groeger-clan.duckdns.org:5000/") - -export default httpClient diff --git a/src/store/modules/barUsers.js b/src/store/modules/barUsers.js index 21485f7..e6b7d1e 100644 --- a/src/store/modules/barUsers.js +++ b/src/store/modules/barUsers.js @@ -1,26 +1,109 @@ -//import axios from 'axios'; -//import url from '@/plugins/routes'; +import axios from 'axios'; +import url from '@/plugins/routes'; const state = { - users: null + users: [], + allUsers: [] }; const mutations = { + setAllUsers: (state, users) => { + state.allUsers = [] + state.allUsers = users + for (let i = 0; i < state.allUsers.length; i++) { + state.allUsers[i].fullName = state.allUsers[i].firstname + " " + state.allUsers[i].lastname + } + }, + setUsers: (state, users) => { + // eslint-disable-next-line no-console + console.log(users) + for (let user in users) { + // eslint-disable-next-line no-console + console.log(user) + let existuser = state.users.find(a => {return user === a.username}) + + if (existuser) { + existuser.sername = users[user].username + existuser.firstname = users[user].firstname + existuser.lastname = users[user].lastname + existuser.locked = users[user].locked + existuser.amount = users[user].amount + existuser.type = users[user].type + } else { + state.users.push({ + username: users[user].username, + firstname: users[user].firstname, + lastname: users[user].lastname, + locked: users[user].locked, + amount: users[user].amount, + type: users[user].type + }) + } + } + // eslint-disable-next-line no-console + console.log(state.users) + mutations.sortUsers(state) + }, + sortUsers: (state) => { + state.users = state.users.sort((a,b) => { + if (a.lastname > b.lastname) return 1 + if (a.lastname < b.lastname) return -1 + if (a.firstname > b.firstname) return 1 + if (a.firstname < b.firstname) return -1 + return 0 + }) + }, }; const actions = { // eslint-disable-next-line no-unused-vars async getUsers({commit, rootState, dispatch}) { - // try { - // const response = await axios.get(url) - // } + try { + const response = await axios.get(url.bar, {headers: {Token: rootState.login.user.accessToken}}) + // eslint-disable-next-line no-console + console.log(response.data) + commit('setUsers', response.data) + } catch (e) { + if (e.response) if (e.response.status === 401) dispatch('logout', null, {root: true}) + } + }, + async addAmount({commit, rootState, dispatch}, data) { + try { + const response = await axios.post(url.barAddAmount, {userId: data.username, amount: data.amount}, {headers: {Token: rootState.login.user.accessToken}}) + commit('setUsers', {[response.data.username]: response.data}) + } catch (e) { + if (e.response) if (e.response.status === 401) dispatch('logout', null, {root: true}) + } + }, + async addCreditList({commit, rootState, dispatch}, data) { + try { + const response = await axios.post(url.barGetUser, {userId: data.username}, {headers: {Token: rootState.login.user.accessToken}}) + commit('setUsers', {[response.data.username]: response.data}) + } catch (e) { + if (e.response) if (e.response.status === 401) dispatch('logout', null, {root: true}) + } + }, + async getAllUsers({commit, rootState, dispatch}) { + // eslint-disable-next-line no-console + console.log('hier bin ich') + try { + const response = await axios.post(url.searchUser, {searchString: ""}, {headers: {Token: rootState.login.user.accessToken}}) + // eslint-disable-next-line no-console + console.log(response) + commit('setAllUsers', response.data) + } catch (e) { + // eslint-disable-next-line no-console + console.log(e) + if (e.response) if (e.response.data === 401) dispatch('logout', null, {root: true}) + } } }; const getters = { - + users: (state) => { return state.users }, + allUsers: (state) => { return state.allUsers } }; export default { diff --git a/src/store/modules/finanzerUsers.js b/src/store/modules/finanzerUsers.js index 9a5de7c..f3b50fb 100644 --- a/src/store/modules/finanzerUsers.js +++ b/src/store/modules/finanzerUsers.js @@ -200,7 +200,7 @@ const actions = { commit('setAllUsers', response.data) } catch (err) { // eslint-disable-next-line no-console - if (err.response.status === 401) dispatch('logout', null, {root: true}) + if (err.response) if (err.response.status === 401) dispatch('logout', null, {root: true}) } }, async getUsers({commit, rootState, dispatch}) { diff --git a/src/views/BarView.vue b/src/views/BarView.vue index 0cfadd3..8ce1bba 100644 --- a/src/views/BarView.vue +++ b/src/views/BarView.vue @@ -2,8 +2,8 @@
- - + +
@@ -11,7 +11,6 @@ From bd91185edc823d1666a8a5a36cdc3f75c805ccef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 14 Jan 2020 21:55:41 +0100 Subject: [PATCH 015/117] add prettier to devdependencies --- .prettierrc.js | 4 ++++ package-lock.json | 24 ++++++++++++++++++++++++ package.json | 4 ++++ 3 files changed, 32 insertions(+) create mode 100644 .prettierrc.js diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..135334e --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,4 @@ +module.exports = { + singleQuote: true, + semi: false +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 4679fc7..69201da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1456,6 +1456,15 @@ } } }, + "@vue/eslint-config-prettier": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@vue/eslint-config-prettier/-/eslint-config-prettier-6.0.0.tgz", + "integrity": "sha512-wFQmv45c3ige5EA+ngijq40YpVcIkAy0Lihupnsnd1Dao5CBbPyfCzqtejFLZX1EwH/kCJdpz3t6s+5wd3+KxQ==", + "dev": true, + "requires": { + "eslint-config-prettier": "^6.0.0" + } + }, "@vue/preload-webpack-plugin": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@vue/preload-webpack-plugin/-/preload-webpack-plugin-1.1.1.tgz", @@ -4252,6 +4261,15 @@ } } }, + "eslint-config-prettier": { + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.9.0.tgz", + "integrity": "sha512-k4E14HBtcLv0uqThaI6I/n1LEqROp8XaPu6SO9Z32u5NlGRC07Enu1Bh2KEFw4FNHbekH8yzbIU9kUGxbiGmCA==", + "dev": true, + "requires": { + "get-stdin": "^6.0.0" + } + }, "eslint-loader": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/eslint-loader/-/eslint-loader-2.2.1.tgz", @@ -5513,6 +5531,12 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, + "get-stdin": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", + "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", + "dev": true + }, "get-stream": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", diff --git a/package.json b/package.json index a53d6f6..b9b8e66 100644 --- a/package.json +++ b/package.json @@ -20,11 +20,13 @@ "@vue/cli-plugin-router": "^4.1.1", "@vue/cli-plugin-vuex": "^4.1.1", "@vue/cli-service": "^4.1.0", + "@vue/eslint-config-prettier": "^6.0.0", "axios": "^0.19.0", "babel-eslint": "^10.0.3", "eslint": "^5.16.0", "eslint-plugin-vue": "^5.0.0", "material-design-icons-iconfont": "^5.0.1", + "prettier": "^1.19.1", "sass": "^1.19.0", "sass-loader": "^8.0.0", "vue-cli-plugin-vuetify": "^2.0.2", @@ -38,6 +40,8 @@ }, "extends": [ "plugin:vue/essential", + "plugin:prettier/recommended", + "@vue/prettier", "eslint:recommended" ], "rules": {}, From 4374eaa3d7d4ff64fa97bc2b9ece6109b29c6029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 14 Jan 2020 22:01:24 +0100 Subject: [PATCH 016/117] used prettier on code --- src/App.vue | 14 +- src/components/TitleBar.vue | 90 ++- src/components/baruser/CreditLists.vue | 212 ++++---- src/components/baruser/SearchBar.vue | 84 +-- src/components/finanzer/Overview.vue | 516 +++++++++++------- src/components/finanzer/Table.vue | 223 ++++---- src/components/finanzer/User.vue | 502 ++++++++++------- src/plugins/routes.js | 34 +- src/plugins/vuetify.js | 14 +- src/router/index.js | 33 +- src/store/index.js | 8 +- src/store/modules/barUsers.js | 225 ++++---- src/store/modules/finanzerUsers.js | 724 +++++++++++++++---------- src/store/modules/login.js | 183 ++++--- src/views/BarView.vue | 47 +- src/views/FinanzerView.vue | 162 +++--- src/views/Home.vue | 4 +- src/views/Login.vue | 137 +++-- 18 files changed, 1794 insertions(+), 1418 deletions(-) diff --git a/src/App.vue b/src/App.vue index 82cdfcc..164699d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,24 +1,20 @@ diff --git a/src/components/TitleBar.vue b/src/components/TitleBar.vue index 0359649..60949de 100644 --- a/src/components/TitleBar.vue +++ b/src/components/TitleBar.vue @@ -1,59 +1,51 @@ diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index 4a0fc08..35bff87 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -1,107 +1,127 @@ diff --git a/src/components/baruser/SearchBar.vue b/src/components/baruser/SearchBar.vue index 14d75e6..c1abe10 100644 --- a/src/components/baruser/SearchBar.vue +++ b/src/components/baruser/SearchBar.vue @@ -1,50 +1,54 @@ diff --git a/src/components/finanzer/Overview.vue b/src/components/finanzer/Overview.vue index cee5221..37da410 100644 --- a/src/components/finanzer/Overview.vue +++ b/src/components/finanzer/Overview.vue @@ -1,227 +1,323 @@ diff --git a/src/components/finanzer/Table.vue b/src/components/finanzer/Table.vue index 0f8ddfb..bfb57c9 100644 --- a/src/components/finanzer/Table.vue +++ b/src/components/finanzer/Table.vue @@ -1,118 +1,125 @@ diff --git a/src/components/finanzer/User.vue b/src/components/finanzer/User.vue index 452484a..0496546 100644 --- a/src/components/finanzer/User.vue +++ b/src/components/finanzer/User.vue @@ -1,212 +1,310 @@ diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 47ed526..9d79aca 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -1,20 +1,20 @@ -const main = 'http://192.168.5.118:5000/'; +const main = 'http://192.168.5.118:5000/' const url = { - login: main + 'login', - getFinanzerMain: main + 'getFinanzerMain', - bar: main + 'bar', - barGetUser: main + 'barGetUser', - barAddAmount: main + 'baradd', - finanzerAddAmount: main + 'finanzerAddAmount', - finanzerAddCredit: main + 'finanzerAddCredit', - searchUser: main + 'search', - getAllUser: main + 'barGetUsers', - lockUser: main + 'finanzerLock', - finanzerSetConfig: main + 'finanzerSetConfig', - finanzerAddUser: main + 'finanzerAddUser', - finanzerSendAllMail: main + 'finanzerSendAllMail', - finanzerSendOneMail: main + 'finanzerSendOneMail' -}; + login: main + 'login', + getFinanzerMain: main + 'getFinanzerMain', + bar: main + 'bar', + barGetUser: main + 'barGetUser', + barAddAmount: main + 'baradd', + finanzerAddAmount: main + 'finanzerAddAmount', + finanzerAddCredit: main + 'finanzerAddCredit', + searchUser: main + 'search', + getAllUser: main + 'barGetUsers', + lockUser: main + 'finanzerLock', + finanzerSetConfig: main + 'finanzerSetConfig', + finanzerAddUser: main + 'finanzerAddUser', + finanzerSendAllMail: main + 'finanzerSendAllMail', + finanzerSendOneMail: main + 'finanzerSendOneMail' +} -export default url; +export default url diff --git a/src/plugins/vuetify.js b/src/plugins/vuetify.js index 392f1a1..fa57d63 100644 --- a/src/plugins/vuetify.js +++ b/src/plugins/vuetify.js @@ -1,11 +1,11 @@ -import Vue from 'vue'; -import Vuetify from 'vuetify/lib'; +import Vue from 'vue' +import Vuetify from 'vuetify/lib' import 'material-design-icons-iconfont' -Vue.use(Vuetify); +Vue.use(Vuetify) export default new Vuetify({ - icons: { - iconfont: 'md', - } -}); + icons: { + iconfont: 'md' + } +}) diff --git a/src/router/index.js b/src/router/index.js index efe673b..e7f546e 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,36 +1,34 @@ import Vue from 'vue' import VueRouter from 'vue-router' -import FinanzerView from "@/views/FinanzerView"; -import Login from "@/views/Login"; -import store from "@/store/index"; -import BarView from "@/views/BarView"; +import FinanzerView from '@/views/FinanzerView' +import Login from '@/views/Login' +import store from '@/store/index' +import BarView from '@/views/BarView' Vue.use(VueRouter) const routes = [ - { - path: "/login", - name: "login", + path: '/login', + name: 'login', component: Login }, { - path: "/finanzer", - name: "finanzer", + path: '/finanzer', + name: 'finanzer', component: FinanzerView }, { - path: "/bar", - name: "bar", + path: '/bar', + name: 'bar', component: BarView }, { path: '*', redirect: { - name: "login" + name: 'login' } - }, - + } ] const router = new VueRouter({ @@ -40,7 +38,7 @@ const router = new VueRouter({ }) router.beforeEach((to, from, next) => { - store.dispatch('fetchAccessToken'); + store.dispatch('fetchAccessToken') let sites = ['/finanzer', '/bar'] if (sites.includes(to.fullPath)) { if (to.fullPath === '/finanzer') { @@ -64,10 +62,9 @@ router.beforeEach((to, from, next) => { } else if (store.state.login.user.group.includes('bar')) { next('/bar') } - } } - next(); -}); + next() +}) export default router diff --git a/src/store/index.js b/src/store/index.js index d4aa58f..e8ca7be 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,8 +1,8 @@ -import Vue from 'vue'; -import Vuex from 'vuex'; -import login from './modules/login'; +import Vue from 'vue' +import Vuex from 'vuex' +import login from './modules/login' import finanzerUsers from './modules/finanzerUsers' -import barUsers from "@/store/modules/barUsers"; +import barUsers from '@/store/modules/barUsers' Vue.use(Vuex) diff --git a/src/store/modules/barUsers.js b/src/store/modules/barUsers.js index e6b7d1e..ed4186a 100644 --- a/src/store/modules/barUsers.js +++ b/src/store/modules/barUsers.js @@ -1,115 +1,138 @@ -import axios from 'axios'; -import url from '@/plugins/routes'; +import axios from 'axios' +import url from '@/plugins/routes' const state = { - users: [], - allUsers: [] -}; + users: [], + allUsers: [] +} const mutations = { - setAllUsers: (state, users) => { - state.allUsers = [] - state.allUsers = users - for (let i = 0; i < state.allUsers.length; i++) { - state.allUsers[i].fullName = state.allUsers[i].firstname + " " + state.allUsers[i].lastname - } - }, - setUsers: (state, users) => { - // eslint-disable-next-line no-console - console.log(users) - for (let user in users) { - // eslint-disable-next-line no-console - console.log(user) - let existuser = state.users.find(a => {return user === a.username}) + setAllUsers: (state, users) => { + state.allUsers = [] + state.allUsers = users + for (let i = 0; i < state.allUsers.length; i++) { + state.allUsers[i].fullName = + state.allUsers[i].firstname + ' ' + state.allUsers[i].lastname + } + }, + setUsers: (state, users) => { + // eslint-disable-next-line no-console + console.log(users) + for (let user in users) { + // eslint-disable-next-line no-console + console.log(user) + let existuser = state.users.find(a => { + return user === a.username + }) - if (existuser) { - existuser.sername = users[user].username - existuser.firstname = users[user].firstname - existuser.lastname = users[user].lastname - existuser.locked = users[user].locked - existuser.amount = users[user].amount - existuser.type = users[user].type - } else { - state.users.push({ - username: users[user].username, - firstname: users[user].firstname, - lastname: users[user].lastname, - locked: users[user].locked, - amount: users[user].amount, - type: users[user].type - }) - } - } - // eslint-disable-next-line no-console - console.log(state.users) - mutations.sortUsers(state) - }, - sortUsers: (state) => { - state.users = state.users.sort((a,b) => { - if (a.lastname > b.lastname) return 1 - if (a.lastname < b.lastname) return -1 - if (a.firstname > b.firstname) return 1 - if (a.firstname < b.firstname) return -1 - return 0 + if (existuser) { + existuser.sername = users[user].username + existuser.firstname = users[user].firstname + existuser.lastname = users[user].lastname + existuser.locked = users[user].locked + existuser.amount = users[user].amount + existuser.type = users[user].type + } else { + state.users.push({ + username: users[user].username, + firstname: users[user].firstname, + lastname: users[user].lastname, + locked: users[user].locked, + amount: users[user].amount, + type: users[user].type }) - }, - -}; + } + } + // eslint-disable-next-line no-console + console.log(state.users) + mutations.sortUsers(state) + }, + sortUsers: state => { + state.users = state.users.sort((a, b) => { + if (a.lastname > b.lastname) return 1 + if (a.lastname < b.lastname) return -1 + if (a.firstname > b.firstname) return 1 + if (a.firstname < b.firstname) return -1 + return 0 + }) + } +} const actions = { - // eslint-disable-next-line no-unused-vars - async getUsers({commit, rootState, dispatch}) { - try { - const response = await axios.get(url.bar, {headers: {Token: rootState.login.user.accessToken}}) - // eslint-disable-next-line no-console - console.log(response.data) - commit('setUsers', response.data) - } catch (e) { - if (e.response) if (e.response.status === 401) dispatch('logout', null, {root: true}) - } - }, - async addAmount({commit, rootState, dispatch}, data) { - try { - const response = await axios.post(url.barAddAmount, {userId: data.username, amount: data.amount}, {headers: {Token: rootState.login.user.accessToken}}) - commit('setUsers', {[response.data.username]: response.data}) - } catch (e) { - if (e.response) if (e.response.status === 401) dispatch('logout', null, {root: true}) - } - }, - async addCreditList({commit, rootState, dispatch}, data) { - try { - const response = await axios.post(url.barGetUser, {userId: data.username}, {headers: {Token: rootState.login.user.accessToken}}) - commit('setUsers', {[response.data.username]: response.data}) - } catch (e) { - if (e.response) if (e.response.status === 401) dispatch('logout', null, {root: true}) - } - }, - async getAllUsers({commit, rootState, dispatch}) { - // eslint-disable-next-line no-console - console.log('hier bin ich') - try { - const response = await axios.post(url.searchUser, {searchString: ""}, {headers: {Token: rootState.login.user.accessToken}}) - // eslint-disable-next-line no-console - console.log(response) - commit('setAllUsers', response.data) - } catch (e) { - // eslint-disable-next-line no-console - console.log(e) - if (e.response) if (e.response.data === 401) dispatch('logout', null, {root: true}) - } + // eslint-disable-next-line no-unused-vars + async getUsers({ commit, rootState, dispatch }) { + try { + const response = await axios.get(url.bar, { + headers: { Token: rootState.login.user.accessToken } + }) + // eslint-disable-next-line no-console + console.log(response.data) + commit('setUsers', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) } - -}; + }, + async addAmount({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.barAddAmount, + { userId: data.username, amount: data.amount }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('setUsers', { [response.data.username]: response.data }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async addCreditList({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.barGetUser, + { userId: data.username }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('setUsers', { [response.data.username]: response.data }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async getAllUsers({ commit, rootState, dispatch }) { + // eslint-disable-next-line no-console + console.log('hier bin ich') + try { + const response = await axios.post( + url.searchUser, + { searchString: '' }, + { headers: { Token: rootState.login.user.accessToken } } + ) + // eslint-disable-next-line no-console + console.log(response) + commit('setAllUsers', response.data) + } catch (e) { + // eslint-disable-next-line no-console + console.log(e) + if (e.response) + if (e.response.data === 401) dispatch('logout', null, { root: true }) + } + } +} const getters = { - users: (state) => { return state.users }, - allUsers: (state) => { return state.allUsers } -}; + users: state => { + return state.users + }, + allUsers: state => { + return state.allUsers + } +} export default { - namespaced: true, - state, - mutations, - actions, - getters + namespaced: true, + state, + mutations, + actions, + getters } diff --git a/src/store/modules/finanzerUsers.js b/src/store/modules/finanzerUsers.js index f3b50fb..d379a36 100644 --- a/src/store/modules/finanzerUsers.js +++ b/src/store/modules/finanzerUsers.js @@ -1,311 +1,443 @@ -import axios from 'axios'; +import axios from 'axios' // eslint-disable-next-line no-unused-vars import url from '@/plugins/routes' const state = { - users: [], - activeUser: { - username: null, - }, - allUsers: [], - user: null, - errorMails: null, - errorMail: null, - year: new Date().getFullYear(), - years: [], - months: [ - {value: 1, text: 'Januar'}, - {value: 2, text: 'Februar'}, - {value: 3, text: 'März'}, - {value: 4, text:'April'}, - {value: 5, text: 'Mai'}, - {value: 6, text: 'Juni'}, - {value: 7, text: 'Juli'}, - {value: 8, text: 'August'}, - {value: 9, text: 'September'}, - {value: 10, text: 'Oktober'}, - {value: 11, text: 'November'}, - {value: 12, text: 'Dezember'} - ], -}; + users: [], + activeUser: { + username: null + }, + allUsers: [], + user: null, + errorMails: null, + errorMail: null, + year: new Date().getFullYear(), + years: [], + months: [ + { value: 1, text: 'Januar' }, + { value: 2, text: 'Februar' }, + { value: 3, text: 'März' }, + { value: 4, text: 'April' }, + { value: 5, text: 'Mai' }, + { value: 6, text: 'Juni' }, + { value: 7, text: 'Juli' }, + { value: 8, text: 'August' }, + { value: 9, text: 'September' }, + { value: 10, text: 'Oktober' }, + { value: 11, text: 'November' }, + { value: 12, text: 'Dezember' } + ] +} const mutations = { - setAllUsers: (state, users) => { - state.allUsers = [] - state.allUsers = users - for (let i = 0; i < state.allUsers.length; i++) { - state.allUsers[i].fullName = state.allUsers[i].firstname + " " + state.allUsers[i].lastname - } - }, - setActiveUser: (state, user) => { - if (state.activeUser.username === user.username) { - state.activeUser = {username: null} - } else { - state.activeUser = user - } - state.errorMail = null - }, - setUsers: (state, users) => { - // eslint-disable-next-line no-console - console.log('users', users) - for (let user in users) { - // eslint-disable-next-line no-console - console.log('user', user) - let list = {} - for (let creditList in users[user]['creditList']) { - let amount = mutations.createAmount(users[user]['creditList'][creditList]) - let credit = mutations.createCredit(users[user]['creditList'][creditList]) - let sum = mutations.createSum(credit, amount) - list[creditList] = [{...credit}, {...amount}, {...sum}] - } - - let existUser = state.users.find(a => {return a.username === user}) - - // eslint-disable-next-line no-console - console.log(existUser) - if (existUser) { - existUser.username = users[user].username - existUser.firstname = users[user].firstname - existUser.lastname = users[user].lastname - existUser.limit = users[user].limit - existUser.locked = users[user].locked - existUser.autoLock = users[user].autoLock - existUser.creditList = list - } else { - state.users.push({ - username: users[user].username, - firstname: users[user].firstname, - lastname: users[user].lastname, - limit: users[user].limit, - locked: users[user].locked, - autoLock: users[user].autoLock, - creditList: list, - expand: false - }) - } - } - mutations.sortUsers(state) - - // eslint-disable-next-line no-console - console.log(state.users) - }, - createAmount(creditList) { - let amount = { - type:'Schulden', - jan_amount: 0 - creditList.jan.depts, - feb_amount: 0 - creditList.feb.depts, - maer_amount: 0 - creditList.maer.depts, - apr_amount:0 - creditList.apr.depts, - mai_amount: 0 - creditList.mai.depts, - jun_amount: 0 - creditList.jun.depts, - jul_amount: 0 - creditList.jul.depts, - aug_amount: 0 - creditList.aug.depts, - sep_amount: 0 - creditList.sep.depts, - okt_amount: 0 - creditList.okt.depts, - nov_amount: 0 - creditList.nov.depts, - dez_amount: 0 - creditList.dez.depts, - last: 0 - creditList['last'] - } - - amount.sum = amount.jan_amount + amount.feb_amount + amount.maer_amount + amount.apr_amount + amount.mai_amount + amount.jun_amount + amount.jul_amount + amount.aug_amount + amount.sep_amount + amount.okt_amount + amount.nov_amount + amount.dez_amount - return amount - }, - createCredit(creditList) { - let credit = { - type:'Guthaben', - jan_amount: creditList.jan.credit, - feb_amount: creditList.feb.credit, - maer_amount: creditList.maer.credit, - apr_amount: creditList.apr.credit, - mai_amount: creditList.mai.credit, - jun_amount: creditList.jun.credit, - jul_amount: creditList.jul.credit, - aug_amount: creditList.aug.credit, - sep_amount: creditList.sep.credit, - okt_amount: creditList.okt.credit, - nov_amount: creditList.nov.credit, - dez_amount: creditList.dez.credit - } - credit.sum = credit.jan_amount + credit.feb_amount + credit.maer_amount + credit.apr_amount + credit.mai_amount + credit.jun_amount + credit.jul_amount + credit.aug_amount + credit.sep_amount + credit.okt_amount + credit.nov_amount + credit.dez_amount - return credit - }, - createSum(credit, amount) { - let sum = { - type:'Summe', - jan_amount: credit.jan_amount + amount.jan_amount, - feb_amount: credit.feb_amount + amount.feb_amount, - maer_amount: credit.maer_amount + amount.maer_amount, - apr_amount: credit.apr_amount + amount.apr_amount, - mai_amount: credit.mai_amount + amount.mai_amount, - jun_amount: credit.jun_amount + amount.jun_amount, - jul_amount: credit.jul_amount + amount.jul_amount, - aug_amount: credit.aug_amount + amount.aug_amount, - sep_amount: credit.sep_amount + amount.sep_amount, - okt_amount: credit.okt_amount + amount.okt_amount, - nov_amount: credit.nov_amount + amount.nov_amount, - dez_amount: credit.dez_amount + amount.dez_amount, - } - sum.sum = sum.jan_amount + sum.feb_amount + sum.maer_amount + sum.apr_amount + sum.mai_amount + sum.jun_amount + sum.jul_amount + sum.aug_amount + sum.sep_amount + sum.okt_amount + sum.nov_amount + sum.dez_amount - return sum - }, - sortUsers: (state) => { - state.users = state.users.sort((a,b) => { - if (a.lastname > b.lastname) return 1 - if (a.lastname < b.lastname) return -1 - if (a.firstname > b.firstname) return 1 - if (a.firstname < b.firstname) return -1 - return 0 - }) - }, - updateUsers: (state, data) => { - let index = state.users.indexOf(state.users.find(a => {return a.username === data.username})) - if (data.creditLists !== undefined) { - let list = {} - for (let creditList in data.creditLists) { - let amount = mutations.createAmount(data.creditLists[creditList]) - let credit = mutations.createCredit(data.creditLists[creditList]) - let sum = mutations.createSum(credit, amount) - list[creditList] = [{...credit}, {...amount}, {...sum}] - } - state.users[index].creditList = list - } - if (data.locked !== undefined) state.users[index].locked = data.locked - if (data.limit !== undefined) state.users[index].limit = data.limit - if (data.autoLock !== undefined) state.users[index].autoLock = data.autoLock - }, - setMails: (state, data) => { - state.errorMails = data - }, - setMail: (state, data) => { - state.errorMail = data - }, - setYears: (state) => { - for (let year = new Date().getFullYear(); year >= 2000; year--) { - state.years.push({value: year, text: year}) - } - }, - setYear: (state, value) => { - if(value) state.year++ - else state.year-- + setAllUsers: (state, users) => { + state.allUsers = [] + state.allUsers = users + for (let i = 0; i < state.allUsers.length; i++) { + state.allUsers[i].fullName = + state.allUsers[i].firstname + ' ' + state.allUsers[i].lastname } -}; + }, + setActiveUser: (state, user) => { + if (state.activeUser.username === user.username) { + state.activeUser = { username: null } + } else { + state.activeUser = user + } + state.errorMail = null + }, + setUsers: (state, users) => { + // eslint-disable-next-line no-console + console.log('users', users) + for (let user in users) { + // eslint-disable-next-line no-console + console.log('user', user) + let list = {} + for (let creditList in users[user]['creditList']) { + let amount = mutations.createAmount( + users[user]['creditList'][creditList] + ) + let credit = mutations.createCredit( + users[user]['creditList'][creditList] + ) + let sum = mutations.createSum(credit, amount) + list[creditList] = [{ ...credit }, { ...amount }, { ...sum }] + } + + let existUser = state.users.find(a => { + return a.username === user + }) + + // eslint-disable-next-line no-console + console.log(existUser) + if (existUser) { + existUser.username = users[user].username + existUser.firstname = users[user].firstname + existUser.lastname = users[user].lastname + existUser.limit = users[user].limit + existUser.locked = users[user].locked + existUser.autoLock = users[user].autoLock + existUser.creditList = list + } else { + state.users.push({ + username: users[user].username, + firstname: users[user].firstname, + lastname: users[user].lastname, + limit: users[user].limit, + locked: users[user].locked, + autoLock: users[user].autoLock, + creditList: list, + expand: false + }) + } + } + mutations.sortUsers(state) + + // eslint-disable-next-line no-console + console.log(state.users) + }, + createAmount(creditList) { + let amount = { + type: 'Schulden', + jan_amount: 0 - creditList.jan.depts, + feb_amount: 0 - creditList.feb.depts, + maer_amount: 0 - creditList.maer.depts, + apr_amount: 0 - creditList.apr.depts, + mai_amount: 0 - creditList.mai.depts, + jun_amount: 0 - creditList.jun.depts, + jul_amount: 0 - creditList.jul.depts, + aug_amount: 0 - creditList.aug.depts, + sep_amount: 0 - creditList.sep.depts, + okt_amount: 0 - creditList.okt.depts, + nov_amount: 0 - creditList.nov.depts, + dez_amount: 0 - creditList.dez.depts, + last: 0 - creditList['last'] + } + + amount.sum = + amount.jan_amount + + amount.feb_amount + + amount.maer_amount + + amount.apr_amount + + amount.mai_amount + + amount.jun_amount + + amount.jul_amount + + amount.aug_amount + + amount.sep_amount + + amount.okt_amount + + amount.nov_amount + + amount.dez_amount + return amount + }, + createCredit(creditList) { + let credit = { + type: 'Guthaben', + jan_amount: creditList.jan.credit, + feb_amount: creditList.feb.credit, + maer_amount: creditList.maer.credit, + apr_amount: creditList.apr.credit, + mai_amount: creditList.mai.credit, + jun_amount: creditList.jun.credit, + jul_amount: creditList.jul.credit, + aug_amount: creditList.aug.credit, + sep_amount: creditList.sep.credit, + okt_amount: creditList.okt.credit, + nov_amount: creditList.nov.credit, + dez_amount: creditList.dez.credit + } + credit.sum = + credit.jan_amount + + credit.feb_amount + + credit.maer_amount + + credit.apr_amount + + credit.mai_amount + + credit.jun_amount + + credit.jul_amount + + credit.aug_amount + + credit.sep_amount + + credit.okt_amount + + credit.nov_amount + + credit.dez_amount + return credit + }, + createSum(credit, amount) { + let sum = { + type: 'Summe', + jan_amount: credit.jan_amount + amount.jan_amount, + feb_amount: credit.feb_amount + amount.feb_amount, + maer_amount: credit.maer_amount + amount.maer_amount, + apr_amount: credit.apr_amount + amount.apr_amount, + mai_amount: credit.mai_amount + amount.mai_amount, + jun_amount: credit.jun_amount + amount.jun_amount, + jul_amount: credit.jul_amount + amount.jul_amount, + aug_amount: credit.aug_amount + amount.aug_amount, + sep_amount: credit.sep_amount + amount.sep_amount, + okt_amount: credit.okt_amount + amount.okt_amount, + nov_amount: credit.nov_amount + amount.nov_amount, + dez_amount: credit.dez_amount + amount.dez_amount + } + sum.sum = + sum.jan_amount + + sum.feb_amount + + sum.maer_amount + + sum.apr_amount + + sum.mai_amount + + sum.jun_amount + + sum.jul_amount + + sum.aug_amount + + sum.sep_amount + + sum.okt_amount + + sum.nov_amount + + sum.dez_amount + return sum + }, + sortUsers: state => { + state.users = state.users.sort((a, b) => { + if (a.lastname > b.lastname) return 1 + if (a.lastname < b.lastname) return -1 + if (a.firstname > b.firstname) return 1 + if (a.firstname < b.firstname) return -1 + return 0 + }) + }, + updateUsers: (state, data) => { + let index = state.users.indexOf( + state.users.find(a => { + return a.username === data.username + }) + ) + if (data.creditLists !== undefined) { + let list = {} + for (let creditList in data.creditLists) { + let amount = mutations.createAmount(data.creditLists[creditList]) + let credit = mutations.createCredit(data.creditLists[creditList]) + let sum = mutations.createSum(credit, amount) + list[creditList] = [{ ...credit }, { ...amount }, { ...sum }] + } + state.users[index].creditList = list + } + if (data.locked !== undefined) state.users[index].locked = data.locked + if (data.limit !== undefined) state.users[index].limit = data.limit + if (data.autoLock !== undefined) state.users[index].autoLock = data.autoLock + }, + setMails: (state, data) => { + state.errorMails = data + }, + setMail: (state, data) => { + state.errorMail = data + }, + setYears: state => { + for (let year = new Date().getFullYear(); year >= 2000; year--) { + state.years.push({ value: year, text: year }) + } + }, + setYear: (state, value) => { + if (value) state.year++ + else state.year-- + } +} const actions = { - // eslint-disable-next-line no-unused-vars - async getAllUsers({commit, rootState, dispatch}) { - // eslint-disable-next-line no-console - console.log(rootState) - try { - const response = await axios.post(url.searchUser, {searchString: ""}, {headers: {Token: rootState.login.user.accessToken}}) - commit('setAllUsers', response.data) - } catch (err) { - // eslint-disable-next-line no-console - if (err.response) if (err.response.status === 401) dispatch('logout', null, {root: true}) - } - }, - async getUsers({commit, rootState, dispatch}) { - try { - const response = await axios.get(url.getFinanzerMain, {headers: {Token: rootState.login.user.accessToken}}) - // eslint-disable-next-line no-console - console.log('response', response.data) - commit('setUsers', response.data) - } catch (err) { - // eslint-disable-next-line no-console - console.log(err) - if (err.response) if (err.response.status === 401) dispatch('logout', null, {root: true}) - } - }, - setActiveUser({ commit }, user) { - commit('setActiveUser', user) - }, - async addAmount({commit, rootState, dispatch}, data) { - try { - const response = await axios.post(url.finanzerAddAmount, {userId: data.user.username, amount: data.amount * 100, year: data.year, month: data.month}, {headers: {Token: rootState.login.user.accessToken}}) - const creditLists = {...response.data} - delete creditLists.locked - commit('updateUsers', {creditLists: creditLists, locked: response.data.locked, username: data.user.username}) - } catch (err) { - if (err.response) if (err.response.status === 401) dispatch('logout', null, {root: true}) - } - }, - async addCredit({commit, rootState, dispatch}, data) { - try { - const response = await axios.post(url.finanzerAddCredit, {userId: data.user.username, credit: data.credit * 100, year: data.year, month: data.month}, {headers: {Token: rootState.login.user.accessToken}}) - const creditLists = {...response.data} - delete creditLists.locked - commit('updateUsers', {creditLists: creditLists, locked: response.data.locked, username: data.user.username}) - } catch (err) { - if (err.response) if (err.response.status === 401) dispatch('logout', null, {root: true}) - } - }, - async doLock({commit, rootState, dispatch}, data) { - try { - const response = await axios.post(url.lockUser, {userId: data.user.username, locked: data.locked}, {headers: {Token: rootState.login.user.accessToken}}) - commit('updateUsers', response.data) - } catch (e) { - if (e.response) if(e.response.status === 401) dispatch('logout', null, {root: true}) - } - }, - async saveConfig({commit, rootState, dispatch}, data) { - try { - const response = await axios.post(url.finanzerSetConfig, {userId: data.user.username, limit: data.limit * 100, autoLock: data.autoLock}, {headers: {Token: rootState.login.user.accessToken}}) - commit('updateUsers', response.data) - } catch (e) { - if (e.response) if(e.response.status === 401) dispatch('logout', null, {root: true}) - } - }, - async addUser({commit, rootState, dispatch}, data) { - try { - const response = await axios.post(url.finanzerAddUser, {userId: data.username}, {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 sendMails({commit, rootState, dispatch}) { - try { - const response = await axios.get(url.finanzerSendAllMail, {headers: {Token: rootState.login.user.accessToken}}) - commit('setMails', response.data) - } catch (e) { - if (e.response) if (e.response.status === 401) dispatch('logout', null, {root: true}) - } - }, - async sendMail({commit, rootState, dispatch}, data) { - try { - const response = await axios.post(url.finanzerSendOneMail, {userId: data.username}, {headers: {Token: rootState.login.user.accessToken}}) - commit('setMail', response.data) - } catch (e) { - if (e.response) if (e.response.status === 401) dispatch('logout', null, {root: true}) - } - }, - createYears({commit}) { - commit('setYears') - return 'hallo' - }, - countYear({commit}, value) { - commit('setYear', value) + // eslint-disable-next-line no-unused-vars + async getAllUsers({ commit, rootState, dispatch }) { + // eslint-disable-next-line no-console + console.log(rootState) + try { + const response = await axios.post( + url.searchUser, + { searchString: '' }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('setAllUsers', response.data) + } catch (err) { + // eslint-disable-next-line no-console + if (err.response) + if (err.response.status === 401) + dispatch('logout', null, { root: true }) } -}; + }, + async getUsers({ commit, rootState, dispatch }) { + try { + const response = await axios.get(url.getFinanzerMain, { + headers: { Token: rootState.login.user.accessToken } + }) + // eslint-disable-next-line no-console + console.log('response', response.data) + commit('setUsers', response.data) + } catch (err) { + // eslint-disable-next-line no-console + console.log(err) + if (err.response) + if (err.response.status === 401) + dispatch('logout', null, { root: true }) + } + }, + setActiveUser({ commit }, user) { + commit('setActiveUser', user) + }, + async addAmount({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.finanzerAddAmount, + { + userId: data.user.username, + amount: data.amount * 100, + year: data.year, + month: data.month + }, + { headers: { Token: rootState.login.user.accessToken } } + ) + const creditLists = { ...response.data } + delete creditLists.locked + commit('updateUsers', { + creditLists: creditLists, + locked: response.data.locked, + username: data.user.username + }) + } catch (err) { + if (err.response) + if (err.response.status === 401) + dispatch('logout', null, { root: true }) + } + }, + async addCredit({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.finanzerAddCredit, + { + userId: data.user.username, + credit: data.credit * 100, + year: data.year, + month: data.month + }, + { headers: { Token: rootState.login.user.accessToken } } + ) + const creditLists = { ...response.data } + delete creditLists.locked + commit('updateUsers', { + creditLists: creditLists, + locked: response.data.locked, + username: data.user.username + }) + } catch (err) { + if (err.response) + if (err.response.status === 401) + dispatch('logout', null, { root: true }) + } + }, + async doLock({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.lockUser, + { userId: data.user.username, locked: data.locked }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updateUsers', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async saveConfig({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.finanzerSetConfig, + { + userId: data.user.username, + limit: data.limit * 100, + autoLock: data.autoLock + }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updateUsers', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async addUser({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.finanzerAddUser, + { userId: data.username }, + { 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 sendMails({ commit, rootState, dispatch }) { + try { + const response = await axios.get(url.finanzerSendAllMail, { + headers: { Token: rootState.login.user.accessToken } + }) + commit('setMails', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async sendMail({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.finanzerSendOneMail, + { userId: data.username }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('setMail', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + createYears({ commit }) { + commit('setYears') + return 'hallo' + }, + countYear({ commit }, value) { + commit('setYear', value) + } +} const getters = { - users: state => { return state.users }, - activeUser: state => { return state.activeUser }, - allUsers: state => { return state.allUsers }, - user: state => { return state.user }, - errorMails: state => { return state.errorMails }, - errorMail: state => { return state.errorMail }, - years: state => { return state.years }, - selectYears: state => {return state.years}, - year: state => { return state.year }, - months: state => { return state.months}, - - -}; + users: state => { + return state.users + }, + activeUser: state => { + return state.activeUser + }, + allUsers: state => { + return state.allUsers + }, + user: state => { + return state.user + }, + errorMails: state => { + return state.errorMails + }, + errorMail: state => { + return state.errorMail + }, + years: state => { + return state.years + }, + selectYears: state => { + return state.years + }, + year: state => { + return state.year + }, + months: state => { + return state.months + } +} export default { - namespaced: true, - state, - mutations, - actions, - getters + namespaced: true, + state, + mutations, + actions, + getters } diff --git a/src/store/modules/login.js b/src/store/modules/login.js index fa0eae0..8604395 100644 --- a/src/store/modules/login.js +++ b/src/store/modules/login.js @@ -1,98 +1,107 @@ -import axios from 'axios'; -import router from "@/router"; +import axios from 'axios' +import router from '@/router' import url from '@/plugins/routes' const state = { - user: { + user: { + username: null, + accessToken: null, + group: null + }, + loggingIn: false, + loginError: null +} + +const mutations = { + loginStart: state => (state.loggingIn = true), + loginStop(state, errorMessage) { + state.loggingIn = false + state.loginError = errorMessage + }, + updateAccessToken(state, data) { + if (typeof data === typeof '') { + data = JSON.parse(data) + } + if (data === null || data === undefined) { + state.user.username = null + state.user.accessToken = null + state.user.group = null + } else { + state.user.username = data.username + state.user.accessToken = data.accessToken + state.user.group = data.group + } + }, + logout(state) { + state.user.accessToken = null + state.user.username = null + state.user.group = null + } +} + +const actions = { + async doLogin({ commit }, loginData) { + commit('loginStart') + try { + const response = await axios.post(url.login, { ...loginData }) + 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 (state.user.group.includes('moneymaster')) { + router.push('/finanzer') + } else if (state.user.group.includes('bar')) { + router.push('/bar') + } + } catch (err) { + commit('loginStop', err.response.data.error) + commit('updateAccessToken', { username: null, accessToken: null, group: null - }, - loggingIn: false, - loginError: null -}; - -const mutations = { - loginStart: state => state.loggingIn = true, - loginStop (state, errorMessage){ - state.loggingIn = false; - state.loginError = errorMessage; - }, - updateAccessToken (state, data) { - if (typeof(data) === typeof("")) { - data = JSON.parse(data) - } - if (data === null || data === undefined) { - state.user.username = null; - state.user.accessToken = null; - state.user.group = null; - } else { - state.user.username = data.username; - state.user.accessToken = data.accessToken; - state.user.group = data.group; - } - }, - logout (state) { - state.user.accessToken = null; - state.user.username = null; - state.user.group = null; + }) } -}; - -const actions = { - async doLogin({ commit }, loginData) { - commit('loginStart'); - try { - const response = await axios.post(url.login, {...loginData}) - 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 (state.user.group.includes('moneymaster')) { - router.push('/finanzer'); - } - else if (state.user.group.includes('bar')) { - router.push('/bar') - } - - } catch (err) { - commit('loginStop', err.response.data.error) - commit('updateAccessToken', {username: null, accessToken: null, group: null}) - } - }, - fetchAccessToken({ commit }) { - commit('updateAccessToken', localStorage.getItem('user')) - }, - logout({ commit }) { - localStorage.removeItem('user'); - commit('logout'); - router.push('/login'); - }, - resetLoginError({ commit }) { - commit("loginStop") - } -}; + }, + fetchAccessToken({ commit }) { + commit('updateAccessToken', localStorage.getItem('user')) + }, + logout({ commit }) { + localStorage.removeItem('user') + commit('logout') + router.push('/login') + }, + resetLoginError({ commit }) { + commit('loginStop') + } +} const getters = { - getGroup: state => { - return state.user.group - }, - group: state => { - return state.user.group - }, - getToken: state => { - return state.user.accessToken - }, - token: state => { - return state.user.accessToken - }, - loginError: state => { - return state.loginError - } -}; + getGroup: state => { + return state.user.group + }, + group: state => { + return state.user.group + }, + getToken: state => { + return state.user.accessToken + }, + token: state => { + return state.user.accessToken + }, + loginError: state => { + return state.loginError + } +} export default { - state, - mutations, - actions, - getters -}; + state, + mutations, + actions, + getters +} diff --git a/src/views/BarView.vue b/src/views/BarView.vue index 8ce1bba..04a38a2 100644 --- a/src/views/BarView.vue +++ b/src/views/BarView.vue @@ -1,34 +1,29 @@ diff --git a/src/views/FinanzerView.vue b/src/views/FinanzerView.vue index 34c64c4..067fd84 100644 --- a/src/views/FinanzerView.vue +++ b/src/views/FinanzerView.vue @@ -1,82 +1,100 @@ diff --git a/src/views/Home.vue b/src/views/Home.vue index 2a8d522..d076a9f 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -1,13 +1,13 @@ From 1bd0d87034ab7b77e319aed30cf6947d509c3309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 14 Jan 2020 22:30:14 +0100 Subject: [PATCH 017/117] fix some bugs --- package-lock.json | 24 ++++++++++++++++++++++++ package.json | 1 + src/plugins/routes.js | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 69201da..35e5a2a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4283,6 +4283,15 @@ "rimraf": "^2.6.1" } }, + "eslint-plugin-prettier": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.2.tgz", + "integrity": "sha512-GlolCC9y3XZfv3RQfwGew7NnuFDKsfI4lbvRK+PIIo23SFH+LemGs4cKwzAaRa+Mdb+lQO/STaIayno8T5sJJA==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0" + } + }, "eslint-plugin-vue": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-5.2.3.tgz", @@ -4648,6 +4657,12 @@ "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", "dev": true }, + "fast-diff": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", + "dev": true + }, "fast-glob": { "version": "2.2.7", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-2.2.7.tgz", @@ -8635,6 +8650,15 @@ "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", "dev": true }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, "pretty-error": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-2.1.1.tgz", diff --git a/package.json b/package.json index b9b8e66..775126e 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "axios": "^0.19.0", "babel-eslint": "^10.0.3", "eslint": "^5.16.0", + "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-vue": "^5.0.0", "material-design-icons-iconfont": "^5.0.1", "prettier": "^1.19.1", diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 9d79aca..4a9c8a2 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -1,4 +1,5 @@ -const main = 'http://192.168.5.118:5000/' +//const main = 'http://192.168.5.118:5000/' +const main = 'http://localhost:5000/' const url = { login: main + 'login', From 708f40938a6975ee541d60c88d023a84b1b44d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 14 Jan 2020 23:10:09 +0100 Subject: [PATCH 018/117] add search for baruser TODO: maybe we can change the filter in finanzerview too --- src/components/baruser/CreditLists.vue | 211 +++++++++++++++---------- src/components/baruser/SearchBar.vue | 15 +- src/components/finanzer/Overview.vue | 83 +++++++--- src/store/modules/barUsers.js | 26 ++- src/store/modules/finanzerUsers.js | 16 -- 5 files changed, 206 insertions(+), 145 deletions(-) diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index 35bff87..03db226 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -1,90 +1,116 @@ @@ -102,8 +128,6 @@ export default { }, created() { this.getUsers() - // eslint-disable-next-line no-console - console.log(this.users) }, methods: { ...mapActions({ @@ -112,10 +136,23 @@ export default { }), getColor(type) { return type === 'credit' ? 'title green--text' : 'title red--text' + }, + isFiltered(user) { + try { + return ( + user.firstname.toLowerCase().includes(this.filter.toLowerCase()) || + user.lastname.toLowerCase().includes(this.filter.toLowerCase()) + ) + } catch (e) { + return true + } } }, computed: { - ...mapGetters({ users: 'barUsers/users' }) + ...mapGetters({ + users: 'barUsers/users', + filter: 'barUsers/filter' + }) } } diff --git a/src/components/baruser/SearchBar.vue b/src/components/baruser/SearchBar.vue index c1abe10..58efddf 100644 --- a/src/components/baruser/SearchBar.vue +++ b/src/components/baruser/SearchBar.vue @@ -13,6 +13,7 @@ item-text="fullName" prepend-inner-icon="search" full-width + :search-input.sync="filter" /> Hinzufügen @@ -28,7 +29,8 @@ export default { props: {}, data() { return { - user: null + user: null, + filter: '' } }, created() { @@ -37,7 +39,8 @@ export default { methods: { ...mapActions({ getAllUsers: 'barUsers/getAllUsers', - addCreditList: 'barUsers/addCreditList' + addCreditList: 'barUsers/addCreditList', + setFilter: 'barUsers/setFilter' }), addUser() { this.addCreditList(this.user) @@ -46,9 +49,13 @@ export default { }, computed: { ...mapGetters({ allUsers: 'barUsers/allUsers' }) + }, + watch: { + filter(val) { + this.setFilter(val) + } } } - + diff --git a/src/components/finanzer/Overview.vue b/src/components/finanzer/Overview.vue index 37da410..ec0c0ae 100644 --- a/src/components/finanzer/Overview.vue +++ b/src/components/finanzer/Overview.vue @@ -8,7 +8,7 @@ keyboard_arrow_left - {{year}} + {{ year }} keyboard_arrow_right @@ -17,7 +17,12 @@ Emails senden - + @@ -28,7 +33,7 @@ text icon style="margin-right: 5px" - @click="errorExpand ? errorExpand = false : errorExpand = true" + @click="errorExpand ? (errorExpand = false) : (errorExpand = true)" > $expand @@ -40,14 +45,18 @@ :key="errorMails.indexOf(error)" dense :type="computeError(error.error)" - >{{errorMessage(error)}} + >{{ errorMessage(error) }}
- - {{user.lastname}}, {{user.firstname}} + + {{ user.lastname }}, {{ user.firstname }}
@@ -60,7 +69,10 @@ {{(user.creditList[year][1].last / 100).toFixed(2)}} + >{{ + (user.creditList[year][1].last / 100).toFixed(2) + }} @@ -71,10 +83,23 @@ - {{(getAllSum(user.creditList[year][2].sum ,user.creditList[year][1].last) / - 100).toFixed(2)}} + {{ + ( + getAllSum( + user.creditList[year][2].sum, + user.creditList[year][1].last + ) / 100 + ).toFixed(2) + }} @@ -85,18 +110,26 @@ Status: - {{user.locked ? 'Gesperrt': 'nicht Gesperrt'}} + {{ + user.locked ? 'Gesperrt' : 'nicht Gesperrt' + }} - Geld transferieren + Geld transferieren - - $expand + + $expand @@ -104,14 +137,21 @@ - + @@ -191,10 +231,7 @@ export default { } } }, - created() { - // eslint-disable-next-line no-console - console.log(this.getData(this.createYears())) - }, + created() {}, methods: { ...mapActions({ createYears: 'finanzerUsers/createYears', diff --git a/src/store/modules/barUsers.js b/src/store/modules/barUsers.js index ed4186a..6dab54b 100644 --- a/src/store/modules/barUsers.js +++ b/src/store/modules/barUsers.js @@ -3,7 +3,8 @@ import url from '@/plugins/routes' const state = { users: [], - allUsers: [] + allUsers: [], + filter: '' } const mutations = { @@ -16,11 +17,7 @@ const mutations = { } }, setUsers: (state, users) => { - // eslint-disable-next-line no-console - console.log(users) for (let user in users) { - // eslint-disable-next-line no-console - console.log(user) let existuser = state.users.find(a => { return user === a.username }) @@ -43,8 +40,6 @@ const mutations = { }) } } - // eslint-disable-next-line no-console - console.log(state.users) mutations.sortUsers(state) }, sortUsers: state => { @@ -55,6 +50,9 @@ const mutations = { if (a.firstname < b.firstname) return -1 return 0 }) + }, + setFilter: (state, filter) => { + state.filter = filter } } @@ -65,8 +63,6 @@ const actions = { const response = await axios.get(url.bar, { headers: { Token: rootState.login.user.accessToken } }) - // eslint-disable-next-line no-console - console.log(response.data) commit('setUsers', response.data) } catch (e) { if (e.response) @@ -100,23 +96,20 @@ const actions = { } }, async getAllUsers({ commit, rootState, dispatch }) { - // eslint-disable-next-line no-console - console.log('hier bin ich') try { const response = await axios.post( url.searchUser, { searchString: '' }, { headers: { Token: rootState.login.user.accessToken } } ) - // eslint-disable-next-line no-console - console.log(response) commit('setAllUsers', response.data) } catch (e) { - // eslint-disable-next-line no-console - console.log(e) if (e.response) if (e.response.data === 401) dispatch('logout', null, { root: true }) } + }, + setFilter({ commit }, data) { + commit('setFilter', data) } } @@ -126,6 +119,9 @@ const getters = { }, allUsers: state => { return state.allUsers + }, + filter: state => { + return state.filter } } diff --git a/src/store/modules/finanzerUsers.js b/src/store/modules/finanzerUsers.js index d379a36..766f0f6 100644 --- a/src/store/modules/finanzerUsers.js +++ b/src/store/modules/finanzerUsers.js @@ -47,11 +47,7 @@ const mutations = { state.errorMail = null }, setUsers: (state, users) => { - // eslint-disable-next-line no-console - console.log('users', users) for (let user in users) { - // eslint-disable-next-line no-console - console.log('user', user) let list = {} for (let creditList in users[user]['creditList']) { let amount = mutations.createAmount( @@ -67,9 +63,6 @@ const mutations = { let existUser = state.users.find(a => { return a.username === user }) - - // eslint-disable-next-line no-console - console.log(existUser) if (existUser) { existUser.username = users[user].username existUser.firstname = users[user].firstname @@ -92,9 +85,6 @@ const mutations = { } } mutations.sortUsers(state) - - // eslint-disable-next-line no-console - console.log(state.users) }, createAmount(creditList) { let amount = { @@ -240,8 +230,6 @@ const mutations = { const actions = { // eslint-disable-next-line no-unused-vars async getAllUsers({ commit, rootState, dispatch }) { - // eslint-disable-next-line no-console - console.log(rootState) try { const response = await axios.post( url.searchUser, @@ -261,12 +249,8 @@ const actions = { const response = await axios.get(url.getFinanzerMain, { headers: { Token: rootState.login.user.accessToken } }) - // eslint-disable-next-line no-console - console.log('response', response.data) commit('setUsers', response.data) } catch (err) { - // eslint-disable-next-line no-console - console.log(err) if (err.response) if (err.response.status === 401) dispatch('logout', null, { root: true }) From 8f786d3883d2b966bc9f41c875be564298f167b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Fri, 17 Jan 2020 01:01:10 +0100 Subject: [PATCH 019/117] new Layout and new Routes for router --- package.json | 4 +- src/App.vue | 10 +- src/components/TitleBar.vue | 33 ++--- src/components/user/AddAmount.vue | 132 +++++++++++++++++++ src/components/user/CreditOverview.vue | 107 ++++++++++++++++ src/plugins/routes.js | 4 +- src/router/index.js | 68 ++++++++-- src/store/index.js | 4 +- src/store/modules/login.js | 30 ++++- src/store/modules/user.js | 168 +++++++++++++++++++++++++ src/views/BarView.vue | 26 +--- src/views/FinanzerView.vue | 32 +++-- src/views/Login.vue | 28 +++-- src/views/MainView.vue | 84 +++++++++++++ src/views/UserView.vue | 27 ++++ src/views/contents/GeruechteView.vue | 27 ++++ 16 files changed, 700 insertions(+), 84 deletions(-) create mode 100644 src/components/user/AddAmount.vue create mode 100644 src/components/user/CreditOverview.vue create mode 100644 src/store/modules/user.js create mode 100644 src/views/MainView.vue create mode 100644 src/views/UserView.vue create mode 100644 src/views/contents/GeruechteView.vue diff --git a/package.json b/package.json index 775126e..bce46ff 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,9 @@ "@vue/prettier", "eslint:recommended" ], - "rules": {}, + "rules": { + "no-console": "off" + }, "parserOptions": { "parser": "babel-eslint" } diff --git a/src/App.vue b/src/App.vue index 164699d..58a0a74 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,18 +1,20 @@ diff --git a/src/components/user/AddAmount.vue b/src/components/user/AddAmount.vue new file mode 100644 index 0000000..e60dfb4 --- /dev/null +++ b/src/components/user/AddAmount.vue @@ -0,0 +1,132 @@ + + + + + diff --git a/src/components/user/CreditOverview.vue b/src/components/user/CreditOverview.vue new file mode 100644 index 0000000..01c0cbe --- /dev/null +++ b/src/components/user/CreditOverview.vue @@ -0,0 +1,107 @@ + + + + + diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 4a9c8a2..b4862fe 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -15,7 +15,9 @@ const url = { finanzerSetConfig: main + 'finanzerSetConfig', finanzerAddUser: main + 'finanzerAddUser', finanzerSendAllMail: main + 'finanzerSendAllMail', - finanzerSendOneMail: main + 'finanzerSendOneMail' + finanzerSendOneMail: main + 'finanzerSendOneMail', + userMain: main + 'user/main', + userAddAmount: main + 'user/addAmount' } export default url diff --git a/src/router/index.js b/src/router/index.js index e7f546e..013404d 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -3,7 +3,12 @@ import VueRouter from 'vue-router' import FinanzerView from '@/views/FinanzerView' import Login from '@/views/Login' import store from '@/store/index' -import BarView from '@/views/BarView' +import GeruechteView from '../views/contents/GeruechteView' +import AddAmount from '../components/user/AddAmount' +import CreditOverview from '../components/user/CreditOverview' +import MainView from '../views/MainView' +import UserView from '../views/UserView' +import BarView from '../views/BarView' Vue.use(VueRouter) @@ -19,9 +24,45 @@ const routes = [ component: FinanzerView }, { - path: '/bar', - name: 'bar', - component: BarView + path: '/main', + name: 'main', + component: MainView, + children: [ + { + path: 'user', + name: 'user', + component: UserView, + children: [ + { + path: 'add', + name: 'add', + component: AddAmount + }, + { + path: 'overview', + name: 'userOverview', + component: CreditOverview + } + ] + }, + { + path: 'bar', + name: 'bar', + component: BarView, + children: [ + { + path: 'geruecht', + name: 'geruecht', + component: GeruechteView + } + ] + }, + { + path: 'finanzer', + name: 'finanzer', + component: FinanzerView + } + ] }, { path: '*', @@ -39,18 +80,23 @@ const router = new VueRouter({ router.beforeEach((to, from, next) => { store.dispatch('fetchAccessToken') - let sites = ['/finanzer', '/bar'] - if (sites.includes(to.fullPath)) { - if (to.fullPath === '/finanzer') { + console.log('fullPath', to.fullPath) + if (to.fullPath.includes('/main')) { + if (to.fullPath.includes('/main/finanzer')) { if (!store.state.login.user.group.includes('moneymaster')) { next('/login') } } - if (to.fullPath === '/bar') { + if (to.fullPath.includes('/main/bar')) { if (!store.state.login.user.group.includes('bar')) { next('/login') } } + if (to.fullPath.includes('/main/user')) { + if (!store.state.login.user.group.includes('user')) { + next('/login') + } + } if (!store.state.login.user.accessToken) { next('/login') } @@ -58,9 +104,11 @@ router.beforeEach((to, from, next) => { if (to.fullPath === '/login') { if (store.state.login.user.accessToken) { if (store.state.login.user.group.includes('moneymaster')) { - next('/finanzer') + next('/main/finanzer') } else if (store.state.login.user.group.includes('bar')) { - next('/bar') + next('/main/bar/geruecht') + } else if (store.state.login.user.group.includes('user')) { + next('/main/user/add') } } } diff --git a/src/store/index.js b/src/store/index.js index e8ca7be..8687346 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -3,6 +3,7 @@ import Vuex from 'vuex' import login from './modules/login' import finanzerUsers from './modules/finanzerUsers' import barUsers from '@/store/modules/barUsers' +import user from '@/store/modules/user' Vue.use(Vuex) @@ -10,6 +11,7 @@ export default new Vuex.Store({ modules: { login, finanzerUsers, - barUsers + barUsers, + user } }) diff --git a/src/store/modules/login.js b/src/store/modules/login.js index 8604395..7abbb6d 100644 --- a/src/store/modules/login.js +++ b/src/store/modules/login.js @@ -55,9 +55,11 @@ const actions = { commit('loginStop', null) commit('updateAccessToken', response.data) if (state.user.group.includes('moneymaster')) { - router.push('/finanzer') + router.push('/main/finanzer') } else if (state.user.group.includes('bar')) { - router.push('/bar') + router.push('/main/bar/geruecht') + } else if (state.user.group.includes('user')) { + router.push('/main/user/add') } } catch (err) { commit('loginStop', err.response.data.error) @@ -96,6 +98,30 @@ const getters = { }, loginError: state => { return state.loginError + }, + isBar: state => { + try { + return state.user.group.includes('bar') ? true : false + } catch (e) { + return false + } + }, + isFinanzer: state => { + try { + return state.user.group.includes('moneymaster') ? true : false + } catch (e) { + return false + } + }, + isUser: state => { + try { + return state.user.group.includes('user') ? true : false + } catch (e) { + return false + } + }, + isLoggedIn: state => { + return state.user.accessToken ? true : false } } diff --git a/src/store/modules/user.js b/src/store/modules/user.js new file mode 100644 index 0000000..4118304 --- /dev/null +++ b/src/store/modules/user.js @@ -0,0 +1,168 @@ +import axios from 'axios' +import url from '@/plugins/routes' + +const state = { + user: null, + creditList: [] +} + +const mutations = { + setUser: (state, user) => { + state.user = user + let list = {} + for (let creditList in user['creditList']) { + console.log(creditList) + let amount = mutations.createAmount(user['creditList'][creditList]) + let credit = mutations.createCredit(user['creditList'][creditList]) + let sum = mutations.createSum(credit, amount) + list[creditList] = [{ ...credit }, { ...amount }, { ...sum }] + } + state.user.creditList = list + state.creditList = [] + console.log(state.user) + }, + createAmount(creditList) { + let amount = { + type: 'Schulden', + jan_amount: 0 - creditList.jan.depts, + feb_amount: 0 - creditList.feb.depts, + maer_amount: 0 - creditList.maer.depts, + apr_amount: 0 - creditList.apr.depts, + mai_amount: 0 - creditList.mai.depts, + jun_amount: 0 - creditList.jun.depts, + jul_amount: 0 - creditList.jul.depts, + aug_amount: 0 - creditList.aug.depts, + sep_amount: 0 - creditList.sep.depts, + okt_amount: 0 - creditList.okt.depts, + nov_amount: 0 - creditList.nov.depts, + dez_amount: 0 - creditList.dez.depts, + last: 0 - creditList['last'] + } + + amount.sum = + amount.jan_amount + + amount.feb_amount + + amount.maer_amount + + amount.apr_amount + + amount.mai_amount + + amount.jun_amount + + amount.jul_amount + + amount.aug_amount + + amount.sep_amount + + amount.okt_amount + + amount.nov_amount + + amount.dez_amount + return amount + }, + createCredit(creditList) { + let credit = { + type: 'Guthaben', + jan_amount: creditList.jan.credit, + feb_amount: creditList.feb.credit, + maer_amount: creditList.maer.credit, + apr_amount: creditList.apr.credit, + mai_amount: creditList.mai.credit, + jun_amount: creditList.jun.credit, + jul_amount: creditList.jul.credit, + aug_amount: creditList.aug.credit, + sep_amount: creditList.sep.credit, + okt_amount: creditList.okt.credit, + nov_amount: creditList.nov.credit, + dez_amount: creditList.dez.credit + } + credit.sum = + credit.jan_amount + + credit.feb_amount + + credit.maer_amount + + credit.apr_amount + + credit.mai_amount + + credit.jun_amount + + credit.jul_amount + + credit.aug_amount + + credit.sep_amount + + credit.okt_amount + + credit.nov_amount + + credit.dez_amount + return credit + }, + createSum(credit, amount) { + let sum = { + type: 'Summe', + jan_amount: credit.jan_amount + amount.jan_amount, + feb_amount: credit.feb_amount + amount.feb_amount, + maer_amount: credit.maer_amount + amount.maer_amount, + apr_amount: credit.apr_amount + amount.apr_amount, + mai_amount: credit.mai_amount + amount.mai_amount, + jun_amount: credit.jun_amount + amount.jun_amount, + jul_amount: credit.jul_amount + amount.jul_amount, + aug_amount: credit.aug_amount + amount.aug_amount, + sep_amount: credit.sep_amount + amount.sep_amount, + okt_amount: credit.okt_amount + amount.okt_amount, + nov_amount: credit.nov_amount + amount.nov_amount, + dez_amount: credit.dez_amount + amount.dez_amount + } + sum.sum = + sum.jan_amount + + sum.feb_amount + + sum.maer_amount + + sum.apr_amount + + sum.mai_amount + + sum.jun_amount + + sum.jul_amount + + sum.aug_amount + + sum.sep_amount + + sum.okt_amount + + sum.nov_amount + + sum.dez_amount + return sum + } +} + +const actions = { + async getUser({ commit, rootState, dispatch }) { + try { + const response = await axios.get(url.userMain, { + headers: { Token: rootState.login.user.accessToken } + }) + commit('setUser', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async addAmount({ commit, rootState, dispatch }, amount) { + try { + const response = await axios.post( + url.userAddAmount, + { amount: amount }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('setUser', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + } +} + +const getters = { + user: state => { + return state.user + }, + year: state => { + let year = 0 + for (let creditList in state.user.creditList) { + let currentYear = parseInt(creditList) + if (currentYear > year) year = currentYear + } + return year + } +} + +export default { + namespaced: true, + state, + mutations, + actions, + getters +} diff --git a/src/views/BarView.vue b/src/views/BarView.vue index 04a38a2..3487f61 100644 --- a/src/views/BarView.vue +++ b/src/views/BarView.vue @@ -1,29 +1,13 @@ - + diff --git a/src/views/FinanzerView.vue b/src/views/FinanzerView.vue index 067fd84..302413a 100644 --- a/src/views/FinanzerView.vue +++ b/src/views/FinanzerView.vue @@ -1,7 +1,14 @@ + + diff --git a/src/components/vorstand/ServiceManagementComponents/Day.vue b/src/components/vorstand/ServiceManagementComponents/Day.vue new file mode 100644 index 0000000..84c4266 --- /dev/null +++ b/src/components/vorstand/ServiceManagementComponents/Day.vue @@ -0,0 +1,58 @@ + + + + + diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 3861d98..3fca019 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -1,5 +1,6 @@ -//const main = 'http://192.168.5.118:5000/' +//const main = 'https://192.168.5.128:5000/' const main = 'https://localhost:5000/' +//const main = 'https://groeger-clan.duckdns.org:5000/' const url = { login: main + 'login', diff --git a/src/router/index.js b/src/router/index.js index a816fab..8d6f02b 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -14,6 +14,7 @@ import BarNavigation from '../components/baruser/BarNavigation' import FinanzerNavigation from '../components/finanzer/FinanzerNavigation' import Overview from '../components/finanzer/Overview' import User from '../components/finanzer/User' +import ServiceManagement from '../components/vorstand/ServiceManagement' Vue.use(VueRouter) @@ -71,6 +72,10 @@ const routes = [ name: 'activeUser', props: true, component: User + }, + { + path: 'servicemanagement', + component: ServiceManagement } ] } diff --git a/src/store/index.js b/src/store/index.js index 8687346..412ceef 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -4,6 +4,7 @@ import login from './modules/login' import finanzerUsers from './modules/finanzerUsers' import barUsers from '@/store/modules/barUsers' import user from '@/store/modules/user' +import sm from '@/store/modules/serviceManagement' Vue.use(Vuex) @@ -12,6 +13,7 @@ export default new Vuex.Store({ login, finanzerUsers, barUsers, - user + user, + sm } }) diff --git a/src/store/modules/serviceManagement.js b/src/store/modules/serviceManagement.js new file mode 100644 index 0000000..7702697 --- /dev/null +++ b/src/store/modules/serviceManagement.js @@ -0,0 +1,219 @@ +import axios from 'axios' +import url from '@/plugins/routes' + +const state = { + month: [], + allUsers: [] +} + +const mutations = { + setAllUsers: (state, users) => { + state.allUsers = [] + state.allUsers = users + for (let i = 0; i < state.allUsers.length; i++) { + state.allUsers[i].fullName = + state.allUsers[i].firstname + ' ' + state.allUsers[i].lastname + } + }, + createMonth: (state, date) => { + let month = [] + let id = 0 + const year = date.getFullYear() + const mon = date.getMonth() + let a = new Date(year, mon, 0, 13, 1) + console.log('createMonth', a) + let days = a.getDate() + let startDate = 1 + for (let intDay = 1; intDay <= days; intDay++) { + if (new Date(year, mon, intDay).getDay() === 3) { + startDate = intDay + break + } + } + let week = { id: id, days: {} } + for (let intDay = startDate; intDay <= days; intDay++) { + let currentDate = new Date(year, mon, intDay, 13, 1) + console.log('currentDate', currentDate) + + switch (currentDate.getDay()) { + case 1: + if (week.days.monday) { + week.startDate = week.days.monday.date + } else if (week.days.tuesday) { + week.startDate = week.days.tuesday.date + } else if (week.days.wednesday) { + week.startDate = week.days.wednesday.date + } else if (week.days.thursday) { + week.startDate = week.days.thursday.date + } else if (week.days.friday) { + week.startDate = week.days.friday.date + } else if (week.days.satturday) { + week.startDate = week.days.satturday.date + } else if (week.days.sunday) { + week.startDate = week.days.sunday.date + } + + if (week.days.sunday) { + week.endDate = week.days.sunday.date + } else if (week.days.satturday) { + week.endDate = week.days.satturday.date + } else if (week.days.friday) { + week.endDate = week.days.friday.date + } else if (week.days.thursday) { + week.endDate = week.days.thursday.date + } else if (week.days.wednesday) { + week.endDate = week.days.wednesday.date + } else if (week.days.tuesday) { + week.endDate = week.days.tuesday.date + } else if (week.days.monday) { + week.endDate = week.days.monday.date + } + + month.push(week) + id++ + week = { id: id, days: {} } + week.days.monday = { + id: currentDate.getDay(), + date: currentDate, + name: 'Montag', + worker: [] + } + break + case 2: + week.days.tuesday = { + id: currentDate.getDay(), + date: currentDate, + name: 'Dienstag', + worker: [] + } + break + case 3: + week.days.wednesday = { + id: currentDate.getDay(), + date: currentDate, + name: 'Mittwoch', + worker: [] + } + break + case 4: + week.days.thursday = { + id: currentDate.getDay(), + date: currentDate, + name: 'Donnerstag', + worker: [] + } + break + case 5: + week.days.friday = { + id: currentDate.getDay(), + date: currentDate, + name: 'Freitag', + worker: [] + } + break + case 6: + week.days.satturday = { + id: currentDate.getDay(), + date: currentDate, + name: 'Samstag', + worker: [] + } + break + case 0: + week.days.sunday = { + id: currentDate.getDay(), + date: currentDate, + name: 'Sontag', + worker: [] + } + break + } + } + if (week.days.monday) { + week.startDate = week.days.monday.date + } else if (week.days.tuesday) { + week.startDate = week.days.tuesday.date + } else if (week.days.wednesday) { + week.startDate = week.days.wednesday.date + } else if (week.days.thursday) { + week.startDate = week.days.thursday.date + } else if (week.days.friday) { + week.startDate = week.days.friday.date + } else if (week.days.satturday) { + week.startDate = week.days.satturday.date + } else if (week.days.sunday) { + week.startDate = week.days.sunday.date + } + + if (week.days.sunday) { + week.endDate = week.days.sunday.date + } else if (week.days.satturday) { + week.endDate = week.days.satturday.date + } else if (week.days.friday) { + week.endDate = week.days.friday.date + } else if (week.days.thursday) { + week.endDate = week.days.thursday.date + } else if (week.days.wednesday) { + week.endDate = week.days.wednesday.date + } else if (week.days.tuesday) { + week.endDate = week.days.tuesday.date + } else if (week.days.monday) { + week.endDate = week.days.monday.date + } + month.push(week) + state.month = month + console.log(state.month) + }, + setWorker: (state, data) => { + console.log('hier ist die mutation', data) + for (let week in state.month) { + console.log('week', week) + for (let day in state.month[week].days) { + console.log(state.month[week].days[day], data.day) + if (state.month[week].days[day].date - data.day.date === 0) { + state.month[week].days[day].worker.push(data.worker) + console.log('sm', state.month) + return + } + } + } + } +} +const actions = { + createMonth({ commit }, date) { + commit('createMonth', date) + }, + async getAllUsers({ commit, rootState, dispatch }) { + try { + const response = await axios.post( + url.searchUser, + { searchString: '' }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('setAllUsers', response.data) + } catch (e) { + if (e.response) + if (e.response.data === 401) dispatch('logout', null, { root: true }) + } + }, + setWorker({ commit }, data) { + console.log('hier bin ich', data) + commit('setWorker', data) + } +} +const getters = { + month: state => { + return state.month + }, + allUsers: state => { + return state.allUsers + } +} + +export default { + namespaced: true, + state, + mutations, + actions, + getters +} diff --git a/src/views/FinanzerView.vue b/src/views/FinanzerView.vue index 2341ee9..9d27a1c 100644 --- a/src/views/FinanzerView.vue +++ b/src/views/FinanzerView.vue @@ -1,52 +1,10 @@ diff --git a/src/views/Home.vue b/src/views/Home.vue deleted file mode 100644 index d076a9f..0000000 --- a/src/views/Home.vue +++ /dev/null @@ -1,17 +0,0 @@ - - - From af542bb2e528c0decf3f52dad42a1762cfb671ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 19 Jan 2020 21:31:48 +0100 Subject: [PATCH 022/117] finished serviceManagement --- src/components/vorstand/ServiceManagement.vue | 54 ++++--- .../ServiceManagementComponents/Day.vue | 129 +++++++++++----- src/plugins/routes.js | 9 +- src/store/modules/serviceManagement.js | 139 +++++++++++------- 4 files changed, 217 insertions(+), 114 deletions(-) diff --git a/src/components/vorstand/ServiceManagement.vue b/src/components/vorstand/ServiceManagement.vue index 8586493..276d364 100644 --- a/src/components/vorstand/ServiceManagement.vue +++ b/src/components/vorstand/ServiceManagement.vue @@ -11,7 +11,10 @@ keyboard_arrow_left - {{monthArray[date.getMonth()]}} {{date.getFullYear()}} + {{ monthArray[date.getMonth()] }} + {{ date.getFullYear() }} keyboard_arrow_right @@ -20,17 +23,22 @@ - + Woche vom {{ week.startDate.getDate() }}.{{ - week.startDate.getMonth()+1 - }}.{{week.startDate.getFullYear()}} bis {{ week.endDate.getDate() }}.{{ - week.endDate.getMonth()+1 - }}.{{week.endDate.getFullYear()}} + week.startDate.getMonth() + 1 + }}.{{ week.startDate.getFullYear() }} bis + {{ week.endDate.getDate() }}.{{ week.endDate.getMonth() + 1 }}.{{ + week.endDate.getFullYear() + }} -
- -
+ +
+ + + +
+
@@ -48,18 +56,18 @@ export default { id: 0, date: new Date(), monthArray: [ - 'Januar', - 'Februar', - 'März', - 'April', - 'Mai', - 'Juni', - 'Juli', - 'August', - 'September', - 'Oktober', - 'November', - 'Dezember' + 'Januar', + 'Februar', + 'März', + 'April', + 'Mai', + 'Juni', + 'Juli', + 'August', + 'September', + 'Oktober', + 'November', + 'Dezember' ] } }, @@ -74,9 +82,9 @@ export default { }), changeMonth(value) { if (value === -1) { - this.date = new Date(this.date.getFullYear(), this.date.getMonth(), 0, 1) + this.date = new Date(this.date.getFullYear(), this.date.getMonth() - 1) } else { - this.date = new Date(this.date.getFullYear(), this.date.getMonth() + 2, 0, 1) + this.date = new Date(this.date.getFullYear(), this.date.getMonth() + 1) } this.createMonth(this.date) } diff --git a/src/components/vorstand/ServiceManagementComponents/Day.vue b/src/components/vorstand/ServiceManagementComponents/Day.vue index 84c4266..0b69f14 100644 --- a/src/components/vorstand/ServiceManagementComponents/Day.vue +++ b/src/components/vorstand/ServiceManagementComponents/Day.vue @@ -1,28 +1,46 @@ diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 3fca019..0cbcb75 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -18,7 +18,14 @@ const url = { finanzerSendAllMail: main + 'finanzerSendAllMail', finanzerSendOneMail: main + 'finanzerSendOneMail', userMain: main + 'user/main', - userAddAmount: main + 'user/addAmount' + userAddAmount: main + 'user/addAmount', + vorstand: { + sm: { + addUser: main + 'sm/addUser', + deleteUser: main + 'sm/deleteUser', + getUser: main + 'sm/getUser' + } + } } export default url diff --git a/src/store/modules/serviceManagement.js b/src/store/modules/serviceManagement.js index 7702697..237da7c 100644 --- a/src/store/modules/serviceManagement.js +++ b/src/store/modules/serviceManagement.js @@ -20,8 +20,7 @@ const mutations = { let id = 0 const year = date.getFullYear() const mon = date.getMonth() - let a = new Date(year, mon, 0, 13, 1) - console.log('createMonth', a) + let a = new Date(year, mon + 1, 0) let days = a.getDate() let startDate = 1 for (let intDay = 1; intDay <= days; intDay++) { @@ -30,45 +29,15 @@ const mutations = { break } } + let end = false let week = { id: id, days: {} } - for (let intDay = startDate; intDay <= days; intDay++) { - let currentDate = new Date(year, mon, intDay, 13, 1) - console.log('currentDate', currentDate) + for (let intDay = startDate; intDay <= days + 7; intDay++) { + if (end) break + let currentDate = new Date(year, mon, intDay, 12) switch (currentDate.getDay()) { case 1: - if (week.days.monday) { - week.startDate = week.days.monday.date - } else if (week.days.tuesday) { - week.startDate = week.days.tuesday.date - } else if (week.days.wednesday) { - week.startDate = week.days.wednesday.date - } else if (week.days.thursday) { - week.startDate = week.days.thursday.date - } else if (week.days.friday) { - week.startDate = week.days.friday.date - } else if (week.days.satturday) { - week.startDate = week.days.satturday.date - } else if (week.days.sunday) { - week.startDate = week.days.sunday.date - } - - if (week.days.sunday) { - week.endDate = week.days.sunday.date - } else if (week.days.satturday) { - week.endDate = week.days.satturday.date - } else if (week.days.friday) { - week.endDate = week.days.friday.date - } else if (week.days.thursday) { - week.endDate = week.days.thursday.date - } else if (week.days.wednesday) { - week.endDate = week.days.wednesday.date - } else if (week.days.tuesday) { - week.endDate = week.days.tuesday.date - } else if (week.days.monday) { - week.endDate = week.days.monday.date - } - + mutations.setStartEndDate(week) month.push(week) id++ week = { id: id, days: {} } @@ -88,11 +57,17 @@ const mutations = { } break case 3: - week.days.wednesday = { - id: currentDate.getDay(), - date: currentDate, - name: 'Mittwoch', - worker: [] + if (currentDate.getMonth() === mon + 1) { + end = true + mutations.setStartEndDate(week) + month.push(week) + } else { + week.days.wednesday = { + id: currentDate.getDay(), + date: currentDate, + name: 'Mittwoch', + worker: [] + } } break case 4: @@ -129,6 +104,9 @@ const mutations = { break } } + state.month = month + }, + setStartEndDate: week => { if (week.days.monday) { week.startDate = week.days.monday.date } else if (week.days.tuesday) { @@ -160,20 +138,24 @@ const mutations = { } else if (week.days.monday) { week.endDate = week.days.monday.date } - month.push(week) - state.month = month - console.log(state.month) }, - setWorker: (state, data) => { - console.log('hier ist die mutation', data) - for (let week in state.month) { - console.log('week', week) + updateMonth: (state, data) => { + const date = new Date(data.startdatetime) + const user = data.user + for (let week = 0; week < state.month.length; week++) { for (let day in state.month[week].days) { - console.log(state.month[week].days[day], data.day) - if (state.month[week].days[day].date - data.day.date === 0) { - state.month[week].days[day].worker.push(data.worker) - console.log('sm', state.month) - return + if (state.month[week].days[day].date - date === 0) { + let worker = state.month[week].days[day].worker.find(a => { + return a.username === user.username + }) + if (!worker && data.com === 'add') { + state.month[week].days[day].worker.push({ + firstname: user.firstname, + lastname: user.lastname, + username: user.username, + fullName: user.firstname + ' ' + user.lastname + }) + } } } } @@ -196,9 +178,52 @@ const actions = { if (e.response.data === 401) dispatch('logout', null, { root: true }) } }, - setWorker({ commit }, data) { - console.log('hier bin ich', data) - commit('setWorker', data) + // eslint-disable-next-line no-unused-vars + async addUser({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.vorstand.sm.addUser, + { ...data }, + { + headers: { Token: rootState.login.user.accessToken } + } + ) + console.log(response.data) + commit('updateMonth', {...response.data[0], com: 'add'}) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async getUser({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.vorstand.sm.getUser, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + for (let item = 0; item < response.data.length; item++) { + commit('updateMonth', { ...response.data[item], com: 'add' }) + } + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + // eslint-disable-next-line no-unused-vars + async deleteUser({ commit, rootState, dispatch }, data) { + try { + // eslint-disable-next-line no-unused-vars + const response = await axios.post( + url.vorstand.sm.deleteUser, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updateMonth', {...data, com: 'delete'}) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } } } const getters = { From db524355b5825c9c410313837985a9afba8fd85f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Thu, 23 Jan 2020 11:11:26 +0100 Subject: [PATCH 023/117] =?UTF-8?q?added=20loading=20and=20fix=20bug=20th?= =?UTF-8?q?=C3=A4t=20sm=20delete=20user=20when=20switch=20months?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/vorstand/ServiceManagement.vue | 2 +- .../ServiceManagementComponents/Day.vue | 128 ++++++++++++------ src/plugins/routes.js | 3 +- src/store/modules/serviceManagement.js | 70 ++++++++-- 4 files changed, 148 insertions(+), 55 deletions(-) diff --git a/src/components/vorstand/ServiceManagement.vue b/src/components/vorstand/ServiceManagement.vue index 276d364..80aa998 100644 --- a/src/components/vorstand/ServiceManagement.vue +++ b/src/components/vorstand/ServiceManagement.vue @@ -91,7 +91,7 @@ export default { }, computed: { ...mapGetters({ - month: 'sm/month' + month: 'sm/month', }) } } diff --git a/src/components/vorstand/ServiceManagementComponents/Day.vue b/src/components/vorstand/ServiceManagementComponents/Day.vue index 0b69f14..f931636 100644 --- a/src/components/vorstand/ServiceManagementComponents/Day.vue +++ b/src/components/vorstand/ServiceManagementComponents/Day.vue @@ -1,43 +1,57 @@ diff --git a/src/components/baruser/SearchBar.vue b/src/components/baruser/SearchBar.vue index 20bacee..b37ece2 100644 --- a/src/components/baruser/SearchBar.vue +++ b/src/components/baruser/SearchBar.vue @@ -16,10 +16,13 @@ :search-input.sync="filter" > Hinzufügen + + {{ menuIcon }} + @@ -27,7 +30,7 @@ diff --git a/src/store/modules/barUsers.js b/src/store/modules/barUsers.js index 7539831..0744c48 100644 --- a/src/store/modules/barUsers.js +++ b/src/store/modules/barUsers.js @@ -97,7 +97,9 @@ const mutations = { state.message.unshift({ message: message, error: data.error, + storno: false, visible: true, + amount: data.amount, date: new Date() }) console.log(state.message) From 20fb2f56dec2f42c421c4091b98a84ce59552b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Wed, 19 Feb 2020 23:22:23 +0100 Subject: [PATCH 033/117] storno at 5 min for the baruser in geruecht ##164 --- src/components/baruser/CreditLists.vue | 29 +++++++++++++------------- src/plugins/routes.js | 7 +++++-- src/store/modules/barUsers.js | 26 +++++++++++++++++++++++ 3 files changed, 45 insertions(+), 17 deletions(-) diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index cbad491..90b99ac 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -24,18 +24,19 @@
- -
- +
+ {{ now(message.date) }} {{ message.message }} + STORNIERT!!! Klicken um zu Stornieren - + >Klicken um zu Stornieren +
@@ -214,7 +215,8 @@ export default { ...mapActions({ addAmount: 'barUsers/addAmount', getUsers: 'barUsers/getUsers', - deactivate: 'barUsers/deactivateMenu' + deactivate: 'barUsers/deactivateMenu', + commitStorno: 'barUsers/storno' }), getColor(type) { return type === 'credit' ? 'title green--text' : 'title red--text' @@ -231,9 +233,10 @@ export default { }, storno(message) { if (!message.error) { - console.log(message) - message.storno = true if (!this.under5minutes(message.date)) this.dialog = true + else { + this.commitStorno({username: message.user.username, amount: message.amount, date: message.date}) + } } } }, @@ -267,7 +270,6 @@ export default { var actual = new Date() var zero = new Date(0) var date = new Date(actual - now) - console.log(date) if (date.getFullYear() === zero.getFullYear()) { if (date.getMonth() === zero.getMonth()) { if (date.getDate() === zero.getDate()) { @@ -301,13 +303,10 @@ export default { }, watch: { menu(newValue) { - console.log('menu', newValue) if (!newValue) this.deactivate() }, menu_from_store(newValue) { - console.log('for menu_from_store', newValue, this.menu) if (newValue) this.menu = this.menu_from_store - console.log('after menu_from_store', newValue, this.menu) } } } diff --git a/src/plugins/routes.js b/src/plugins/routes.js index f7f0e25..caabd83 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -1,7 +1,7 @@ //const main = 'https://192.168.5.128:5000/' -//const main = 'http://localhost:5000/' +const main = 'http://localhost:5000/' //const main = 'http://192.168.5.118:5000/' -const main = 'https://groeger-clan.duckdns.org:5000/' +//const main = 'https://groeger-clan.duckdns.org:5000/' const url = { login: main + 'login', @@ -30,6 +30,9 @@ const url = { user: { config: main + 'user/saveConfig', job: main + 'user/job' + }, + barU: { + storno: main + 'bar/storno' } } diff --git a/src/store/modules/barUsers.js b/src/store/modules/barUsers.js index 0744c48..ba72e29 100644 --- a/src/store/modules/barUsers.js +++ b/src/store/modules/barUsers.js @@ -96,6 +96,7 @@ const mutations = { } state.message.unshift({ message: message, + user: data.user, error: data.error, storno: false, visible: true, @@ -104,6 +105,12 @@ const mutations = { }) console.log(state.message) }, + updateMessage: (state, data) => { + var message = state.message.find(msg => {return msg.date - data.date === 0 ? true : false}) + if (message) { + message.storno = true + } + }, setMenu: (state, value) => { state.menu = value } @@ -179,6 +186,25 @@ const actions = { } commit('setAllUsersLoading', false) }, + async storno({ commit, rootState, dispatch }, data) { + commit('setUsersLoading', true) + try { + const response = await axios.post( + url.barU.storno, + { + userId: data.username, + amount: data.amount + }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('setUsers', { [response.data.username]: response.data }) + commit('updateMessage', { date: data.date }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + commit('setUsersLoading', false) + }, setFilter({ commit }, data) { commit('setFilter', data) }, From 6f4980dfb52ecaf1d8fb570fde6a228ae1d9fb03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sat, 22 Feb 2020 07:28:13 +0100 Subject: [PATCH 034/117] fixed ##180 --- src/components/baruser/CreditLists.vue | 4 ++-- src/store/modules/barUsers.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index 90b99ac..4e78e2a 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -305,8 +305,8 @@ export default { menu(newValue) { if (!newValue) this.deactivate() }, - menu_from_store(newValue) { - if (newValue) this.menu = this.menu_from_store + menu_from_store() { + this.menu = this.menu_from_store } } } diff --git a/src/store/modules/barUsers.js b/src/store/modules/barUsers.js index ba72e29..8fe6cfc 100644 --- a/src/store/modules/barUsers.js +++ b/src/store/modules/barUsers.js @@ -106,7 +106,9 @@ const mutations = { console.log(state.message) }, updateMessage: (state, data) => { - var message = state.message.find(msg => {return msg.date - data.date === 0 ? true : false}) + var message = state.message.find(msg => { + return msg.date - data.date === 0 ? true : false + }) if (message) { message.storno = true } From 3125e00a2aea94ce403a3af3d89db3376256e4d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sat, 22 Feb 2020 08:33:21 +0100 Subject: [PATCH 035/117] fixed ##181 --- src/components/baruser/CreditLists.vue | 50 +++++++++++++++++++++----- src/store/modules/barUsers.js | 10 +++--- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index 4e78e2a..dc98410 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -23,18 +23,27 @@ - + + + + Verlauf + + +
- + + {{ now(message.date) }} {{ message.message }} - STORNIERT!!! - STORNIERT!!! + Klicken um zu Stornieren @@ -204,12 +213,15 @@ export default { return { color: 'green accent-4', menu: true, - dialog: false + dialog: false, + componentRenderer: 0, + timer: '' } }, created() { this.menu = this.menu_from_store this.getUsers() + this.timer = setInterval(this.forceRender, 1000) }, methods: { ...mapActions({ @@ -218,6 +230,9 @@ export default { deactivate: 'barUsers/deactivateMenu', commitStorno: 'barUsers/storno' }), + forceRender() { + this.componentRenderer += 1 + }, getColor(type) { return type === 'credit' ? 'title green--text' : 'title red--text' }, @@ -232,10 +247,15 @@ export default { } }, storno(message) { + console.log('storno') if (!message.error) { if (!this.under5minutes(message.date)) this.dialog = true else { - this.commitStorno({username: message.user.username, amount: message.amount, date: message.date}) + this.commitStorno({ + username: message.user.username, + amount: message.amount, + date: message.date + }) } } } @@ -279,10 +299,22 @@ export default { } else if (date.getMinutes() < 10) { return 'vor ' + date.getMinutes() + ' Minuten' } else { - return now.getHours() + ':' + now.getMinutes() + return ( + (now.getHours() < 10 ? '0' : '') + + now.getHours() + + ':' + + (now.getMinutes() < 10 ? '0' : '') + + now.getMinutes() + ) } } else { - return now.getHours() + ':' + now.getMinutes() + return ( + (now.getHours() < 10 ? '0' : '') + + now.getHours() + + ':' + + (now.getMinutes() < 10 ? '0' : '') + + now.getMinutes() + ) } } } @@ -294,8 +326,10 @@ export default { '.' + now.getFullYear() + ' ' + + (now.getHours() < 10 ? '0' : '') + now.getHours() + ':' + + (now.getMinutes() < 10 ? '0' : '') + now.getMinutes() ) } diff --git a/src/store/modules/barUsers.js b/src/store/modules/barUsers.js index 8fe6cfc..fda23e7 100644 --- a/src/store/modules/barUsers.js +++ b/src/store/modules/barUsers.js @@ -99,6 +99,7 @@ const mutations = { user: data.user, error: data.error, storno: false, + loading: false, visible: true, amount: data.amount, date: new Date() @@ -110,7 +111,8 @@ const mutations = { return msg.date - data.date === 0 ? true : false }) if (message) { - message.storno = true + if (data.storno !== undefined) message.storno = data.storno + if (data.loading !== undefined) message.loading = data.loading } }, setMenu: (state, value) => { @@ -189,7 +191,7 @@ const actions = { commit('setAllUsersLoading', false) }, async storno({ commit, rootState, dispatch }, data) { - commit('setUsersLoading', true) + commit('updateMessage', { date: data.date, loading: true }) try { const response = await axios.post( url.barU.storno, @@ -200,12 +202,12 @@ const actions = { { headers: { Token: rootState.login.user.accessToken } } ) commit('setUsers', { [response.data.username]: response.data }) - commit('updateMessage', { date: data.date }) + commit('updateMessage', { date: data.date, storno: true }) } catch (e) { if (e.response) if (e.response.status === 401) dispatch('logout', null, { root: true }) } - commit('setUsersLoading', false) + commit('updateMessage', { date: data.date, loading: false }) }, setFilter({ commit }, data) { commit('setFilter', data) From ae89781da1a07af2c12d4fcfcf0dc49eb03bec6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sat, 22 Feb 2020 08:40:02 +0100 Subject: [PATCH 036/117] destroy Interval to render every Second the History --- src/components/baruser/CreditLists.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index dc98410..9f2e039 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -342,6 +342,9 @@ export default { menu_from_store() { this.menu = this.menu_from_store } + }, + beforeDestroy () { + clearInterval(this.timer) } } From 62af175884967200e6ea65363bcafe9e383bc761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sat, 22 Feb 2020 11:14:54 +0100 Subject: [PATCH 037/117] finished ##168 --- src/components/user/Jobs.vue | 78 +++--- src/components/user/Jobs/Day.vue | 141 +++++++---- src/components/vorstand/ServiceManagement.vue | 10 +- src/store/index.js | 4 +- src/store/modules/jobs.js | 230 ++++++++++++++++++ 5 files changed, 375 insertions(+), 88 deletions(-) create mode 100644 src/store/modules/jobs.js diff --git a/src/components/user/Jobs.vue b/src/components/user/Jobs.vue index 5733292..642b1d4 100644 --- a/src/components/user/Jobs.vue +++ b/src/components/user/Jobs.vue @@ -11,12 +11,8 @@ {{ date.getDate() }}.{{ date.getMonth() + 1 }}.{{ - date.getFullYear() - }} - bis {{ toDate.getDate() }}.{{ toDate.getMonth() + 1 }}.{{ - toDate.getFullYear() - }} + >{{ monthArray[date.getMonth()] }} + {{ date.getFullYear() }} @@ -25,10 +21,25 @@ - -
- -
+ + + Woche vom {{ week.startDate.getDate() }}.{{ + week.startDate.getMonth() + 1 + }}.{{ week.startDate.getFullYear() }} bis + {{ week.endDate.getDate() }}.{{ week.endDate.getMonth() + 1 }}.{{ + week.endDate.getFullYear() + }} + + + +
+ + + +
+
+
+
@@ -43,46 +54,43 @@ export default { return { keyboard_arrow_left: mdiChevronLeft, keyboard_arrow_right: mdiChevronRight, - date: new Date() + date: new Date(), + monthArray: [ + 'Januar', + 'Februar', + 'März', + 'April', + 'Mai', + 'Juni', + 'Juli', + 'August', + 'September', + 'Oktober', + 'November', + 'Dezember' + ] } }, created() { - this.createDays(this.date) + this.createMonth(this.date) }, methods: { ...mapActions({ - createDays: 'user/createDays' + createMonth: 'jobs/createMonth' }), changeMonth(value) { if (value === -1) { - this.date = new Date( - this.date.getFullYear(), - this.date.getMonth(), - this.date.getDate() - 1 - ) + this.date = new Date(this.date.getFullYear(), this.date.getMonth() - 1) } else { - this.date = new Date( - this.date.getFullYear(), - this.date.getMonth(), - this.date.getDate() + 1 - ) + this.date = new Date(this.date.getFullYear(), this.date.getMonth() + 1) } - this.createDays(this.date) - }, - test(day) { - let index = this.days.indexOf(day) - console.log(index, index % 3) - return true + this.createMonth(this.date) } }, computed: { ...mapGetters({ - days: 'user/days', - loading: 'user/loading' - }), - toDate() { - return new Date(new Date().setDate(this.date.getDate() + 10)) - } + month: 'jobs/month' + }) } } diff --git a/src/components/user/Jobs/Day.vue b/src/components/user/Jobs/Day.vue index 59ae525..a7c8138 100644 --- a/src/components/user/Jobs/Day.vue +++ b/src/components/user/Jobs/Day.vue @@ -1,28 +1,61 @@ + + diff --git a/src/components/user/Jobs.vue b/src/components/user/Jobs.vue index a50bef1..77e322d 100644 --- a/src/components/user/Jobs.vue +++ b/src/components/user/Jobs.vue @@ -73,10 +73,12 @@ export default { }, created() { this.createMonth(this.date) + this.getAllUsers() }, methods: { ...mapActions({ - createMonth: 'jobs/createMonth' + createMonth: 'jobs/createMonth', + getAllUsers: 'jobs/getAllUsers' }), changeMonth(value) { if (value === -1) { diff --git a/src/components/user/Jobs/Day.vue b/src/components/user/Jobs/Day.vue index f14941a..7c14f9c 100644 --- a/src/components/user/Jobs/Day.vue +++ b/src/components/user/Jobs/Day.vue @@ -17,7 +17,7 @@
+ + + + + + + + senden + +
@@ -45,7 +74,10 @@
Eintragen + >Eintragen +
@@ -71,7 +103,8 @@ export default { data() { return { account_add: mdiAccountPlus, - searchInput: null + searchInput: null, + requestUser: null } }, created() { @@ -83,18 +116,36 @@ export default { month: this.day.date.getMonth() + 1, day: this.day.date.getDate() }) + this.getTransactJobs({}) + this.getTransactJobs({ + year: this.day.date.getFullYear(), + month: this.day.date.getMonth() + 1, + day: this.day.date.getDate() + }) }, methods: { ...mapActions({ + getTransactJobs: 'requestJobs/getTransactJobs', getUser: 'jobs/getUser', setLoading: 'jobs/setDayLoading', setNotLoading: 'jobs/setDayNotLoading', addJob: 'jobs/addJob', - deleteJob: 'jobs/deleteJob' + deleteJob: 'jobs/deleteJob', + transactJob: 'jobs/transactJob' }), test(event) { console.log('blur', event) }, + send() { + this.transactJob({ + user: this.requestUser.username, + year: this.day.date.getFullYear(), + month: this.day.date.getMonth() + 1, + day: this.day.date.getDate() + }) + this.requestUser = null + this.searchInput = null + }, color: day => { if (day) { if (day.date.getDay() === 0 || day.date.getDay() === 1) { @@ -117,12 +168,38 @@ export default { computed: { ...mapGetters({ disabled: 'jobs/disabled', - activeUser: 'user' + activeUser: 'user', + allUsers: 'jobs/allUsers', + transactJobs: 'requestJobs/transactJobs' }), userInWorker() { return this.day.worker.find(a => { return a.username === this.activeUser.username }) + }, + specifiedUsers() { + var users = [...this.allUsers] + for (var i in this.day.worker) { + var worker = users.find(a => { + return a.username === this.day.worker[i].username + }) + var index = users.indexOf(worker) + if (worker) users.splice(index, 1) + } + return users + }, + canDelete() { + console.log(this.day.date) + console.log(this.transactJobs) + var transactJob = this.transactJobs.filter(a => { + return a.date - this.day.date === 0 + }) + console.log('filter', transactJob) + var test = transactJob.find(a => { + return a.accepted && a.answerd + }) + console.log('find', test) + return test } }, watch: { diff --git a/src/components/user/UserNavigation.vue b/src/components/user/UserNavigation.vue index ade5ca4..a9aa1b0 100644 --- a/src/components/user/UserNavigation.vue +++ b/src/components/user/UserNavigation.vue @@ -2,7 +2,7 @@ - {{account}} + {{ account }} Home @@ -10,21 +10,29 @@ - {{bank}} + {{ bank }} Finanzübersicht - {{briefcase}} + {{ briefcase }} Dienstübersicht + + + + {{ switchAccount }} + + + Dienstanfragen + - {{account_card_details}} + {{ account_card_details }} Einstellung @@ -32,15 +40,22 @@ diff --git a/src/plugins/routes.js b/src/plugins/routes.js index c8ea406..a9dd05f 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -37,7 +37,8 @@ const url = { answerTransactJob: main + 'user/answerTransactJob', jobRequests: main + 'user/jobRequests', getTransactJobs: main + 'user/getTransactJobs', - deleteTransactJobs: main + 'user/deleteTransactJob' + deleteTransactJobs: main + 'user/deleteTransactJob', + storno: main + 'user/storno' }, barU: { storno: main + 'bar/storno' diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 575501c..eb682d9 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -7,7 +7,8 @@ const state = { loading: false, addLoading: false, error: '', - days: [] + days: [], + message: [] } const mutations = { @@ -157,6 +158,48 @@ const mutations = { if (data.workers) state.days[day].workers = data.workers } } + }, + addMessage: (state, data) => { + var message = '' + if (data.error) { + message = + 'Konnte ' + + (data.amount / 100).toFixed(2) + + '€ zu ' + + data.user.firstname + + ' ' + + data.user.lastname + + ' hinzufügen.' + } else { + message = + '' + + (data.amount / 100).toFixed(2) + + '€ wurde zu ' + + data.user.firstname + + ' ' + + data.user.lastname + + ' hinzugefügt.' + } + state.message.unshift({ + message: message, + user: data.user, + error: data.error, + storno: false, + loading: false, + visible: true, + amount: data.amount, + date: new Date() + }) + console.log(state.message) + }, + updateMessage: (state, data) => { + var message = state.message.find(msg => { + return msg.date - data.date === 0 ? true : false + }) + if (message) { + if (data.storno !== undefined) message.storno = data.storno + if (data.loading !== undefined) message.loading = data.loading + } } } @@ -183,9 +226,20 @@ const actions = { { amount: amount }, { headers: { Token: rootState.login.user.accessToken } } ) + console.log(response.data) commit('setUser', response.data) + commit('addMessage', { + user: rootState.login.user, + amount: amount, + error: false + }) commit('setError', '') } catch (e) { + commit('addMessage', { + user: rootState.login.user, + amount: amount, + error: true + }) if (e.response) if (e.response.status === 401) dispatch('logout', null, { root: true }) } @@ -238,6 +292,25 @@ const actions = { console.log(e) } commit('setLoading', false) + }, + async storno({ commit, rootState, dispatch }, data) { + commit('updateMessage', { date: data.date, loading: true }) + try { + const response = await axios.post( + url.user.storno, + { + amount: data.amount + }, + { headers: { Token: rootState.login.user.accessToken } } + ) + console.log(response.data) + commit('setUser', response.data) + commit('updateMessage', { date: data.date, storno: true }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + commit('updateMessage', { date: data.date, loading: false }) } } @@ -264,6 +337,9 @@ const getters = { }, days: state => { return state.days + }, + messages: state => { + return state.message } } From 796e35946317fe9d898e80e3e11fab980d267771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Thu, 27 Feb 2020 15:59:10 +0100 Subject: [PATCH 044/117] better Button vor history in ##200 --- src/components/user/AddAmount.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/user/AddAmount.vue b/src/components/user/AddAmount.vue index d1c69e6..c150fac 100644 --- a/src/components/user/AddAmount.vue +++ b/src/components/user/AddAmount.vue @@ -52,7 +52,9 @@ {{ user.firstname }} {{ user.lastname }} - test + + {{ menuIcon }} + @@ -158,6 +160,7 @@ + + 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 046/117] 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 @@ - - - + + + 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 053/117] 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 054/117] 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 @@ + + From c0360bfff59b1894cdeec03d68e85c9832b5eb85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Wed, 4 Mar 2020 23:18:32 +0100 Subject: [PATCH 058/117] new logo --- src/assets/logo-64.png | Bin 0 -> 4487 bytes src/components/TitleBar.vue | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 src/assets/logo-64.png diff --git a/src/assets/logo-64.png b/src/assets/logo-64.png new file mode 100644 index 0000000000000000000000000000000000000000..50aacbbd31695baab87522527a681f9dcf52928d GIT binary patch literal 4487 zcmV;25qR#2P)EX>4Tx04R}tkv&MmKpe$i(~2S$2aAYw$WWauh>AFB6^c+H)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfa&%I3krMxx6k5c1aNLh~_a1le0HIM~niU!cG~G7S z$%L5At%}{R2qJ_*gb|gQWz0!Z3clm(9s$1I#d((hxj#prnztAb5Q%4*VcNtS#M7I$ z!FiuJ!b-AAd`>)O(glehxvqHp#<}RSz%wIeCOuCaAr^}rtaLCdnHupFaZJ^8$``U8 ztDLtuYn2*n-IKpCoYz;DxlS{RBo?s*2_h8KP(}qd;eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{01sbDL_t(|+SQwTxX)F-$6p^&?TsRvC}xvOp^2z8A~{iN zD&3{%)J##TiRo^-jUm&VCShudX-wB=%8+q}R75VPQIw|SDCAO2xkm2feg5$No@brk z^JBBm4zr$TKfmvHeb;w=*ZQo_<^6fDwS)asB>ez58CV4z1H2s(^Y-;PVjoWU2%tT% z3D^v*0qOxot}73;^7Vv>c1pl02%?+fEr$P0Xu-|Uisyo^vggo(A;%j03UdqRV>5>z_f_i zdO!(4(lfv`;J-Y9)Y5z-vH{oX4}1>+QflY#sog11oIr0j!9KS&~{>)w8h`1M7g#fPTP+h?p&@3D6e! zgQSZiV#)qc`^u7jC8?aG6_UR2@AHx#lhj7iHIicPkxL4{v@g1Zr(4Jbd#iWB(;$Ajq8t-)Id^o z-xo@{P0~Smmb@J7%-VG$3Zb*xyqa|JIRoLJG zJ}#-er23M2Sfw{uQzU7#O{kjhKbAB}(wUMjkyIz=+c#trw+5ah>6qksD@oUWuTel! z8$;Q%T{R3?@3=o0I1G3mSZZK%3eXKWJx_Pv0-b?>0$Cn#C(r=s1QY_#M?@b3m7kBpokljHLOJev`BrRl>wS z^h70TnWR;cb|lZ|+LSJl)X#NyN~$Gkd!GKLOFAphSUX!I%2WXNNqR+6T}e-R04pV3 z<>!5J2Dd!VfE(Ev{@U7fq%~ohpKp=$k_A;HsUUNZ{{CP|eRKN$B45<8@42$9CV!=* zCXyQX{*V6nW4^B|XM(WYf|(zd*$ zjyB2BWrYMA0hNGbC5-{j0WOP(zc_A>%<1zxr@$M1|D+M!0^kS0SH7=cC;5Be55QbI z+V;SxobgToe(2|gIpZsmR2UH(O|mq0ialUg6Dqft0{9G=bVQ`w`F9x0l zdK&T;I#OiqHUmEb?g4%QboBk<_Ur=s054lhA|h5q#57>KBS==>_BYl8V-u*|5m*ut z!^%nn)&cc_yPe*)h=>uA&IS4>?d}F%alYRPIK&CgGk!kLOwh+bO$((laJ}>YH9$LH zp;z!Y3vh#^gMjzlt|l-tBDzazY)z^nsa`~UCh4cZPs=hHYH10#Fxl~hr1QPfY55cw zYVF7-+8uZZs12Oyc0+*~?sus*>m1{N**1&ez(>Hzl8$!LH8vqq)=O#!H1n!gGr97a zwWyM$pG3qT%fbW-fNMRtjKr*v*!88rL{H=+6D02dr`kUZaHf})wGr`>HR4&1Nd6W4fkTLXUqHrPM(1jb7mXupy%Ml$ua&}MKsaHGF{F3{BicqdP~{cS{avF}&} zL`1wTO`ev)GK*^cpk>6Uh=$G znGhn9I(U^2c1RoN)j!Q%ynI4*)N`8+c7nO(EJ+=0`yKNFN_;EpQ?5 zo(H%R_&2A)Px!r05+~RKc+7$y1q=edOw!+;z+%&9J)A;k`MzG|c>Io|!6HM``Zk%>u4`uXKv=t+$> zYuqd%9`GU^>F=yIcsj&L@(KH~igF{_LZWK!DnS`F_B~6et$0_b)*U$F5-F-i+gzvrQb{VfY#Ptg#ePSN+Q%S$h zd9T1@s_ilEko1TtyEi4(D6JEG)V4@OtTGy#Z)lq`Ep4o#S)^F)`WBKJS`C)~AC@5V zdHz=21ngjk*f7aMM*bg8FJhB5wY#-5?4K4`!>0A0=LA*q_3)&{F$d$(B#+;1mV z6}Tx!I2|J5E8ul+itMh;N+$K^h`2s^_KF3)7+5K(N&>`&*<_3Dh)F{6m&x^B3*aBX z1-|ZP$uF#cZ#+!PVdI$9I}cNqjN^?O+;9AvznA<8lSYoC*9Pv6B@Rsfd(^$c*f zN}A|R)QdbOtZCSn06d&%(q8+3=0j~&ws zlGaITmhgG!m4N%VnOjJC{;&P4b5j4Lq_vW^CQkQBNh2in&zVQdjKbS16NrcpfXWfE z%;DvKv3f*|lytJBTMSXNQWxkP5t~d}R0cYjE*otVDJd*x{9-L*{~GoW6BFM58)t_V zT))~TS~U;-^{FYey+(pXj^nWN>`qoDNjlF=%aELH>q4NNSE04*H`;d$at={aX_!Qp z&Awg~5gUAcM2;Z4B}~(F3qQBN;?g+5&IwQ&n*(h}7}#Xx1EaRg0ljVl6iz>~O z0letn%MxcgHqp!>z?BIg+Uo4F3a~KG-e9*RH1CxFCIW4(35}BaKE?u-jOphCwAH$JZK@{1Tx*Q+8)K2h*%qFp`p!5vl*R`v0k->e z*0SVLimaZqZBGHtNNf%Z2n%bi?>}%Zk*_RqIICywVN@d2X^Clu3D%5PYzrI{5wk6n zu+M4lHmeMxN)-uS^zZCE9(#kND-1)6lKNVPtxXI|=lXeHNxdX}o@aY&t)y-~WAKJU zU!fuJ)MR`8sAK~sE8k>?C6aMhkTlP5c(kORrI~z9N!R&0-@&I*N!u(Y&-4A?yff2V z(m2<>;k+Tk6zh||UUn?M)O&&#dlHh=){}o-QbqTb?HA7XZ$WmTBH0dGA*rFi+p;u1 zpl71)`Hrwo&kima0t3A2vx4`St(^v(A?ZS3k{xGbw;k;8*3((#;ij}Y0An0^UNVO; z!RDCR^7zF0jsu!R#EK+E{@kW_Jn+8FW3L79tIVO0|BT;4ppCU8JIF8%ZZcUI#cRB6irP46qk(Tv)U#@CfMH`CF%Im z2%xnmi3gpV&faeJXJAq{Il(IiinL7F~FN0tsL@tTf<(+*)q#Ax-J&L958El_Fs|!=2-f83oIi$-|~RcGA$yO`AB?*BenqdnF1dUjFR-Uqc;~e9Hy(ue9aTQ5gDyfzGy2z>Xqduy0cJiI96#F>d9oc)O-WM>^dpKciPOv6? z?79(Ve$TLzJJ+~BEftLH_NHVQV;FEpM9fTfr*YKyU7k~5qm5t>@wtGRWuXNR=G<2| zqMIV=a^L^Z&qifvEeDhwB57>SLCSn(xlfvPmGoChPv`XYR0_b7`m+qaTKn%UN!RSj z{Ptvbc%9X%(6+t8$;s8gR-fAV(9bT3h%a;AU*%oii@b6hck``j)~4;=@4v+p%zVaT zQ{d_3i=ArEHFeet7#I#MdmTyB;$jD1zSf?XxGF6H}eOk(zt^rfVO z?Ig3(S5m*E{bjj=cA7mPS(G08QUJweaU9)D?b%tL?h~SmB-Ku^Lt*mGR>`}M=bj7x zmn{y9r%5{2n$S{G6>|m`*#FG+>C%CcYGh_uRweec0E&UrBjP#Vw=mz=!`pIiIgD2H z)?6iEV?>N8t1*<@p8_yyt1anPPyPgUo*$?W6h_3#h)_hVkBG6}ubfeqV<>k3Si)$- z>sn5F*0A%OVAVWrug#dBvMS~G_v|BLzND?*2Y5FkhVG_qng9QAc@B&+nVm;nM(pbk Z{}0oa0s6C6Ip_cY002ovPDHLkV1mXBqWAy+ literal 0 HcmV?d00001 diff --git a/src/components/TitleBar.vue b/src/components/TitleBar.vue index 9757a3e..eb00664 100644 --- a/src/components/TitleBar.vue +++ b/src/components/TitleBar.vue @@ -1,7 +1,7 @@ + + diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index a3098ad..9a9e4d5 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -262,7 +262,6 @@ export default { }, 300) }, storno(message) { - console.log('storno') if (!message.error) { if (!this.under5minutes(message.date)) this.dialog = true else { diff --git a/src/components/finanzer/User.vue b/src/components/finanzer/User.vue index 7f09a1d..be477d0 100644 --- a/src/components/finanzer/User.vue +++ b/src/components/finanzer/User.vue @@ -347,8 +347,6 @@ export default { }, watch: { activeUser(newVal) { - // eslint-disable-next-line no-console - console.log(newVal) this.limit = (newVal.limit / 100).toFixed(2) this.autoLock = { value: newVal.autoLock, @@ -356,8 +354,6 @@ export default { } }, id(newVal) { - // eslint-disable-next-line no-console - console.log(newVal) this.setActiveUser(newVal) } } diff --git a/src/components/pricelist/PriceList.vue b/src/components/pricelist/PriceList.vue index 7a0b2f2..62c361d 100644 --- a/src/components/pricelist/PriceList.vue +++ b/src/components/pricelist/PriceList.vue @@ -347,7 +347,6 @@ export default { deleteDrinkType: 'priceList/deleteDrinkType' }), editType(item) { - console.log(item) this.editedType = Object.assign({}, item) this.dialogType = true }, @@ -379,7 +378,6 @@ export default { }, editItem(item) { this.editedIndex = item.id - console.log('item', item) this.editedItem = Object.assign({}, item) for (let i in this.editedItem) { this.editedItem[i] = isNaN(this.editedItem[i]) @@ -388,7 +386,6 @@ export default { ? null : (this.editedItem[i] / 100).toFixed(2) } - console.log(this.editedItem) this.editedItem.type = Object.assign( {}, this.types.find(a => a.id == item.type) @@ -401,9 +398,6 @@ export default { this.deleteDrink({ id: item.id }) }, save() { - console.log(this.editedItem) - console.log(this.editedIndex) - console.log(!isNaN(this.editedItem.price_extern_club)) var drink = { id: this.editedIndex, name: this.editedItem.name, @@ -430,7 +424,6 @@ export default { ? this.editedItem.price_extern_club * 100 : null } - console.log(drink) drink.id === -1 ? this.setDrink(drink) : this.updateDrink(drink) this.editedItem = Object.assign({}, this.defaultItem) this.close() diff --git a/src/components/user/AddAmount.vue b/src/components/user/AddAmount.vue index 8fefcac..84fc5ad 100644 --- a/src/components/user/AddAmount.vue +++ b/src/components/user/AddAmount.vue @@ -198,7 +198,6 @@ export default { return value >= 0 ? 'title green--text' : 'title red--text' }, getAllSum() { - console.log('getAllSum', this.user) if (this.user) return ( this.user.creditList[this.year][2].sum + @@ -207,7 +206,6 @@ export default { return 0 }, storno(message) { - console.log('storno') if (!message.error) { if (!this.under5minutes(message.date)) this.dialog = true else { diff --git a/src/components/user/Jobs/Day.vue b/src/components/user/Jobs/Day.vue index f322de8..7c47de5 100644 --- a/src/components/user/Jobs/Day.vue +++ b/src/components/user/Jobs/Day.vue @@ -31,7 +31,7 @@ -
+
{{ lockedText }} - {{lockedTextBtn}} + {{lockedTextBtn}}
@@ -113,9 +113,6 @@ export default { day: this.day.date.getDate() }) }, - test(event) { - console.log('blur', event) - }, color: day => { if (day) { if (day.date.getDay() === 0 || day.date.getDay() === 1) { @@ -173,7 +170,6 @@ export default { for (let user in oldValue) { if (!newValue.includes(oldValue[user])) { deletedUser = oldValue[user] - console.log('deleteUser', deletedUser, this.day.date) this.deleteUser({ startdatetime: this.day.date, date: this.day.date.getTime() / 1000, @@ -194,9 +190,6 @@ export default { month: this.day.date.getMonth() + 1, day: this.day.date.getDate() }) - }, - focused(newVal, oldValue) { - console.log(newVal, oldValue) } } } diff --git a/src/components/vorstand/UserManager.vue b/src/components/vorstand/UserManager.vue index 61652df..72f9491 100644 --- a/src/components/vorstand/UserManager.vue +++ b/src/components/vorstand/UserManager.vue @@ -174,9 +174,7 @@ export default { }, 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) @@ -184,7 +182,6 @@ export default { 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) { diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 06f86a8..a6d0023 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -1,7 +1,7 @@ //const main = 'https://192.168.5.128:5000/' -const main = 'http://localhost:5000/' +//const main = 'http://localhost:5000/' //const main = 'http://192.168.5.118:5000/' -//const main = 'https://groeger-clan.duckdns.org:5000/' +const main = 'https://groeger-clan.duckdns.org:5000/' const url = { login: main + 'login', diff --git a/src/router/index.js b/src/router/index.js index b47ef28..fccf75b 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -19,18 +19,17 @@ 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 ManagementNavigation from "@/components/vorstand/ManagementNavigation"; -import GastroNavigation from "@/components/gastro/GastroNavigation"; -import PriceListView from "@/views/contents/PriceListView"; -import UserManager from "@/components/vorstand/UserManager"; +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) const routes = [ { path: '/cookies', - name: 'cookies', - + name: 'cookies' }, { path: '/pricelist', @@ -50,7 +49,7 @@ const routes = [ { path: 'management', name: 'management', - components: { nav: ManagementNavigation, default: BarView}, + components: { nav: ManagementNavigation, default: BarView }, children: [ { path: 'servicemanagement', @@ -126,7 +125,7 @@ const routes = [ { path: 'gastro', name: 'gastro', - components: { nav: GastroNavigation, default: BarView}, + components: { nav: GastroNavigation, default: BarView }, children: [ { path: 'pricelist', diff --git a/src/store/modules/barUsers.js b/src/store/modules/barUsers.js index b48afef..d2bca91 100644 --- a/src/store/modules/barUsers.js +++ b/src/store/modules/barUsers.js @@ -104,7 +104,6 @@ const mutations = { amount: data.amount, date: new Date() }) - console.log(state.message) }, updateMessage: (state, data) => { var message = state.message.find(msg => { @@ -137,9 +136,9 @@ const actions = { }, async addAmount({ commit, rootState, dispatch }, data) { try { - commit('updateUser', {username: data.username, loading: true}) + commit('updateUser', { username: data.username, loading: true }) } catch (e) { - console.log(e) + //error } try { const response = await axios.post( @@ -163,16 +162,16 @@ const actions = { if (e.response.status === 401) dispatch('logout', null, { root: true }) } try { - commit('updateUser', {username: data.username, loading: false}) + commit('updateUser', { username: data.username, loading: false }) } catch (e) { - console.log(e) + //error } }, async addCreditList({ commit, rootState, dispatch }, data) { try { - commit('updateUser', {username: data.username, loading: true}) + commit('updateUser', { username: data.username, loading: true }) } catch (e) { - console.log(e) + //error } try { const response = await axios.post( @@ -186,18 +185,17 @@ const actions = { if (e.response.status === 401) dispatch('logout', null, { root: true }) } try { - commit('updateUser', {username: data.username, loading: false}) - } catch (e) { - console.log(e) + commit('updateUser', { username: data.username, loading: false }) + } catch { + //error } }, async getAllUsers({ commit, rootState, dispatch }) { commit('setAllUsersLoading', true) try { - const response = await axios.get( - url.searchUser, - { headers: { Token: rootState.login.user.accessToken } } - ) + const response = await axios.get(url.searchUser, { + headers: { Token: rootState.login.user.accessToken } + }) commit('setAllUsers', response.data) } catch (e) { if (e.response) diff --git a/src/store/modules/finanzerUsers.js b/src/store/modules/finanzerUsers.js index 6a92bc9..66b31e5 100644 --- a/src/store/modules/finanzerUsers.js +++ b/src/store/modules/finanzerUsers.js @@ -243,13 +243,11 @@ const actions = { async getAllUsers({ commit, rootState, dispatch }) { commit('setAllUsersLoading', true) try { - const response = await axios.get( - url.searchUser, - { headers: { Token: rootState.login.user.accessToken } } - ) + const response = await axios.get(url.searchUser, { + headers: { Token: rootState.login.user.accessToken } + }) commit('setAllUsers', response.data) } catch (err) { - // eslint-disable-next-line no-console if (err.response) if (err.response.status === 401) dispatch('logout', null, { root: true }) diff --git a/src/store/modules/jobRequests.js b/src/store/modules/jobRequests.js index 02747ac..45267f7 100644 --- a/src/store/modules/jobRequests.js +++ b/src/store/modules/jobRequests.js @@ -65,14 +65,10 @@ const mutations = { deleteTransactJobactJob: (state, data) => { const date = new Date(data.year, data.month - 1, data.day) var job = state.transactJobs.find(a => { - console.log(a) - console.log(a.date, date) return a.date - date === 0 && a.to_user.username === data.username }) - console.log(job) var index = state.transactJobs.indexOf(job) - if (job) - state.transactJobs.splice(index, 1) + if (job) state.transactJobs.splice(index, 1) } } diff --git a/src/store/modules/jobs.js b/src/store/modules/jobs.js index 99a8cfc..15d6a32 100644 --- a/src/store/modules/jobs.js +++ b/src/store/modules/jobs.js @@ -204,10 +204,9 @@ const mutations = { const actions = { async getAllUsers({ commit, rootState, dispatch }) { try { - const response = await axios.get( - url.searchUser, - { headers: { Token: rootState.login.user.accessToken } } - ) + const response = await axios.get(url.searchUser, { + headers: { Token: rootState.login.user.accessToken } + }) commit('setAllUsers', { users: response.data, username: rootState.login.user.username @@ -271,7 +270,7 @@ const actions = { // eslint-disable-next-line no-unused-vars async deleteJob({ commit, rootState, dispatch }, data) { try { - const response = await axios.post( + await axios.post( url.user.deleteJob, { ...data }, { headers: { Token: rootState.login.user.accessToken } } @@ -281,7 +280,6 @@ const actions = { user: rootState.login.user, com: 'delete' }) - console.log(response) } catch (e) { if (e.response) if (e.response.status === 401) dispatch('logout', null, { root: true }) diff --git a/src/store/modules/login.js b/src/store/modules/login.js index a05bcd1..dbecdb1 100644 --- a/src/store/modules/login.js +++ b/src/store/modules/login.js @@ -11,7 +11,9 @@ const state = { group: null }, loggingIn: false, - loginError: null + loginError: null, + cookieNotification: true, + cookieAccepted: false } const mutations = { @@ -42,6 +44,12 @@ const mutations = { state.user.group = null state.user.firstname = null state.user.lastname = null + }, + setCookieNotification(state, value) { + state.cookieNotification = value + }, + setCookieAccepted(state, value) { + state.cookieAccepted = value } } @@ -53,6 +61,8 @@ const actions = { const cookieA = localStorage.getItem('cookie:accepted') if (!cookieA) { commit('loginStop', 'Sie müssen die Cookies akzeptieren!') + commit('setCookieNotification', true) + commit('setCookieAccepted', false) return } localStorage.setItem( @@ -93,12 +103,25 @@ const actions = { logout({ commit }) { localStorage.removeItem('user') localStorage.removeItem('cookie:accepted') - localStorage.removeItem('cookie:all') + commit('setCookieNotification', true) + commit('setCookieAccepted', false) commit('logout') router.push('/login') }, resetLoginError({ commit }) { commit('loginStop') + }, + acceptNotification({ commit }) { + localStorage.setItem('cookie:accepted', true) + commit('setCookieAccepted', true) + commit('setCookieNotification', false) + }, + disableNotification({ commit }) { + commit('setCookieNotification', false) + }, + getCookieAccepted({ commit }) { + var cookie = localStorage.getItem('cookie:accepted') + commit('setCookieAccepted', cookie) } } @@ -158,7 +181,11 @@ const getters = { }, isManagement: state => { try { - return state.user.group.includes('vorstand') || state.user.group.includes('gastro') || state.user.group.includes('moneymaster') + return ( + state.user.group.includes('vorstand') || + state.user.group.includes('gastro') || + state.user.group.includes('moneymaster') + ) } catch (e) { return false } @@ -168,6 +195,12 @@ const getters = { }, user: state => { return state.user + }, + cookieNotification: state => { + return state.cookieNotification + }, + cookieAccepted: state => { + return state.cookieAccepted } } diff --git a/src/store/modules/serviceManagement.js b/src/store/modules/serviceManagement.js index c78d7e9..51ad6db 100644 --- a/src/store/modules/serviceManagement.js +++ b/src/store/modules/serviceManagement.js @@ -200,10 +200,9 @@ const actions = { }, async getAllUsers({ commit, rootState, dispatch }) { try { - const response = await axios.get( - url.vorstand.sm.searchUser, - { headers: { Token: rootState.login.user.accessToken } } - ) + const response = await axios.get(url.vorstand.sm.searchUser, { + headers: { Token: rootState.login.user.accessToken } + }) commit('setAllUsers', response.data) } catch (e) { if (e.response) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 4d1e4d2..fdb3c9f 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -20,8 +20,6 @@ const mutations = { state.user = user let list = {} for (let creditList in user['creditList']) { - // eslint-disable-next-line no-console - console.log(creditList) let amount = mutations.createAmount(user['creditList'][creditList]) let credit = mutations.createCredit(user['creditList'][creditList]) let sum = mutations.createSum(credit, amount) @@ -30,8 +28,6 @@ const mutations = { state.user.creditList = list state.creditList = [] state.error = '' - // eslint-disable-next-line no-console - console.log(state.user) }, createAmount(creditList) { let amount = { @@ -136,7 +132,6 @@ const mutations = { }, setError(state, value) { state.error = value - console.log(state) }, createDays(state, date) { let days = [] @@ -194,7 +189,6 @@ const mutations = { amount: data.amount, date: new Date() }) - console.log(state.message) }, updateMessage: (state, data) => { var message = state.message.find(msg => { @@ -230,7 +224,6 @@ const actions = { { amount: amount }, { headers: { Token: rootState.login.user.accessToken } } ) - console.log(response.data) commit('setUser', response.data) commit('addMessage', { user: rootState.login.user, @@ -257,14 +250,12 @@ const actions = { { ...data }, { headers: { Token: rootState.login.user.accessToken } } ) - console.log(response.data) commit('setUser', response.data) commit('setError', '') } catch (e) { if (e.response) { if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.data) { - console.log(e.response.data) commit('setError', e.response.data.error) } } @@ -277,23 +268,19 @@ const actions = { async updateDay({ commit, rootState, dispatch }, data) { commit('setLoading', true) try { - console.log('hier bin ich') const response = await axios.post( url.user.job, { date: data.date.getTime() / 1000 }, { headers: { Token: rootState.login.user.accessToken } } ) - console.log(response.data) commit('updateDay', { ...response.data, date: data.date }) } catch (e) { if (e.response) { if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.data) { - console.log(e.response.data, data.date) commit('setError', e.response.data.error) } } - console.log(e) } commit('setLoading', false) }, @@ -307,7 +294,6 @@ const actions = { }, { headers: { Token: rootState.login.user.accessToken } } ) - console.log(response.data) commit('setUser', response.data) commit('updateMessage', { date: data.date, storno: true }) } catch (e) { @@ -316,7 +302,7 @@ const actions = { } commit('updateMessage', { date: data.date, loading: false }) }, - async getStatus({commit, rootState, dispatch }) { + async getStatus({ commit, rootState, dispatch }) { try { const response = await axios.get(url.user.getAllStatus, { headers: { Token: rootState.login.user.accessToken } diff --git a/src/store/modules/userManager.js b/src/store/modules/userManager.js index 6034485..6284a40 100644 --- a/src/store/modules/userManager.js +++ b/src/store/modules/userManager.js @@ -5,7 +5,7 @@ const state = { users: [], status: [], usersLoading: false, - statusLoading: false, + statusLoading: false } const mutations = { @@ -14,7 +14,6 @@ const mutations = { }, setStatus: (state, status) => { state.status = status - }, updateUser: (state, user) => { let exists = state.users.find(a => { diff --git a/src/views/contents/Cookies.vue b/src/views/contents/Cookies.vue deleted file mode 100644 index 965a56e..0000000 --- a/src/views/contents/Cookies.vue +++ /dev/null @@ -1,22 +0,0 @@ - - - - - From 00bffe665dba3a35b004075f8c7d50eab5d8341b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Thu, 5 Mar 2020 21:31:52 +0100 Subject: [PATCH 061/117] fixed bug that password is cleared, whenn saving. --- src/components/user/Config.vue | 6 +++++- src/plugins/routes.js | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/user/Config.vue b/src/components/user/Config.vue index 022b7d9..eb34dfe 100644 --- a/src/components/user/Config.vue +++ b/src/components/user/Config.vue @@ -56,6 +56,7 @@ - Save + Save {{ error }} @@ -170,6 +171,7 @@ export default { firstname: null, lastname: null, password: null, + controlPassword: null, equal_password: value => this.password === value || 'Passwörter sind nicht identisch.', email: value => { @@ -198,6 +200,8 @@ export default { if (this.password) user.password = this.password } this.saveConfig({ oldUsername: user.username, ...user }) + this.password = null + this.controlPassword = null } }, computed: { diff --git a/src/plugins/routes.js b/src/plugins/routes.js index a6d0023..06f86a8 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -1,7 +1,7 @@ //const main = 'https://192.168.5.128:5000/' -//const main = 'http://localhost:5000/' +const main = 'http://localhost:5000/' //const main = 'http://192.168.5.118:5000/' -const main = 'https://groeger-clan.duckdns.org:5000/' +//const main = 'https://groeger-clan.duckdns.org:5000/' const url = { login: main + 'login', From 53676763ea70953c665417530d38a3573d3d516b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sat, 7 Mar 2020 15:00:52 +0100 Subject: [PATCH 062/117] finished ##217 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixed bug that when you search in barCreditList or finanzerOverview, with 2 strings e.g. full name fixed bug when you click on a name in searchbar in finanzerOverview, that you get the profile of the user you dont need to click button "hinzufügen" --- src/App.vue | 147 +++++++++++++++++- src/components/TitleBar.vue | 2 +- src/components/baruser/CreditLists.vue | 39 +++-- src/components/finanzer/Overview.vue | 20 +-- src/components/vorstand/ServiceManagement.vue | 18 ++- src/plugins/routes.js | 3 + src/store/modules/barUsers.js | 5 + src/store/modules/finanzerUsers.js | 9 ++ src/store/modules/jobRequests.js | 4 + src/store/modules/jobs.js | 5 + src/store/modules/login.js | 45 +++++- src/store/modules/pricelist.js | 12 +- src/store/modules/serviceManagement.js | 5 + src/store/modules/user.js | 6 + src/store/modules/userManager.js | 4 + 15 files changed, 289 insertions(+), 35 deletions(-) diff --git a/src/App.vue b/src/App.vue index 8db0818..417b731 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,9 +3,35 @@ - © {{ new Date().getFullYear() }} Studentenclub Wu 5 e.v. + +
+ + {{ calcTime }} + +
+ + + + Zeit bis zum Logout ändern + + + + + + + Abbrechen + Speichern + + +
@@ -13,12 +39,123 @@ diff --git a/src/components/TitleBar.vue b/src/components/TitleBar.vue index eb00664..d480505 100644 --- a/src/components/TitleBar.vue +++ b/src/components/TitleBar.vue @@ -1,6 +1,6 @@ Hinzufügen + Sperren + Entsperren {{ menuIcon }} + + + + Entsperre Baransicht + + + + + + Abbrechen + Entsperren + + + +
@@ -40,11 +57,14 @@ export default { user: null, filter: '', search_person: mdiAccountSearch, - menuIcon: mdiMenu + menuIcon: mdiMenu, + overlay: false, + password: '' } }, created() { this.getAllUsers() + this.getLocked() }, methods: { ...mapActions({ @@ -52,7 +72,10 @@ export default { addCreditList: 'barUsers/addCreditList', setFilter: 'barUsers/setFilter', activateMenu: 'barUsers/activateMenu', - deactivateMenu: 'barUsers/deactivateMenu' + deactivateMenu: 'barUsers/deactivateMenu', + lock: 'barUsers/setLocked', + unlock: 'barUsers/unlock', + getLocked: 'barUsers/getLocked' }), addUser() { this.addCreditList(this.user) @@ -61,13 +84,19 @@ export default { clickMenu() { if (this.menu) this.deactivateMenu() else this.activateMenu() + }, + doUnlock() { + this.unlock(this.password) + this.password = '' + this.overlay = false } }, computed: { ...mapGetters({ allUsers: 'barUsers/allUsers', loading: 'barUsers/allUsersLoading', - menu: 'barUsers/menu' + menu: 'barUsers/menu', + locked: 'barUsers/locked' }) }, watch: { diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 547b80f..fed4a7a 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -54,10 +54,12 @@ const url = { deleteTransactJobs: main + 'user/deleteTransactJob', storno: main + 'user/storno', getAllStatus: main + 'getAllStatus', - getStatus: main + 'getStatus' + getStatus: main + 'getStatus', + valid: main + 'valid' }, barU: { - storno: main + 'bar/storno' + storno: main + 'bar/storno', + lock: main + 'bar/lock' }, gastro: { setDrink: main + 'gastro/setDrink', diff --git a/src/store/modules/barUsers.js b/src/store/modules/barUsers.js index cacf3ed..7717847 100644 --- a/src/store/modules/barUsers.js +++ b/src/store/modules/barUsers.js @@ -8,7 +8,8 @@ const state = { usersLoading: false, allUsersLoading: false, message: [], - menu: false + menu: false, + locked: false } const mutations = { @@ -116,6 +117,9 @@ const mutations = { }, setMenu: (state, value) => { state.menu = value + }, + setLocked: (satet, value) => { + state.locked = value } } @@ -227,6 +231,51 @@ const actions = { } commit('updateMessage', { date: data.date, loading: false }) }, + async getLocked({ commit, rootState, dispatch }) { + try { + const response = await axios.get(url.barU.lock, { + headers: { Token: rootState.login.user.accessToken } + }) + console.log(response.data.value) + commit('setLocked', response.data.value) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async setLocked({ commit, rootState, dispatch }) { + try { + const response = await axios.post( + url.barU.lock, + { value: true }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('setLocked', response.data.value) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async unlock({ commit, rootState, dispatch }, password) { + try { + const valid = await axios.post( + url.user.valid, + { password: password }, + { headers: { Token: rootState.login.user.accessToken } } + ) + if (valid.data.ok === 'ok') { + const response = await axios.post( + url.barU.lock, + { value: false }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('setLocked', response.data.value) + } + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, setFilter({ commit }, data) { commit('setFilter', data) }, @@ -259,6 +308,9 @@ const getters = { }, menu: state => { return state.menu + }, + locked: state => { + return state.locked } } diff --git a/src/views/MainView.vue b/src/views/MainView.vue index 5540f2a..aeb4aae 100644 --- a/src/views/MainView.vue +++ b/src/views/MainView.vue @@ -18,7 +18,7 @@ {{user.firstname}} {{user.lastname}} - + {{person}} @@ -32,7 +32,7 @@ Bar - + {{king}} @@ -40,7 +40,7 @@ Vorstand - + {{gastro}} @@ -48,7 +48,7 @@ Gastro - + {{attach_money}} @@ -107,7 +107,8 @@ export default { isManagement: 'isManagement', isLoggedIn: 'isLoggedIn', isExtern: 'isExtern', - user: 'user' + user: 'user', + lockedBar: 'barUsers/locked' }) } } From bf71bcb1ed40ba394ed82fbd67a13685a1bea92a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Fri, 15 May 2020 13:00:02 +0200 Subject: [PATCH 067/117] fix routes --- src/plugins/routes.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/routes.js b/src/plugins/routes.js index ce35c0e..2ccbc5d 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -1,7 +1,7 @@ //const main = 'https://192.168.5.128:5000/' -const main = 'http://localhost:5000/' +//const main = 'http://localhost:5000/' //const main = 'http://192.168.5.118:5000/' -//const main = 'https://groeger-clan.duckdns.org:5000/' +const main = 'https://groeger-clan.duckdns.org:5000/' const url = { login: main + 'login', @@ -10,7 +10,7 @@ const url = { pricelist: main + 'pricelist', getTypes: main + 'drinkTypes', getFinanzerMain: main + 'getFinanzerMain', - bar: main + 'bar', + bar: main + 'bar' barGetUser: main + 'barGetUser', barAddAmount: main + 'baradd', finanzerAddAmount: main + 'finanzerAddAmount', From 671b9335c9445f8050bdbc0dd91570719b83aece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sat, 16 May 2020 23:24:14 +0200 Subject: [PATCH 068/117] finished ##255 --- src/components/pricelist/PriceList.vue | 11 +- .../vorstand/ManagementNavigation.vue | 13 +- .../vorstand/WorkgroupManagement.vue | 190 ++++++++++++++++++ src/plugins/routes.js | 12 +- src/router/index.js | 5 + src/store/index.js | 4 +- src/store/modules/workgroupManagement.js | 120 +++++++++++ 7 files changed, 346 insertions(+), 9 deletions(-) create mode 100644 src/components/vorstand/WorkgroupManagement.vue create mode 100644 src/store/modules/workgroupManagement.js diff --git a/src/components/pricelist/PriceList.vue b/src/components/pricelist/PriceList.vue index 62c361d..299ce75 100644 --- a/src/components/pricelist/PriceList.vue +++ b/src/components/pricelist/PriceList.vue @@ -1,6 +1,11 @@ + @@ -132,6 +153,7 @@ export default { header: [ { text: 'Nachname', value: 'lastname' }, { text: 'Vorname(n)', value: 'firstname' }, + { text: 'AG\'s', value: 'workgroups'}, { text: 'Status', value: 'statusgroup' }, { text: 'Stimmrecht', value: 'voting' }, { @@ -146,6 +168,7 @@ export default { firstname: null, lastname: null, username: null, + workgroups: [], statusgroup: { id: -1, name: null @@ -158,6 +181,7 @@ export default { defaultItem: { id: -1, username: null, + workgroups: [], statusgroup: { id: -1, name: null @@ -183,7 +207,9 @@ export default { getUsers: 'usermanager/getUsers', getStatus: 'usermanager/getStatus', updateStatusUser: 'usermanager/updateStatusUser', - updateVoting: 'usermanager/updateVoting' + updateVoting: 'usermanager/updateVoting', + updateWorkgroups: 'usermanager/updateWorkgroups', + getAllWorkgroups: 'wm/getAllWorkgroups' }), getWindowWidth() { this.isFulllineText = document.documentElement.clientWidth <= 750; @@ -231,6 +257,7 @@ export default { save() { this.updateStatusUser({username: this.editedItem.username, status: this.editedItem.statusgroup}) this.updateVoting({username: this.editedItem.username, voting: this.editedItem.voting.value}) + this.updateWorkgroups(this.editedItem) this.close() } }, @@ -239,7 +266,8 @@ export default { users: 'usermanager/users', status: 'usermanager/status', usersLoading: 'usermanager/usersLoading', - statusLoading: 'usermanager/statusLoading' + statusLoading: 'usermanager/statusLoading', + workgroups: 'wm/workgroups' }), computeStatus() { return id => { @@ -263,6 +291,7 @@ export default { created() { this.getUsers() this.getStatus() + this.getAllWorkgroups() } } diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 4c3994e..118a35e 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -40,7 +40,8 @@ const url = { updateStatus: main + 'um/updateStatus', deleteStatus: main + 'um/deleteStatus', updateStatusUser: main + 'um/updateStatusUser', - updateVoting: main + 'um/updateVoting' + updateVoting: main + 'um/updateVoting', + updateWorkgroups: main + 'um/updateWorkgroups' }, wm: { workgroup: main + 'wgm/workgroup', diff --git a/src/store/modules/userManager.js b/src/store/modules/userManager.js index d60a75f..c63ec42 100644 --- a/src/store/modules/userManager.js +++ b/src/store/modules/userManager.js @@ -25,6 +25,7 @@ const mutations = { exists.mail = user.mail exists.statusgroup = user.statusgroup exists.voting = user.voting + exists.workgroups = user.workgroup } else { state.users.push({ username: user.username, @@ -32,7 +33,8 @@ const mutations = { lastname: user.lastname, mail: user.mail, statusgroup: user.statusgroup, - voting: user.voting + voting: user.voting, + workgroups: user.workgroups }) } }, @@ -59,6 +61,14 @@ const mutations = { }, setStatusLoading: (state, value) => { state.statusLoading = value + }, + updateWorkgroups: (state, { id, workgroups }) => { + let exists = state.users.find(a => { + return a.id === id + }) + if (exists) { + exists.workgroups = workgroups + } } } @@ -126,6 +136,23 @@ const actions = { if (e.response) if (e.response.status === 401) dispatch('logout', null, { root: true }) } + }, + async updateWorkgroups({ commit, rootState, dispatch }, data) { + try { + commit('setUsersLoading', true) + const response = await axios.post( + url.vorstand.um.updateWorkgroups, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updateWorkgroups', { id: data.id, workgroups: response.data }) + commit('setUsersLoading', false) + dispatch('getLifeTime', null, { root: true }) + } catch (e) { + commit('setUsersLoading', false) + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } } } From 82610a011b680d4e8c4f31bf6eafa09e8517231f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 17 May 2020 13:46:34 +0200 Subject: [PATCH 070/117] finished ##257 --- src/components/user/Config.vue | 47 +++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/src/components/user/Config.vue b/src/components/user/Config.vue index 2933ed9..6d4fa8b 100644 --- a/src/components/user/Config.vue +++ b/src/components/user/Config.vue @@ -132,10 +132,39 @@ - + - + + +
+ + + + + @@ -186,9 +215,8 @@ export default { }, mounted() { this.$nextTick(function() { - window.addEventListener('resize', this.getWindowWidth); + window.addEventListener('resize', this.getWindowWidth) this.getWindowWidth() - }) }, methods: { @@ -196,9 +224,9 @@ export default { saveConfig: 'user/saveConfig', getStatus: 'user/getStatus' }), - getWindowWidth() { - this.isFulllineText = document.documentElement.clientWidth <= 600; - }, + getWindowWidth() { + this.isFulllineText = document.documentElement.clientWidth <= 600 + }, save() { let user = {} if (this.firstname) user.firstname = this.firstname @@ -249,6 +277,7 @@ export default { +} + From 4af0d77584515c24ec258951c29c68ecc84efc65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 17 May 2020 20:22:03 +0200 Subject: [PATCH 071/117] vorstand can create, edit and delete jobkinds --- src/components/vorstand/JobKindManager.vue | 119 ++++++++++++++++++ .../vorstand/ManagementNavigation.vue | 8 ++ src/plugins/routes.js | 6 +- src/router/index.js | 5 + src/store/index.js | 4 +- src/store/modules/jobkindManager.js | 118 +++++++++++++++++ 6 files changed, 258 insertions(+), 2 deletions(-) create mode 100644 src/components/vorstand/JobKindManager.vue create mode 100644 src/store/modules/jobkindManager.js diff --git a/src/components/vorstand/JobKindManager.vue b/src/components/vorstand/JobKindManager.vue new file mode 100644 index 0000000..036674f --- /dev/null +++ b/src/components/vorstand/JobKindManager.vue @@ -0,0 +1,119 @@ + + + + + diff --git a/src/components/vorstand/ManagementNavigation.vue b/src/components/vorstand/ManagementNavigation.vue index f2ec3ac..46ffe61 100644 --- a/src/components/vorstand/ManagementNavigation.vue +++ b/src/components/vorstand/ManagementNavigation.vue @@ -24,6 +24,14 @@ Arbeitsgruppen + + + ??? + + + Dienstarten + + diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 118a35e..66b4282 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -33,7 +33,11 @@ const url = { getUser: main + 'sm/getUser', getUsers: main + 'sm/getUsers', lockDay: main + 'sm/lockDay', - searchUser: main + 'sm/searchWithExtern' + searchUser: main + 'sm/searchWithExtern', + jobkind: main + 'sm/JobKind', + getAllJobKindsbKinds: main + 'sm/getAllJobKinds', + getJobKind: main + 'sm/getJobKind', + deleteJobKind: main + 'sm/deleteJobKind' }, um: { setStatus: main + 'um/setStatus', diff --git a/src/router/index.js b/src/router/index.js index fecd282..c7a8f16 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -24,6 +24,7 @@ import GastroNavigation from '@/components/gastro/GastroNavigation' import PriceListView from '@/views/contents/PriceListView' import UserManager from '@/components/vorstand/UserManager' import WorkgroupManagement from "@/components/vorstand/WorkgroupManagement"; +import JobKindManager from "@/components/vorstand/JobKindManager"; Vue.use(VueRouter) @@ -63,6 +64,10 @@ const routes = [ { path: 'workgroupmanagement', component: WorkgroupManagement + }, + { + path: 'jobkindmanagement', + component: JobKindManager } ] }, diff --git a/src/store/index.js b/src/store/index.js index 5fc6616..eb63086 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -10,6 +10,7 @@ import requestJobs from '@/store/modules/jobRequests' import priceList from '@/store/modules/pricelist' import usermanager from '@/store/modules/userManager' import wm from '@/store/modules/workgroupManagement' +import jkm from '@/store/modules/jobkindManager' Vue.use(Vuex) @@ -24,6 +25,7 @@ export default new Vuex.Store({ requestJobs, priceList, usermanager, - wm + wm, + jkm } }) diff --git a/src/store/modules/jobkindManager.js b/src/store/modules/jobkindManager.js new file mode 100644 index 0000000..09b36a9 --- /dev/null +++ b/src/store/modules/jobkindManager.js @@ -0,0 +1,118 @@ +import url from '@/plugins/routes' +import axios from 'axios' + +const state = { + jobkinds: [], + jobkindLoading: false +} + +const mutations = { + setJobkinds: (state, jobkinds) => { + state.jobkinds = jobkinds + }, + updateJobKind: (state, jobkind) => { + console.log(jobkind) + const exists = state.jobkinds.find(a => { + return a.id === jobkind.id + }) + console.log(exists) + if (exists) { + exists.name = jobkind.name + } else { + state.jobkinds.push(jobkind) + } + }, + deleteJobKind: (state, jobkind) => { + const exists = state.jobkinds.indexOf( + state.jobkinds.find(a => { + return a.id === jobkind.id + }) + ) + state.jobkinds.splice(exists, 1) + }, + setJobkindsLoading: (state, value) => { + state.jobkindLoading = value + } +} + +const actions = { + async getAllJobKinds({ commit, rootState, dispatch }) { + try { + commit('setJobkindsLoading', true) + const response = await axios.get(url.vorstand.sm.getAllJobKindsbKinds, { + headers: { Token: rootState.login.user.accessToken } + }) + commit('setJobkinds', response.data) + commit('setJobkindsLoading', false) + dispatch('getLifeTime', null, { root: true }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async addJobKind({ commit, rootState, dispatch }, data) { + try { + commit('setJobkindsLoading', true) + const response = await axios.put( + url.vorstand.sm.jobkind, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updateJobKind', response.data) + commit('setJobkindsLoading', false) + dispatch('getLifeTime', null, { root: true }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async updateJobKind({ commit, rootState, dispatch }, data) { + try { + commit('setJobkindsLoading', true) + const response = await axios.post( + url.vorstand.sm.jobkind, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updateJobKind', response.data) + commit('setJobkindsLoading', false) + dispatch('getLifeTime', null, { root: true }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async deleteJobKind({ commit, rootState, dispatch }, data) { + try { + commit('setJobkindsLoading', true) + await axios.post( + url.vorstand.sm.deleteJobKind, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('deleteJobKind', data) + commit('setJobkindsLoading', false) + dispatch('getLifeTime', null, { root: true }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + } +} + +const getters = { + jobkinds: state => { + return state.jobkinds + }, + jobkindsLoading: state => { + return state.jobkindLoading + } +} + +export default { + namespaced: true, + state, + mutations, + actions, + getters +} From 9bd854209e74a96e36cb855267f73880b7d9adb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 17 May 2020 21:19:19 +0200 Subject: [PATCH 072/117] vorstand can change group for jobkind --- src/components/vorstand/JobKindManager.vue | 130 ++++++++++++++------- src/components/vorstand/UserManager.vue | 61 ++++++---- src/store/modules/jobkindManager.js | 1 + 3 files changed, 130 insertions(+), 62 deletions(-) diff --git a/src/components/vorstand/JobKindManager.vue b/src/components/vorstand/JobKindManager.vue index 036674f..ca4a63d 100644 --- a/src/components/vorstand/JobKindManager.vue +++ b/src/components/vorstand/JobKindManager.vue @@ -1,43 +1,62 @@