frequi_origin/src/components/ftbot/Balance.vue

51 lines
1.3 KiB
Vue
Raw Normal View History

2020-05-14 05:15:18 +00:00
<template>
<div class="card">
<div class="card-header">
<label class="mr-auto">Balance</label>
<b-button class="float-right" size="sm" @click="getBalance">R</b-button>
</div>
2020-05-14 05:15:18 +00:00
<div class="card-body">
2020-05-14 05:22:27 +00:00
<p v-if="balance.note">
<strong>{{ balance.note }}</strong>
</p>
2020-05-14 05:15:18 +00:00
<b-table class="table-sm" :items="balance.currencies" :fields="table_fields">
<template slot="bottom-row">
2020-05-14 05:16:07 +00:00
<td><strong>Total</strong></td>
2020-05-14 05:15:18 +00:00
<td></td>
<!-- this is a computed prop that adds up all the expenses in the visible rows -->
2020-05-14 05:16:07 +00:00
<td>
<strong>{{ formatCurrency(balance.total) }}</strong>
</td>
2020-05-14 05:15:18 +00:00
</template>
</b-table>
</div>
</div>
</template>
<script>
2020-05-17 18:43:19 +00:00
import { mapActions, mapState } from 'vuex';
2020-05-14 05:15:18 +00:00
export default {
name: 'Balance',
computed: {
...mapState('ftbot', ['balance']),
table_fields() {
return [
{ key: 'currency', label: 'Currency' },
{ key: 'free', label: 'Available', formatter: 'formatCurrency' },
{ key: 'est_stake', label: `in ${this.balance.stake}`, formatter: 'formatCurrency' },
];
},
},
methods: {
2020-05-17 18:43:19 +00:00
...mapActions('ftbot', ['getBalance']),
2020-05-14 05:15:18 +00:00
formatCurrency(value) {
2020-05-14 16:12:20 +00:00
return value ? value.toFixed(5) : '';
2020-05-14 05:15:18 +00:00
},
},
2020-05-17 18:43:19 +00:00
mounted() {
this.getBalance();
},
2020-05-14 05:15:18 +00:00
};
</script>