transactionslist two varants

This commit is contained in:
ogerly 2021-03-02 13:11:58 +01:00
parent 345c0f09d9
commit e6998ab87e
6 changed files with 103 additions and 65 deletions

View File

@ -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")

View File

@ -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 {

View File

@ -49,7 +49,13 @@
GddTable,
GddAddWork,
GddWorkTable
}
},
created() {
this.$store.dispatch('accountBalance')
},
};
</script>

View File

@ -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) {

View File

@ -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
<template slot="footer">
<span class="text-success mr-2">Wird immer angezeigt</span>
</template>
@ -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
<template slot="footer">
<span class="text-nowrap">Wird nur angezeigt wenn user GDT besitzt.</span>
</template>
@ -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
}
},
};
</script>

View File

@ -3,7 +3,7 @@
<b-table striped hover :items="items" :fields="fields" :tbody-tr-class="rowClass" responsive="true" >
<template #cell(status)="row">
<img v-if="row.item.type === 'sent' " src="img/icons/gradido/minus.png" width="50" />
<img v-if="row.item.type === 'send' " src="img/icons/gradido/minus.png" width="50" />
<img v-else src="img/icons/gradido/plus-low.png" width="50" />
</template>
<template #cell(details)="row">
@ -39,9 +39,9 @@
<b-list-group >
<b-list-group-item v-for="item in items" :key="item.id">
<div class="d-flex w-100 justify-content-between" @click="toogle(item)" >
<b-icon v-if="item.type === 'sent'" icon="box-arrow-left" class="m-1" font-scale="2" style="color:red"></b-icon>
<b-icon v-if="item.type === 'send'" icon="box-arrow-left" class="m-1" font-scale="2" style="color:red"></b-icon>
<b-icon v-else icon="box-arrow-right" class="m-1" font-scale="2" style="color:green" ></b-icon>
<h1 class="mb-1">{{item.balance}} <small>GDD</small></h1>
<h1 class="mb-1">{{ setComma(item.balance) }} <small>GDD</small></h1>
<h2 class="text-muted"><small>{{item.date}}</small> - {{item.name}}</h2>
</div>
</b-list-group-item>
@ -51,7 +51,7 @@
</template>
<script>
import axios from 'axios';
export default {
name: 'GddTable',
@ -59,26 +59,50 @@ export default {
return {
form: [],
fields: [ 'balance', 'date', 'memo', 'name', 'transaction_id', 'type','details'],
items: this.$store.state.transactions
items: []
};
},
created() {
axios.get("http://localhost/state-balances/ajaxListTransactions/"+ this.$store.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")
//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)
this.$store.state.user.balance_gdt = result.data.gdtSum
this.items = result.data.transactions
}, (error) => {
console.log(error);
});
},
methods: {
rowClass(item, type) {
if (!item || type !== 'row') return
if (item.type === 'received') return 'table-success'
if (item.type === 'sent') return 'table-warning'
if (item.type === 'create') return 'table-primary'
if (item.type === 'receive') return 'table-success'
if (item.type === 'send') return 'table-warning'
if (item.type === 'creation') return 'table-primary'
},
toogle(item) {
const temp = '<b-collapse visible v-bind:id="item.id">xxx <small class="text-muted">porta</small></b-collapse>'
},
setComma(int){
return int / 10000
}
},
mounted() {
this.$store.dispatch('ajaxListTransactions')
console.log("this.items", this.items)
}
};
</script>
<style>