2021-12-22 05:44:09 +00:00
|
|
|
<template>
|
2021-12-31 15:28:34 +00:00
|
|
|
<div class="h-100 overflow-auto p-1">
|
|
|
|
<b-list-group id="tradeList">
|
2021-12-25 09:05:38 +00:00
|
|
|
<b-list-group-item
|
2021-12-25 18:50:00 +00:00
|
|
|
v-for="trade in filteredTrades"
|
2021-12-25 09:05:38 +00:00
|
|
|
:key="trade.trade_id"
|
2021-12-31 15:28:34 +00:00
|
|
|
class="border border-secondary rounded my-05 px-1"
|
2021-12-30 08:42:41 +00:00
|
|
|
@click="tradeClick(trade)"
|
2021-12-25 09:05:38 +00:00
|
|
|
>
|
2021-12-22 05:44:09 +00:00
|
|
|
<CustomTradeListEntry :trade="trade" :stake-currency-decimals="stakeCurrencyDecimals" />
|
|
|
|
</b-list-group-item>
|
|
|
|
</b-list-group>
|
|
|
|
|
2021-12-25 09:05:38 +00:00
|
|
|
<span v-if="trades.length == 0" class="mt-5">{{ emptyText }}</span>
|
|
|
|
|
2021-12-31 15:28:34 +00:00
|
|
|
<div class="w-100 d-flex justify-content-between mt-1">
|
2021-12-22 05:44:09 +00:00
|
|
|
<b-pagination
|
|
|
|
v-if="!activeTrades"
|
|
|
|
v-model="currentPage"
|
|
|
|
:total-rows="rows"
|
|
|
|
:per-page="perPage"
|
2021-12-31 15:28:34 +00:00
|
|
|
aria-controls="tradeList"
|
2021-12-22 05:44:09 +00:00
|
|
|
></b-pagination>
|
|
|
|
<b-input
|
|
|
|
v-if="showFilter"
|
|
|
|
v-model="filterText"
|
|
|
|
type="text"
|
|
|
|
placeholder="Filter"
|
|
|
|
size="sm"
|
|
|
|
style="width: unset"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2022-04-16 12:16:22 +00:00
|
|
|
import { formatPrice } from '@/shared/formatters';
|
2022-08-03 04:41:16 +00:00
|
|
|
import { Trade } from '@/types';
|
2021-12-22 05:44:09 +00:00
|
|
|
import CustomTradeListEntry from '@/components/ftbot/CustomTradeListEntry.vue';
|
2022-10-19 05:59:45 +00:00
|
|
|
import { defineComponent, computed, ref } from 'vue';
|
2022-04-19 04:53:35 +00:00
|
|
|
import { useBotStore } from '@/stores/ftbotwrapper';
|
2021-12-22 05:44:09 +00:00
|
|
|
|
2022-04-16 12:16:22 +00:00
|
|
|
export default defineComponent({
|
|
|
|
name: 'CustomTradeList',
|
2021-12-22 05:44:09 +00:00
|
|
|
components: {
|
|
|
|
CustomTradeListEntry,
|
|
|
|
},
|
2022-04-16 12:16:22 +00:00
|
|
|
props: {
|
|
|
|
trades: { required: true, type: Array as () => Trade[] },
|
|
|
|
title: { default: 'Trades', type: String },
|
|
|
|
stakeCurrency: { required: false, default: '', type: String },
|
|
|
|
activeTrades: { default: false, type: Boolean },
|
|
|
|
showFilter: { default: false, type: Boolean },
|
|
|
|
multiBotView: { default: false, type: Boolean },
|
|
|
|
emptyText: { default: 'No Trades to show.', type: String },
|
|
|
|
stakeCurrencyDecimals: { default: 3, type: Number },
|
|
|
|
},
|
2022-07-07 18:44:19 +00:00
|
|
|
setup(props) {
|
2022-04-19 04:53:35 +00:00
|
|
|
const botStore = useBotStore();
|
2022-04-16 12:16:22 +00:00
|
|
|
const currentPage = ref(1);
|
|
|
|
const filterText = ref('');
|
|
|
|
const perPage = props.activeTrades ? 200 : 25;
|
|
|
|
|
|
|
|
const rows = computed(() => props.trades.length);
|
|
|
|
|
|
|
|
const filteredTrades = computed(() => {
|
|
|
|
return props.trades.slice((currentPage.value - 1) * perPage, currentPage.value * perPage);
|
|
|
|
});
|
|
|
|
const formatPriceWithDecimals = (price) => {
|
|
|
|
return formatPrice(price, props.stakeCurrencyDecimals);
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleContextMenuEvent = (item, index, event) => {
|
|
|
|
// stop browser context menu from appearing
|
|
|
|
if (!props.activeTrades) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
event.preventDefault();
|
|
|
|
// log the selected item to the console
|
|
|
|
console.log(item);
|
|
|
|
};
|
|
|
|
|
|
|
|
const tradeClick = (trade) => {
|
2022-04-19 04:53:35 +00:00
|
|
|
botStore.activeBot.setDetailTrade(trade);
|
2022-04-16 12:16:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
currentPage,
|
|
|
|
filterText,
|
|
|
|
perPage,
|
|
|
|
filteredTrades,
|
|
|
|
formatPriceWithDecimals,
|
|
|
|
handleContextMenuEvent,
|
|
|
|
tradeClick,
|
2022-04-19 04:53:35 +00:00
|
|
|
botStore,
|
2022-04-16 12:16:22 +00:00
|
|
|
rows,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
2021-12-22 05:44:09 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-12-25 09:05:38 +00:00
|
|
|
.my-05 {
|
|
|
|
margin-top: 0.125rem;
|
|
|
|
margin-bottom: 0.125rem;
|
|
|
|
}
|
2021-12-22 05:44:09 +00:00
|
|
|
</style>
|