mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-13 03:33:50 +00:00
use edit-value for config actions
This commit is contained in:
parent
ef70eaded8
commit
8cee684a58
|
@ -1,51 +1,33 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="d-flex flex-row mb-2 gap-2">
|
<div class="d-flex mb-2 gap-2">
|
||||||
<b-button
|
<edit-value
|
||||||
title="Delete config"
|
v-model="pairlistStore.config.name"
|
||||||
:disabled="!pairlistStore.isSavedConfig"
|
editable-name="config"
|
||||||
variant="dark"
|
:allow-add="true"
|
||||||
@click="pairlistStore.deleteConfig()"
|
:allow-duplicate="true"
|
||||||
><i-mdi-delete width="24" height="24"
|
:allow-edit="true"
|
||||||
/></b-button>
|
class="d-flex flex-grow-1"
|
||||||
|
@delete="pairlistStore.deleteConfig"
|
||||||
<b-form-input v-model="configName" placeholder="Configuration name..." />
|
@duplicate="(oldName:string,newName:string) => pairlistStore.duplicateConfig(oldName, newName)"
|
||||||
|
@new="(name:string) => pairlistStore.newConfig(name)"
|
||||||
<b-button-group>
|
@rename="(oldName: string, newName:string) => pairlistStore.renameOrSaveConfig(oldName,newName)"
|
||||||
<b-dropdown variant="dark" title="Saved configs">
|
>
|
||||||
<b-dropdown-item-button
|
<b-form-select
|
||||||
v-for="config in pairlistStore.savedConfigs"
|
v-model="pairlistStore.config"
|
||||||
:key="config.name"
|
size="sm"
|
||||||
@click="pairlistStore.selectConfig(config)"
|
:options="
|
||||||
>{{ config.name }}</b-dropdown-item-button
|
pairlistStore.savedConfigs.map((c) => {
|
||||||
>
|
return { text: c.name, value: c };
|
||||||
</b-dropdown>
|
})
|
||||||
<b-button
|
"
|
||||||
title="Save config"
|
/>
|
||||||
variant="dark"
|
</edit-value>
|
||||||
:disabled="!configName || pairlistStore.config.pairlists.length == 0"
|
|
||||||
@click="pairlistStore.saveConfig(configName)"
|
|
||||||
><i-mdi-content-save width="24" height="24"
|
|
||||||
/></b-button>
|
|
||||||
</b-button-group>
|
|
||||||
<b-button
|
|
||||||
title="Clone config"
|
|
||||||
variant="dark"
|
|
||||||
:disabled="!pairlistStore.config.name || !pairlistStore.isSavedConfig"
|
|
||||||
@click="pairlistStore.cloneConfig()"
|
|
||||||
><i-mdi-content-copy width="24" height="24"
|
|
||||||
/></b-button>
|
|
||||||
<b-button
|
|
||||||
title="New config"
|
|
||||||
variant="dark"
|
|
||||||
:disabled="pairlistStore.config.pairlists.length == 0"
|
|
||||||
@click="pairlistStore.newConfig()"
|
|
||||||
><i-mdi-plus width="24" height="24"
|
|
||||||
/></b-button>
|
|
||||||
<b-button
|
<b-button
|
||||||
title="Evaluate pairlist"
|
title="Evaluate pairlist"
|
||||||
:disabled="pairlistStore.evaluating || !pairlistStore.pairlistValid"
|
:disabled="pairlistStore.evaluating || !pairlistStore.pairlistValid"
|
||||||
variant="primary"
|
variant="primary"
|
||||||
class="col-lg-2"
|
class="col-lg-2"
|
||||||
|
size="sm"
|
||||||
@click="pairlistStore.startPairlistEvaluation()"
|
@click="pairlistStore.startPairlistEvaluation()"
|
||||||
>
|
>
|
||||||
<b-spinner v-if="pairlistStore.evaluating" small></b-spinner>
|
<b-spinner v-if="pairlistStore.evaluating" small></b-spinner>
|
||||||
|
@ -55,15 +37,6 @@
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { usePairlistConfigStore } from '@/stores/pairlistConfig';
|
import { usePairlistConfigStore } from '@/stores/pairlistConfig';
|
||||||
import { ref, watch } from 'vue';
|
import EditValue from '../general/EditValue.vue';
|
||||||
const pairlistStore = usePairlistConfigStore();
|
const pairlistStore = usePairlistConfigStore();
|
||||||
|
|
||||||
const configName = ref(pairlistStore.config.name);
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => pairlistStore.config.name,
|
|
||||||
() => {
|
|
||||||
configName.value = pairlistStore.config.name;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -73,9 +73,9 @@ export const usePairlistConfigStore = defineStore(
|
||||||
config.value.pairlists.splice(index, 1);
|
config.value.pairlists.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveConfig(name: string) {
|
function renameOrSaveConfig(oldName: string, newName: string) {
|
||||||
const i = savedConfigs.value.findIndex((c) => c.name === config.value.name);
|
const i = savedConfigs.value.findIndex((c) => c.name === config.value.name);
|
||||||
config.value.name = name;
|
config.value.name = newName;
|
||||||
|
|
||||||
if (i > -1) {
|
if (i > -1) {
|
||||||
savedConfigs.value[i] = config.value;
|
savedConfigs.value[i] = config.value;
|
||||||
|
@ -84,11 +84,19 @@ export const usePairlistConfigStore = defineStore(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function cloneConfig() {
|
function newConfig(name: string) {
|
||||||
config.value = {
|
const c = { name: name, pairlists: [] };
|
||||||
name: '',
|
savedConfigs.value.push(c);
|
||||||
|
config.value = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
function duplicateConfig(oldName: string, newName: string) {
|
||||||
|
const c = {
|
||||||
|
name: newName,
|
||||||
pairlists: structuredClone(toRaw(config.value.pairlists)),
|
pairlists: structuredClone(toRaw(config.value.pairlists)),
|
||||||
};
|
};
|
||||||
|
savedConfigs.value.push(c);
|
||||||
|
config.value = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteConfig() {
|
function deleteConfig() {
|
||||||
|
@ -99,14 +107,6 @@ export const usePairlistConfigStore = defineStore(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function newConfig() {
|
|
||||||
config.value = { name: '', pairlists: [] };
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectConfig(selected: PairlistConfig) {
|
|
||||||
config.value = structuredClone(toRaw(selected));
|
|
||||||
}
|
|
||||||
|
|
||||||
function addToBlacklist() {
|
function addToBlacklist() {
|
||||||
blacklist.value.push('');
|
blacklist.value.push('');
|
||||||
}
|
}
|
||||||
|
@ -198,10 +198,9 @@ export const usePairlistConfigStore = defineStore(
|
||||||
startPairlistEvaluation,
|
startPairlistEvaluation,
|
||||||
addToConfig,
|
addToConfig,
|
||||||
removeFromConfig,
|
removeFromConfig,
|
||||||
saveConfig,
|
renameOrSaveConfig,
|
||||||
cloneConfig,
|
duplicateConfig,
|
||||||
deleteConfig,
|
deleteConfig,
|
||||||
selectConfig,
|
|
||||||
newConfig,
|
newConfig,
|
||||||
addToBlacklist,
|
addToBlacklist,
|
||||||
removeFromBlacklist,
|
removeFromBlacklist,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user