mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-11 02:33:51 +00:00
composition: strategyselect
This commit is contained in:
parent
792e3a3425
commit
50ee60042a
|
@ -1,12 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="w-100 d-flex">
|
<div class="w-100 d-flex">
|
||||||
<b-form-select
|
<b-form-select id="strategy-select" v-model="locStrategy" :options="strategyList">
|
||||||
id="strategy-select"
|
|
||||||
v-model="locStrategy"
|
|
||||||
:options="strategyList"
|
|
||||||
@change="strategyChanged"
|
|
||||||
>
|
|
||||||
</b-form-select>
|
</b-form-select>
|
||||||
<div class="ml-2">
|
<div class="ml-2">
|
||||||
<b-button @click="getStrategyList">↻</b-button>
|
<b-button @click="getStrategyList">↻</b-button>
|
||||||
|
@ -20,55 +15,53 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { BotStoreGetters } from '@/store/modules/ftbot';
|
import { BotStoreGetters } from '@/store/modules/ftbot';
|
||||||
import StoreModules from '@/store/storeSubModules';
|
import StoreModules from '@/store/storeSubModules';
|
||||||
import { StrategyResult } from '@/types';
|
import { defineComponent, computed, onMounted } from '@vue/composition-api';
|
||||||
import { Component, Vue, Prop, Emit } from 'vue-property-decorator';
|
import { useNamespacedActions, useNamespacedGetters } from 'vuex-composition-helpers';
|
||||||
import { namespace } from 'vuex-class';
|
|
||||||
|
|
||||||
const ftbot = namespace(StoreModules.ftbot);
|
export default defineComponent({
|
||||||
|
name: 'StrategySelect',
|
||||||
|
props: {
|
||||||
|
value: { type: String, required: true },
|
||||||
|
showDetails: { default: false, required: false, type: Boolean },
|
||||||
|
},
|
||||||
|
emits: ['input'],
|
||||||
|
setup(props, { emit }) {
|
||||||
|
const { getStrategyList, getStrategy } = useNamespacedActions(StoreModules.ftbot, [
|
||||||
|
'getStrategyList',
|
||||||
|
'getStrategy',
|
||||||
|
]);
|
||||||
|
|
||||||
@Component({})
|
const { strategyList, strategy } = useNamespacedGetters(StoreModules.ftbot, [
|
||||||
export default class StrategySelect extends Vue {
|
BotStoreGetters.strategyList,
|
||||||
@Prop() value!: string;
|
BotStoreGetters.strategy,
|
||||||
|
]);
|
||||||
|
|
||||||
@Prop({ default: false, required: false }) showDetails!: boolean;
|
const strategyCode = computed((): string => strategy.value?.code);
|
||||||
|
const locStrategy = computed({
|
||||||
|
get() {
|
||||||
|
return props.value;
|
||||||
|
},
|
||||||
|
set(strategy) {
|
||||||
|
getStrategy(strategy);
|
||||||
|
emit('input', strategy);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
@ftbot.Action getStrategyList;
|
onMounted(() => {
|
||||||
|
if (strategyList.value.length === 0) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
getStrategyList();
|
||||||
@ftbot.Action getStrategy!: (strategy: string) => void;
|
|
||||||
|
|
||||||
@ftbot.Getter [BotStoreGetters.strategyList]!: string[];
|
|
||||||
|
|
||||||
@ftbot.Getter [BotStoreGetters.strategy]: StrategyResult;
|
|
||||||
|
|
||||||
@Emit('input')
|
|
||||||
emitStrategy(strategy: string) {
|
|
||||||
this.getStrategy(strategy);
|
|
||||||
return strategy;
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
get strategyCode(): string {
|
return {
|
||||||
return this.strategy?.code;
|
getStrategyList,
|
||||||
}
|
getStrategy,
|
||||||
|
strategyList,
|
||||||
get locStrategy() {
|
strategy,
|
||||||
return this.value;
|
strategyCode,
|
||||||
}
|
locStrategy,
|
||||||
|
};
|
||||||
set locStrategy(val) {
|
},
|
||||||
this.emitStrategy(val);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
strategyChanged(newVal) {
|
|
||||||
this.value = newVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
mounted() {
|
|
||||||
if (this.strategyList.length === 0) {
|
|
||||||
this.getStrategyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style></style>
|
<style></style>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user