pair and timeframe should be props

This commit is contained in:
Matthias 2020-06-20 08:52:43 +02:00
parent 7d8a9655e4
commit ef839578ba
2 changed files with 39 additions and 9 deletions

View File

@ -32,12 +32,21 @@ const plotConfig = {
export default { export default {
name: 'CandleChart', name: 'CandleChart',
components: { 'v-chart': ECharts }, components: { 'v-chart': ECharts },
props: {
pair: {
type: String,
required: false,
default: 'XRP/USDT',
},
timeframe: {
type: String,
required: false,
default: '5m',
},
},
data() { data() {
return { return {};
pair: 'XRP/USDT',
timeframe: '5m',
};
}, },
computed: { computed: {
...mapState('ftbot', ['history']), ...mapState('ftbot', ['history']),

View File

@ -1,11 +1,19 @@
<template> <template>
<div> <div class="container-fluid">
<CandleChart> </CandleChart> <div class="row mb-2">
<div class="col-mb-2">
<b-form-select :options="whitelist" v-model="pair" @change="refresh"> </b-form-select>
</div>
<div class="col-mb-2"></div>
</div>
<div class="row">
<CandleChart :pair="pair" :timeframe="timeframe"> </CandleChart>
</div>
</div> </div>
</template> </template>
<script> <script>
import { mapActions } from 'vuex'; import { mapActions, mapState } from 'vuex';
import CandleChart from '@/components/ftbot/CandleChart.vue'; import CandleChart from '@/components/ftbot/CandleChart.vue';
@ -14,11 +22,24 @@ export default {
components: { components: {
CandleChart, CandleChart,
}, },
data() {
return {
pair: 'XRP/USDT',
timeframe: '5m',
};
},
computed: {
...mapState('ftbot', ['whitelist']),
},
mounted() { mounted() {
this.getPairHistory({ pair: 'XRP/USDT', timeframe: '5m', limit: 500 }); this.getWhitelist();
this.refresh();
}, },
methods: { methods: {
...mapActions('ftbot', ['getPairHistory']), ...mapActions('ftbot', ['getPairHistory', 'getWhitelist']),
refresh() {
this.getPairHistory({ pair: this.pair, timeframe: this.timeframe, limit: 500 });
},
}, },
}; };
</script> </script>