frequi_origin/src/components/ftbot/Balance.vue

89 lines
2.5 KiB
Vue
Raw Normal View History

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">&#x21bb;</b-button>
<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>
</div>
2022-01-24 18:47:33 +00:00
<BalanceChart v-if="balanceCurrencies" :currencies="balanceCurrencies" />
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>
<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';
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';
import { BotStoreGetters } from '@/store/modules/ftbot';
import StoreModules from '@/store/storeSubModules';
2020-08-09 13:07:09 +00:00
const ftbot = namespace(StoreModules.ftbot);
2020-08-09 13:07:09 +00:00
@Component({
2021-12-19 19:06:25 +00:00
components: { HideIcon, ShowIcon, BalanceChart },
})
2020-08-09 13:07:09 +00:00
export default class Balance extends Vue {
@ftbot.Action getBalance;
@ftbot.Getter [BotStoreGetters.balance]!: BalanceInterface;
2020-08-09 13:07:09 +00:00
@ftbot.Getter [BotStoreGetters.stakeCurrencyDecimals]!: number;
hideSmallBalances = true;
get smallBalance(): number {
return Number((0.1 ** this.stakeCurrencyDecimals).toFixed(8));
}
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);
}
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>