2020-05-14 05:15:18 +00:00
|
|
|
<template>
|
2020-05-22 18:04:27 +00:00
|
|
|
<div>
|
|
|
|
<div class="mb-2">
|
|
|
|
<label class="mr-auto h3">Balance</label>
|
2020-07-02 18:05:20 +00:00
|
|
|
<b-button class="float-right" size="sm" @click="getBalance">↻</b-button>
|
2021-05-08 07:47:31 +00:00
|
|
|
<b-form-checkbox
|
|
|
|
v-model="hideSmallBalances"
|
|
|
|
class="float-right"
|
|
|
|
size="sm"
|
|
|
|
title="Hide small balances"
|
|
|
|
button
|
|
|
|
>
|
|
|
|
<HideIcon v-if="hideSmallBalances" :size="16" />
|
|
|
|
<ShowIcon v-else :size="16" />
|
|
|
|
</b-form-checkbox>
|
2020-05-17 18:52:14 +00:00
|
|
|
</div>
|
2021-12-19 19:06:25 +00:00
|
|
|
<BalanceChart :balance="balance" />
|
2020-05-22 18:04:27 +00:00
|
|
|
<div>
|
2020-05-14 05:22:27 +00:00
|
|
|
<p v-if="balance.note">
|
|
|
|
<strong>{{ balance.note }}</strong>
|
|
|
|
</p>
|
2021-05-08 07:47:31 +00:00
|
|
|
<b-table class="table-sm" :items="balanceCurrencies" :fields="tableFields">
|
2020-05-14 05:15:18 +00:00
|
|
|
<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>
|
|
|
|
|
2020-08-09 13:07:09 +00:00
|
|
|
<script lang="ts">
|
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
|
|
|
import { namespace } from 'vuex-class';
|
2020-08-29 09:23:39 +00:00
|
|
|
import { BalanceInterface } from '@/types';
|
2021-05-08 07:47:31 +00:00
|
|
|
import HideIcon from 'vue-material-design-icons/EyeOff.vue';
|
|
|
|
import ShowIcon from 'vue-material-design-icons/Eye.vue';
|
2021-12-19 19:06:25 +00:00
|
|
|
import BalanceChart from '@/components/charts/BalanceChart.vue';
|
2021-08-28 09:39:03 +00:00
|
|
|
import { BotStoreGetters } from '@/store/modules/ftbot';
|
2020-08-09 13:07:09 +00:00
|
|
|
|
|
|
|
const ftbot = namespace('ftbot');
|
|
|
|
|
2021-05-08 07:47:31 +00:00
|
|
|
@Component({
|
2021-12-19 19:06:25 +00:00
|
|
|
components: { HideIcon, ShowIcon, BalanceChart },
|
2021-05-08 07:47:31 +00:00
|
|
|
})
|
2020-08-09 13:07:09 +00:00
|
|
|
export default class Balance extends Vue {
|
|
|
|
@ftbot.Action getBalance;
|
|
|
|
|
2021-08-28 09:39:03 +00:00
|
|
|
@ftbot.Getter [BotStoreGetters.balance]!: BalanceInterface;
|
2020-08-09 13:07:09 +00:00
|
|
|
|
2021-05-08 07:47:31 +00:00
|
|
|
hideSmallBalances = true;
|
|
|
|
|
|
|
|
smallBalance = 0.00001;
|
|
|
|
|
|
|
|
get balanceCurrencies() {
|
|
|
|
if (!this.hideSmallBalances) {
|
|
|
|
return this.balance.currencies;
|
|
|
|
}
|
|
|
|
|
2021-06-22 19:04:18 +00:00
|
|
|
return this.balance?.currencies?.filter((v) => v.est_stake >= this.smallBalance);
|
2021-05-08 07:47:31 +00:00
|
|
|
}
|
|
|
|
|
2020-08-09 13:07:09 +00:00
|
|
|
get tableFields() {
|
|
|
|
return [
|
|
|
|
{ key: 'currency', label: 'Currency' },
|
|
|
|
{ key: 'free', label: 'Available', formatter: 'formatCurrency' },
|
|
|
|
{ key: 'est_stake', label: `in ${this.balance.stake}`, formatter: 'formatCurrency' },
|
|
|
|
];
|
|
|
|
}
|
2020-05-14 05:15:18 +00:00
|
|
|
|
2020-05-17 18:43:19 +00:00
|
|
|
mounted() {
|
|
|
|
this.getBalance();
|
2020-08-09 13:07:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
formatCurrency(value) {
|
|
|
|
return value ? value.toFixed(5) : '';
|
|
|
|
}
|
|
|
|
}
|
2020-05-14 05:15:18 +00:00
|
|
|
</script>
|