From a8ae06b3a894b55aaaf6c1c8cc12650fba429c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 11 Feb 2020 20:34:05 +0100 Subject: [PATCH 1/4] transfer --- src/store/modules/barUsers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/store/modules/barUsers.js b/src/store/modules/barUsers.js index be28632..450ad3e 100644 --- a/src/store/modules/barUsers.js +++ b/src/store/modules/barUsers.js @@ -6,7 +6,8 @@ const state = { allUsers: [], filter: '', usersLoading: false, - allUsersLoading: false + allUsersLoading: false, + message: '' } const mutations = { From 08c8475ac13c4ccedff69576f0f3160c521d209e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 16 Feb 2020 20:35:13 +0100 Subject: [PATCH 2/4] add history --- src/components/baruser/CreditLists.vue | 123 +++++++++++++++++++++++-- src/components/baruser/SearchBar.vue | 21 ++++- src/main.js | 2 +- src/plugins/routes.js | 4 +- src/router/index.js | 4 +- src/store/modules/barUsers.js | 57 +++++++++++- 6 files changed, 192 insertions(+), 19 deletions(-) diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index 099cd79..0de77bc 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -4,6 +4,23 @@ + + + + + {{ now(message.date) }} + {{ message.message }} + Klicken um zurückzusetzen + + + +
@@ -22,7 +39,11 @@ class="creditBtn" block @click=" - addAmount({ username: user.username, amount: 200 }) + addAmount({ + username: user.username, + amount: 200, + user: user + }) " :color="color" :disabled="user.locked" @@ -34,7 +55,11 @@ class="creditBtn" block @click=" - addAmount({ username: user.username, amount: 100 }) + addAmount({ + username: user.username, + amount: 100, + user: user + }) " :color="color" :disabled="user.locked" @@ -46,7 +71,11 @@ class="creditBtn" block @click=" - addAmount({ username: user.username, amount: 50 }) + addAmount({ + username: user.username, + amount: 50, + user: user + }) " :color="color" :disabled="user.locked" @@ -60,7 +89,11 @@ class="creditBtn" block @click=" - addAmount({ username: user.username, amount: 40 }) + addAmount({ + username: user.username, + amount: 40, + user: user + }) " :color="color" :disabled="user.locked" @@ -72,7 +105,11 @@ class="creditBtn" block @click=" - addAmount({ username: user.username, amount: 20 }) + addAmount({ + username: user.username, + amount: 20, + user: user + }) " :color="color" :disabled="user.locked" @@ -84,7 +121,11 @@ class="creditBtn" block @click=" - addAmount({ username: user.username, amount: 10 }) + addAmount({ + username: user.username, + amount: 10, + user: user + }) " :color="color" :disabled="user.locked" @@ -113,6 +154,17 @@ > + + {{ message.message }} +
@@ -158,8 +210,63 @@ export default { ...mapGetters({ users: 'barUsers/users', filter: 'barUsers/filter', - loading: 'barUsers/usersLoading' - }) + loading: 'barUsers/usersLoading', + messages: 'barUsers/messages', + menu: 'barUsers/menu' + }), + under5minutes() { + return now => { + var actual = new Date() + var zero = new Date(0) + var date = new Date(actual - now) + if ( + date.getFullYear() === zero.getFullYear() && + date.getMonth() === zero.getMonth() && + date.getDate() === zero.getDate() + ) { + if (date.getMinutes() < 6) { + return true + } + } + return false + } + }, + now() { + return now => { + 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()) { + if (date.getHours() === zero.getDate()) { + if (date.getMinutes() < 1) { + return 'vor ' + date.getSeconds() + ' Sekunden' + } else if (date.getMinutes() < 10) { + return 'vor ' + date.getMinutes() + ' Minuten' + } else { + return now.getHours() + ':' + now.getMinutes() + } + } else { + return now.getHours() + ':' + now.getMinutes() + } + } + } + } + return ( + now.getDate() + + '.' + + now.getMonth() + + '.' + + now.getFullYear() + + ' ' + + now.getHours() + + ':' + + now.getMinutes() + ) + } + } } } 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 4/4] 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) },