added blacklist configuration

This commit is contained in:
Tako 2023-05-30 11:28:55 +00:00
parent ee8db64f28
commit 5e927d406e
3 changed files with 65 additions and 3 deletions

View File

@ -0,0 +1,48 @@
<template>
<b-card no-body class="mb-2">
<template #header>
<div class="d-flex text-start align-items-center">
<div class="d-flex flex-grow-1 align-items-center">
<div
role="button"
class="d-flex flex-grow-1 align-items-center flex-column"
@click="visible = !visible"
>
<span class="fw-bold fd-italic">Blacklist</span>
</div>
</div>
</div>
</template>
<b-card-body :class="{ hidden: !visible }">
<b-collapse v-model="visible">
<b-input-group v-for="(item, i) in pairlistStore.blacklist" :key="i" class="mb-2">
<b-form-input v-model="pairlistStore.blacklist[i]" />
<b-input-group-append>
<b-button size="sm" @click="pairlistStore.removeFromBlacklist(i)"
><i-mdi-close
/></b-button>
</b-input-group-append>
</b-input-group>
<b-button @click="pairlistStore.addToBlacklist()">Add</b-button>
</b-collapse>
</b-card-body>
</b-card>
</template>
<script setup>
import { ref } from 'vue';
import { usePairlistConfigStore } from '@/stores/pairlistConfig';
const pairlistStore = usePairlistConfigStore();
const visible = ref(false);
</script>
<style lang="scss" scoped>
.hidden {
padding: 0;
}
:deep(.collapsing) {
-webkit-transition: none;
transition: none;
display: none;
}
</style>

View File

@ -64,6 +64,7 @@
</b-button> </b-button>
</template> </template>
</b-input-group> </b-input-group>
<PairlistConfigBlacklist />
<b-alert <b-alert
:model-value=" :model-value="
pairlistStore.config.pairlists.length > 0 && !pairlistStore.firstPairlistIsGenerator pairlistStore.config.pairlists.length > 0 && !pairlistStore.firstPairlistIsGenerator
@ -95,7 +96,8 @@ import { computed, onMounted, ref } from 'vue';
import { useBotStore } from '@/stores/ftbotwrapper'; import { useBotStore } from '@/stores/ftbotwrapper';
import { usePairlistConfigStore } from '@/stores/pairlistConfig'; import { usePairlistConfigStore } from '@/stores/pairlistConfig';
import PairlistConfigItem from './PairlistConfigItem.vue'; import PairlistConfigItem from './PairlistConfigItem.vue';
import { Pairlist, PairlistConfig, PairlistParamType, PairlistPayloadItem } from '@/types'; import PairlistConfigBlacklist from './PairlistConfigBlacklist.vue';
import { Pairlist, PairlistParamType, PairlistPayloadItem } from '@/types';
import { useSortable, moveArrayElement } from '@vueuse/integrations/useSortable'; import { useSortable, moveArrayElement } from '@vueuse/integrations/useSortable';
import CopyableTextfield from '@/components/general/CopyableTextfield.vue'; import CopyableTextfield from '@/components/general/CopyableTextfield.vue';
@ -178,7 +180,7 @@ function configToPayload() {
return { return {
pairlists: pairlists, pairlists: pairlists,
stake_currency: botStore.activeBot.stakeCurrency, stake_currency: botStore.activeBot.stakeCurrency,
blacklist: [], blacklist: pairlistStore.blacklist,
}; };
} }

View File

@ -13,6 +13,7 @@ export const usePairlistConfigStore = defineStore(
const evaluating = ref<boolean>(false); const evaluating = ref<boolean>(false);
const intervalId = ref<number>(); const intervalId = ref<number>();
const whitelist = ref<string[]>([]); const whitelist = ref<string[]>([]);
const blacklist = ref<string[]>([]);
const config = ref<PairlistConfig>({ name: '', pairlists: [] }); const config = ref<PairlistConfig>({ name: '', pairlists: [] });
const savedConfigs = ref<PairlistConfig[]>([]); const savedConfigs = ref<PairlistConfig[]>([]);
@ -78,17 +79,28 @@ export const usePairlistConfigStore = defineStore(
config.value = structuredClone(toRaw(selected)); config.value = structuredClone(toRaw(selected));
} }
function addToBlacklist() {
blacklist.value.push('');
}
function removeFromBlacklist(index: number) {
blacklist.value.splice(index, 1);
}
return { return {
evaluating, evaluating,
whitelist, whitelist,
config, config,
savedConfigs, savedConfigs,
blacklist,
startPairlistEvaluation, startPairlistEvaluation,
addToConfig, addToConfig,
removeFromConfig, removeFromConfig,
saveConfig, saveConfig,
selectConfig, selectConfig,
newConfig, newConfig,
addToBlacklist,
removeFromBlacklist,
firstPairlistIsGenerator, firstPairlistIsGenerator,
pairlistValid, pairlistValid,
}; };
@ -96,7 +108,7 @@ export const usePairlistConfigStore = defineStore(
{ {
persist: { persist: {
key: 'pairlist-configs', key: 'pairlist-configs',
paths: ['savedConfigs'], paths: ['savedConfigs', 'blacklist'],
}, },
}, },
); );