From e6998ab87ecd9942abd0c12e44923e78107dafb8 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 2 Mar 2021 13:11:58 +0100 Subject: [PATCH] transactionslist two varants --- frontend/src/App.vue | 6 +- frontend/src/store/store.js | 76 ++++++++++--------- frontend/src/views/KontoOverview.vue | 8 +- frontend/src/views/KontoOverview/GddSent.vue | 17 +++-- .../src/views/KontoOverview/GddStatus.vue | 11 ++- frontend/src/views/KontoOverview/GddTable.vue | 50 ++++++++---- 6 files changed, 103 insertions(+), 65 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 41b504ec1..b77f88ea9 100755 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -13,8 +13,10 @@ export default { name: 'app', created () { - if ( $cookies.isKey("gdd_session_id") == true ) { - this.$store.state.email = this.$cookies.get('gdd_u') + //console.log("this.$cookies.get('gdd_session_id') ", this.$cookies.get('gdd_session_id') ) + //console.log(" $cookies.isKey('gdd_session_id') == true", this.$cookies.isKey("gdd_session_id") == true ) + if ( this.$cookies.get('gdd_session_id') == this.$store.state.session_id ) { + //this.$store.state.email = this.$cookies.get('gdd_u') this.$router.push('/KontoOverview') }else { this.$router.push("/Login") diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index 848ce1e4b..1f1c59223 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -18,10 +18,10 @@ export const store = new Vuex.Store({ }, ajaxCreateData: { session_id : '', - email: "max.musterman@gmail.de", - amount: 10000000, + email: "", + amount: 0, target_date:"2021-02-19T13:25:36+00:00", - memo:"AGE", + memo:"", auto_sign: true }, transactions: [], @@ -36,30 +36,30 @@ export const store = new Vuex.Store({ // Syncronous mutation of the state mutations: { email: (state, email) => { - console.log('mutation: email') + //console.log('mutation: email') state.email = email }, session_id: (state,session_id) => { - console.log('mutation: session_id') + //console.log('mutation: session_id') state.session_id = session_id }, user_balance: (state,balance) => { - console.log('mutation: user_balance') - state.user.balance = balance / 10000 + //console.log('mutation: user_balance') + state.user.balance = balance }, user_balance_gdt: (state,balance) => { - console.log('mutation: user_balance_gdt') - state.user.balance_gdt = balance / 10000 + //console.log('mutation: user_balance_gdt') + state.user.balance_gdt = balance }, transactions: (state,transactions) => { - console.log('mutation: transactions') + //console.log('mutation: transactions') state.transactions = transactions } }, // Asyncronous actions - used for api calls actions: { login: async ({ dispatch, commit }, data) => { - console.log('action: login') + //console.log('action: login') const result = await loginAPI.login(data.email,data.password) if( result.success ){ commit('session_id', result.result.data.session_id) @@ -101,50 +101,52 @@ export const store = new Vuex.Store({ router.push('/Login') }, ajaxCreate: async ({ dispatch, state }) => { - console.log('action: ajaxCreate') - console.log(state.ajaxCreateData) + //console.log('action: ajaxCreate') + //console.log("dispatch", dispatch) + //console.log("state.ajaxCreateData", state.ajaxCreateData) + /* const result = await communityAPI.create( state.ajaxCreateData.session_id, state.ajaxCreateData.email, state.ajaxCreateData.amount, - state.ajaxCreateData.memo, state.ajaxCreateData.target_date, + state.ajaxCreateData.memo ) + */ + + /* + this.ajaxCreateData.session_id : '', + this.ajaxCreateData.email: "max.musterman@gmail.de", + this.ajaxCreateData.amount: 10000000, + this.ajaxCreateData.target_date:"2021-02-19T13:25:36+00:00", + this.ajaxCreateData.memo:"AGE", + this.ajaxCreateData.auto_sign: true + */ + + + axios.post("http://localhost/transaction-creations/ajaxCreate", state.ajaxCreateData).then((result) => { + console.log("ajaxCreate result", result) + if( result.success ){ // TODO } else { - dispatch('logout') + //dispatch('logout') } - }, - ajaxListTransactions: async ({commit, dispatch, state}) => { - console.log('action: ajaxListTransactions', state.session_id) - // const result = await communityAPI.transactions(state.session_id) - - axios.get("http://localhost/state-balances/ajaxListTransactions/"+ state.session_id).then((result) => { - console.log("result",result) - console.log("result.state",result.data.state) - - console.log("result.data.state == 'success'",result.data.state == "success") - if(result.data.state == "success") { - console.log("result.count",result.data.count) - console.log("result.gdtSum",result.data.gdtSum) - console.log("result.transactions",result.data.transactions) - commit('transactions', result.data.transactions) - commit('user_balance_gdt', result.data.gdtSum) - } else { - dispatch('logout') - } - }, (error) => { console.log(error); }); + }, + ajaxListTransactions: async ({commit, dispatch, state}) => { + // console.log('action: ajaxListTransactions', state.session_id) + // const result = await communityAPI.transactions(state.session_id) + }, accountBalance: async ({ commit, dispatch, state }) => { - console.log('action: accountBalance') + //console.log('action: accountBalance') const result = await communityAPI.balance(state.session_id) - console.log(result) + //console.log(result) if(result.success) { commit('user_balance', result.result.data.balance) } else { diff --git a/frontend/src/views/KontoOverview.vue b/frontend/src/views/KontoOverview.vue index 130f7e6fa..4ad3e5ada 100644 --- a/frontend/src/views/KontoOverview.vue +++ b/frontend/src/views/KontoOverview.vue @@ -49,7 +49,13 @@ GddTable, GddAddWork, GddWorkTable - } + }, + created() { + + + this.$store.dispatch('accountBalance') + + }, }; diff --git a/frontend/src/views/KontoOverview/GddSent.vue b/frontend/src/views/KontoOverview/GddSent.vue index 0f6cbfec0..a90ceb563 100644 --- a/frontend/src/views/KontoOverview/GddSent.vue +++ b/frontend/src/views/KontoOverview/GddSent.vue @@ -162,16 +162,17 @@ export default { async onSubmit() { //event.preventDefault() console.log("onSubmit", this.form) - console.log("this.form.img", this.form.img) - console.log("this.form.email", this.form.email) - console.log("this.form.amount", this.form.amount) - console.log("this.form.memo", this.form.memo) + //console.log("this.form.img", this.form.img) + //console.log("this.form.email", this.form.email) + //console.log("this.form.amount", this.form.amount) + //console.log("this.form.memo", this.form.memo) this.$store.state.ajaxCreateData.session_id = this.$cookies.get('gdd_session_id') - this.$store.state.ajaxCreateData.email = this.form.email, - this.$store.state.ajaxCreateData.amount = this.form.amount, - this.$store.state.ajaxCreateData.memo = this.form.memo, - + this.$store.state.ajaxCreateData.email = this.form.email + this.$store.state.ajaxCreateData.amount = this.form.amount + this.$store.state.ajaxCreateData.memo = this.form.memo + this.$store.state.ajaxCreateData.target_date = Date.now() + this.$store.dispatch('ajaxCreate') }, onReset(event) { diff --git a/frontend/src/views/KontoOverview/GddStatus.vue b/frontend/src/views/KontoOverview/GddStatus.vue index 1803d1149..02a17e894 100644 --- a/frontend/src/views/KontoOverview/GddStatus.vue +++ b/frontend/src/views/KontoOverview/GddStatus.vue @@ -6,7 +6,7 @@ type="gradient-red" sub-title="balance_gdd" class="mb-4"> - {{ $store.state.user.balance.toFixed(4) }} GDD + {{ setComma($store.state.user.balance) }} GDD @@ -17,7 +17,7 @@ type="gradient-orange" sub-title="balance_gdt" class="mb-4"> - {{ $store.state.user.balance_gdt.toFixed(4) }} GDT + {{ setComma($store.state.user.balance_gdt) }} GDT @@ -36,8 +36,11 @@ export default { balance_gdt: this.$store.state.user.balance_gdt, } }, - mounted() { - this.$store.dispatch('accountBalance') + methods: { + setComma(int){ + return int / 10000 + + } }, }; \ No newline at end of file diff --git a/frontend/src/views/KontoOverview/GddTable.vue b/frontend/src/views/KontoOverview/GddTable.vue index 7d02dfc82..55ebc71b0 100644 --- a/frontend/src/views/KontoOverview/GddTable.vue +++ b/frontend/src/views/KontoOverview/GddTable.vue @@ -3,7 +3,7 @@