frequi_origin/src/views/PairlistConfigView.vue

86 lines
2.3 KiB
Vue
Raw Normal View History

2023-05-23 18:27:33 +00:00
<template>
2023-05-28 15:54:11 +00:00
<div class="h-100">
<b-button-group class="py-3">
<b-button
v-model="currentView"
:active="currentView === 'configurator'"
@click="currentView = 'configurator'"
>Configurator</b-button
>
<b-button
v-model="currentView"
:disabled="whitelist.length == 0"
:active="currentView === 'results'"
@click="currentView = 'results'"
>Results</b-button
>
</b-button-group>
<PairlistConfigurator
v-if="currentView == 'configurator'"
:selected-config="selectedConfig"
@save-config="addConfig"
@started="evalStarted"
@error="evalError"
@done="evalDone"
/>
2023-05-26 17:45:52 +00:00
<PairlistConfigResults v-if="currentView == 'results'" :input-whitelist="whitelist" />
2023-05-23 18:27:33 +00:00
</div>
</template>
<script setup lang="ts">
import { useBotStore } from '@/stores/ftbotwrapper';
import { ref, computed } from 'vue';
import PairlistConfigurator from '@/components/ftbot/PairlistConfigurator.vue';
import PairlistConfigResults from '@/components/ftbot/PairlistConfigResults.vue';
import { PairlistConfig, PairlistEvalResponse, StatusResponse } from '@/types';
import { showAlert } from '@/stores/alerts';
2023-05-23 18:27:33 +00:00
const botStore = useBotStore();
const configs = ref<PairlistConfig[]>([]);
const selectedConfig = ref<PairlistConfig>({ name: '', pairlists: [] });
const whitelist = ref<string[]>([]);
const currentView = ref<'configurator' | 'results'>('configurator');
2023-05-23 18:27:33 +00:00
const addConfig = (config: PairlistConfig) => {
const i = configs.value.findIndex((c) => c.name === config.name);
if (i > -1) {
configs.value[i] = config;
} else {
configs.value.push(config);
}
selectedConfig.value = config;
};
const configsSelectOptions = computed(() => {
const options = configs.value.map((c) => {
return { value: c, text: c.name };
});
const val: PairlistConfig = {
name: '',
pairlists: [],
};
return [{ text: 'New config...', value: val }, ...options];
});
const evalDone = (res: PairlistEvalResponse) => {
if (res.result?.whitelist) {
whitelist.value = res.result.whitelist;
currentView.value = 'results';
}
2023-05-23 18:27:33 +00:00
};
const evalError = (res: PairlistEvalResponse) => {
if (res.error) {
showAlert(res.error, 'danger');
2023-05-23 18:27:33 +00:00
}
};
const evalStarted = (res: StatusResponse) => {
whitelist.value = [];
showAlert(res.status, 'info');
2023-05-24 18:19:46 +00:00
};
2023-05-23 18:27:33 +00:00
</script>