2023-05-23 18:27:33 +00:00
|
|
|
<template>
|
2023-05-28 15:54:11 +00:00
|
|
|
<div class="h-100">
|
2023-05-26 11:12:40 +00:00
|
|
|
<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';
|
2023-05-26 11:12:40 +00:00
|
|
|
import PairlistConfigResults from '@/components/ftbot/PairlistConfigResults.vue';
|
2023-05-24 23:40:43 +00:00
|
|
|
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[]>([]);
|
2023-05-26 11:12:40 +00:00
|
|
|
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];
|
|
|
|
});
|
|
|
|
|
2023-05-24 23:40:43 +00:00
|
|
|
const evalDone = (res: PairlistEvalResponse) => {
|
|
|
|
if (res.result?.whitelist) {
|
|
|
|
whitelist.value = res.result.whitelist;
|
2023-05-26 11:12:40 +00:00
|
|
|
currentView.value = 'results';
|
2023-05-24 23:40:43 +00:00
|
|
|
}
|
2023-05-23 18:27:33 +00:00
|
|
|
};
|
2023-05-24 23:40:43 +00:00
|
|
|
const evalError = (res: PairlistEvalResponse) => {
|
|
|
|
if (res.error) {
|
|
|
|
showAlert(res.error, 'danger');
|
2023-05-23 18:27:33 +00:00
|
|
|
}
|
|
|
|
};
|
2023-05-24 23:40:43 +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>
|