wip config storage

This commit is contained in:
Tako 2023-05-29 22:24:48 +00:00
parent cebf07bdee
commit 0c4c4b7fc6
2 changed files with 90 additions and 73 deletions

View File

@ -34,13 +34,21 @@
<b-col> <b-col>
<b-row> <b-row>
<b-col> <b-col>
<b-form-input <b-row>
<b-col>
<b-form-select v-model="pairlistStore.config" :options="configsSelectOptions" />
</b-col>
<b-col
><b-form-input
v-model="pairlistStore.config.name" v-model="pairlistStore.config.name"
class="mb-2" class="mb-2"
placeholder="Configuration name..." placeholder="Configuration name..."
></b-form-input> ></b-form-input
></b-col>
</b-row>
</b-col> </b-col>
<b-col cols="auto"> <b-col cols="auto">
<b-button>New</b-button>
<b-button @click="pairlistStore.saveConfig()">Save</b-button> <b-button @click="pairlistStore.saveConfig()">Save</b-button>
</b-col> </b-col>
</b-row> </b-row>

View File

@ -5,7 +5,9 @@ import { Pairlist, PairlistConfig, PairlistsPayload } from '@/types';
import { computed, ref, toRaw } from 'vue'; import { computed, ref, toRaw } from 'vue';
import { showAlert } from './alerts'; import { showAlert } from './alerts';
export const usePairlistConfigStore = defineStore('pairlistConfig', () => { export const usePairlistConfigStore = defineStore(
'pairlistConfig',
() => {
const botStore = useBotStore(); const botStore = useBotStore();
const evaluating = ref<boolean>(false); const evaluating = ref<boolean>(false);
@ -62,9 +64,9 @@ export const usePairlistConfigStore = defineStore('pairlistConfig', () => {
const i = savedConfigs.value.findIndex((c) => c.name === config.value.name); const i = savedConfigs.value.findIndex((c) => c.name === config.value.name);
if (i > -1) { if (i > -1) {
savedConfigs.value[i] = config.value; savedConfigs.value[i] = structuredClone(toRaw(config.value));
} else { } else {
savedConfigs.value.push(config.value); savedConfigs.value.push(structuredClone(toRaw(config.value)));
} }
}; };
@ -80,4 +82,11 @@ export const usePairlistConfigStore = defineStore('pairlistConfig', () => {
firstPairlistIsGenerator, firstPairlistIsGenerator,
pairlistValid, pairlistValid,
}; };
}); },
{
persist: {
key: 'pairlist-configs',
paths: ['savedConfigs'],
},
},
);