From 345c0f09d9546a9be3f5090070c77122b9922806 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 2 Mar 2021 10:24:04 +0100 Subject: [PATCH] add transactionslist scelet --- frontend/src/App.vue | 2 +- frontend/src/routes/routes.js | 14 +- frontend/src/store/store.js | 40 +++- frontend/src/views/KontoOverview.vue | 100 +--------- frontend/src/views/KontoOverview/GddSent.vue | 174 ++++++++---------- .../src/views/KontoOverview/GddStatus.vue | 7 +- frontend/src/views/KontoOverview/GddTable.vue | 38 ++-- frontend/src/views/Pages/Login.vue | 1 + frontend/src/views/{ => Pages}/thx.vue | 0 9 files changed, 147 insertions(+), 229 deletions(-) rename frontend/src/views/{ => Pages}/thx.vue (100%) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index bb9330920..41b504ec1 100755 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -17,7 +17,7 @@ export default { this.$store.state.email = this.$cookies.get('gdd_u') this.$router.push('/KontoOverview') }else { - this.$router.push("/Login") + this.$router.push("/Login") } } } diff --git a/frontend/src/routes/routes.js b/frontend/src/routes/routes.js index 15de73163..844b323b6 100755 --- a/frontend/src/routes/routes.js +++ b/frontend/src/routes/routes.js @@ -8,23 +8,23 @@ import NotFound from '@/views/NotFoundPage.vue' const routes = [ { path: '/', - redirect: 'landing', + redirect: 'login', component: AuthLayoutGDD, children: [ { path: '/login', name: 'login', - component: () => import(/* webpackChunkName: "demo" */ '../views/Pages/Login.vue') + component: () => import('../views/Pages/Login.vue') }, { path: '/thx', name: 'Thanks', - component: () => import(/* webpackChunkName: "demo" */ '../views/thx.vue') + component: () => import('../views/Pages/thx.vue') }, { path: '/register', name: 'register', - component: () => import(/* webpackChunkName: "demo" */ '../views/Pages/Register.vue') + component: () => import('../views/Pages/Register.vue') }, ] }, @@ -36,7 +36,7 @@ const routes = [ { path: '/KontoOverview', name: 'Kontoübersicht', - component: () => import(/* webpackChunkName: "demo" */ '../views/KontoOverview.vue'), + component: () => import('../views/KontoOverview.vue'), meta: { requiresAuth: true } @@ -44,7 +44,7 @@ const routes = [ { path: '/profile', name: 'profile', - component: () => import(/* webpackChunkName: "demo" */ '../views/Pages/UserProfile.vue') + component: () => import('../views/Pages/UserProfile.vue') } ] }, @@ -57,7 +57,7 @@ const routes = [ { path: '/AdminOverview', name: 'Adminübersicht', - component: () => import(/* webpackChunkName: "demo" */ '../views/AdminOverview.vue'), + component: () => import('../views/AdminOverview.vue'), meta: { requiresAuth: true } diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index cb85c42c5..848ce1e4b 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -4,6 +4,8 @@ Vue.use(Vuex) import router from '../routes/router.js' import loginAPI from '../apis/loginAPI' import communityAPI from '../apis/communityAPI' +import axios from 'axios' + export const store = new Vuex.Store({ state: { @@ -11,7 +13,8 @@ export const store = new Vuex.Store({ email: null, user : { name:"", - balance: 0 + balance: 0, + balance_gdt: 0 }, ajaxCreateData: { session_id : '', @@ -44,6 +47,10 @@ export const store = new Vuex.Store({ console.log('mutation: user_balance') state.user.balance = balance / 10000 }, + user_balance_gdt: (state,balance) => { + console.log('mutation: user_balance_gdt') + state.user.balance_gdt = balance / 10000 + }, transactions: (state,transactions) => { console.log('mutation: transactions') state.transactions = transactions @@ -110,14 +117,29 @@ export const store = new Vuex.Store({ } }, ajaxListTransactions: async ({commit, dispatch, state}) => { - console.log('action: ajaxListTransactions') - const result = await communityAPI.transactions(state.session_id) - console.log(result) - if(result.success) { - commit('transactions', result.result.data.transactions) - } else { - dispatch('logout') - } + 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); + }); + + }, accountBalance: async ({ commit, dispatch, state }) => { console.log('action: accountBalance') diff --git a/frontend/src/views/KontoOverview.vue b/frontend/src/views/KontoOverview.vue index 4cfcddfe7..130f7e6fa 100644 --- a/frontend/src/views/KontoOverview.vue +++ b/frontend/src/views/KontoOverview.vue @@ -8,21 +8,18 @@ -
-
+
-
-
+
-

@@ -34,35 +31,7 @@
this.$store.dispatch('ajaxListTransactions')
this.$store.dispatch('accountBalance')

-

User Balanace

- this.$store.state.user.balance -

- {{this.$store.state.user}} -

-
-

User Balanace

- this.$store.state.user.balance -

- {{this.$store.state.user.balance}} -

- -
-

User Transactions List

- this.$store.state.transactions -

- {{this.$store.state.transactions}} -

- - -
-

User Participation List

- /public/json-example/userparticipation.json -

- {{userparticipation}} -

- - -
+ diff --git a/frontend/src/views/KontoOverview/GddSent.vue b/frontend/src/views/KontoOverview/GddSent.vue index 79c4ad32d..0f6cbfec0 100644 --- a/frontend/src/views/KontoOverview/GddSent.vue +++ b/frontend/src/views/KontoOverview/GddSent.vue @@ -1,79 +1,68 @@ diff --git a/frontend/src/views/KontoOverview/GddStatus.vue b/frontend/src/views/KontoOverview/GddStatus.vue index bffb6933a..1803d1149 100644 --- a/frontend/src/views/KontoOverview/GddStatus.vue +++ b/frontend/src/views/KontoOverview/GddStatus.vue @@ -15,9 +15,9 @@ - {{ balance_gdt }} GDT + {{ $store.state.user.balance_gdt.toFixed(4) }} GDT @@ -33,11 +33,10 @@ export default { data(){ return { balance_gdd: this.$store.state.user.balance, - balance_gdt: "0", + balance_gdt: this.$store.state.user.balance_gdt, } }, mounted() { - this.$store.dispatch('accountBalance') }, }; diff --git a/frontend/src/views/KontoOverview/GddTable.vue b/frontend/src/views/KontoOverview/GddTable.vue index ccc29d67e..7d02dfc82 100644 --- a/frontend/src/views/KontoOverview/GddTable.vue +++ b/frontend/src/views/KontoOverview/GddTable.vue @@ -1,9 +1,9 @@