mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-11 02:33:51 +00:00
pinia: Update BotList
This commit is contained in:
parent
fa5e039e8f
commit
02f73ed0d5
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
<div class="align-items-center d-flex">
|
<div class="align-items-center d-flex">
|
||||||
<span class="ml-2 mr-1 align-middle">{{
|
<span class="ml-2 mr-1 align-middle">{{
|
||||||
allIsBotOnline[bot.botId] ? '🟢' : '🔴'
|
botStore.availableBots[bot.botId] ? '🟢' : '🔴'
|
||||||
}}</span>
|
}}</span>
|
||||||
<b-form-checkbox
|
<b-form-checkbox
|
||||||
v-model="autoRefreshLoc"
|
v-model="autoRefreshLoc"
|
||||||
|
@ -29,13 +29,11 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { MultiBotStoreGetters } from '@/store/modules/botStoreWrapper';
|
|
||||||
import EditIcon from 'vue-material-design-icons/Pencil.vue';
|
import EditIcon from 'vue-material-design-icons/Pencil.vue';
|
||||||
import DeleteIcon from 'vue-material-design-icons/Delete.vue';
|
import DeleteIcon from 'vue-material-design-icons/Delete.vue';
|
||||||
import { BotDescriptor } from '@/types';
|
import { BotDescriptor } from '@/types';
|
||||||
import StoreModules from '@/store/storeSubModules';
|
|
||||||
import { defineComponent, computed } from '@vue/composition-api';
|
import { defineComponent, computed } from '@vue/composition-api';
|
||||||
import { useNamespacedActions, useNamespacedGetters, useStore } from 'vuex-composition-helpers';
|
import { useBotStore } from '@/stores/ftbotwrapper';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'BotEntry',
|
name: 'BotEntry',
|
||||||
|
@ -49,15 +47,10 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
emits: ['edit'],
|
emits: ['edit'],
|
||||||
setup(props, { root }) {
|
setup(props, { root }) {
|
||||||
const store = useStore();
|
const botStore = useBotStore();
|
||||||
const { allIsBotOnline, allAutoRefresh } = useNamespacedGetters(StoreModules.ftbot, [
|
|
||||||
MultiBotStoreGetters.allIsBotOnline,
|
|
||||||
MultiBotStoreGetters.allAutoRefresh,
|
|
||||||
]);
|
|
||||||
const { removeBot } = useNamespacedActions(StoreModules.ftbot, ['removeBot']);
|
|
||||||
|
|
||||||
const changeEvent = (v) => {
|
const changeEvent = (v) => {
|
||||||
store.dispatch(`ftbot/${props.bot.botId}/setAutoRefresh`, v);
|
botStore.botStores[props.bot.botId].setAutoRefresh(v);
|
||||||
};
|
};
|
||||||
|
|
||||||
const clickRemoveBot = (bot: BotDescriptor) => {
|
const clickRemoveBot = (bot: BotDescriptor) => {
|
||||||
|
@ -66,13 +59,13 @@ export default defineComponent({
|
||||||
.msgBoxConfirm(`Really remove (logout) from '${bot.botName}' (${bot.botId})?`)
|
.msgBoxConfirm(`Really remove (logout) from '${bot.botName}' (${bot.botId})?`)
|
||||||
.then((value: boolean) => {
|
.then((value: boolean) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
removeBot(bot.botId);
|
botStore.removeBot(bot.botId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const autoRefreshLoc = computed({
|
const autoRefreshLoc = computed({
|
||||||
get() {
|
get() {
|
||||||
return allAutoRefresh.value[props.bot.botId];
|
return botStore.botStores[props.bot.botId].autoRefresh;
|
||||||
},
|
},
|
||||||
set(_) {
|
set(_) {
|
||||||
// pass
|
// pass
|
||||||
|
@ -80,8 +73,7 @@ export default defineComponent({
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
allIsBotOnline,
|
botStore,
|
||||||
allAutoRefresh,
|
|
||||||
changeEvent,
|
changeEvent,
|
||||||
clickRemoveBot,
|
clickRemoveBot,
|
||||||
autoRefreshLoc,
|
autoRefreshLoc,
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="botCount > 0">
|
<div v-if="botStore.botCount > 0">
|
||||||
<h3 v-if="!small">Available bots</h3>
|
<h3 v-if="!small">Available bots</h3>
|
||||||
<b-list-group>
|
<b-list-group>
|
||||||
<b-list-group-item
|
<b-list-group-item
|
||||||
v-for="bot in allAvailableBots"
|
v-for="bot in botStore.availableBots"
|
||||||
:key="bot.botId"
|
:key="bot.botId"
|
||||||
:active="bot.botId === selectedBot"
|
:active="bot.botId === botStore.selectedBot"
|
||||||
button
|
button
|
||||||
:title="`${bot.botId} - ${bot.botName} - ${bot.botUrl}`"
|
:title="`${bot.botId} - ${bot.botName} - ${bot.botUrl}`"
|
||||||
@click="selectBot(bot.botId)"
|
@click="botStore.selectBot(bot.botId)"
|
||||||
>
|
>
|
||||||
<bot-rename
|
<bot-rename
|
||||||
v-if="editingBots.includes(bot.botId)"
|
v-if="editingBots.includes(bot.botId)"
|
||||||
|
@ -25,14 +25,14 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { MultiBotStoreGetters } from '@/store/modules/botStoreWrapper';
|
|
||||||
import LoginModal from '@/views/LoginModal.vue';
|
import LoginModal from '@/views/LoginModal.vue';
|
||||||
import BotEntry from '@/components/BotEntry.vue';
|
import BotEntry from '@/components/BotEntry.vue';
|
||||||
import BotRename from '@/components/BotRename.vue';
|
import BotRename from '@/components/BotRename.vue';
|
||||||
import StoreModules from '@/store/storeSubModules';
|
import StoreModules from '@/store/storeSubModules';
|
||||||
|
|
||||||
import { defineComponent, ref } from '@vue/composition-api';
|
import { defineComponent, ref } from '@vue/composition-api';
|
||||||
import { useNamespacedActions, useNamespacedGetters } from 'vuex-composition-helpers';
|
import { useNamespacedActions } from 'vuex-composition-helpers';
|
||||||
|
import { useBotStore } from '@/stores/ftbotwrapper';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'BotList',
|
name: 'BotList',
|
||||||
|
@ -41,15 +41,8 @@ export default defineComponent({
|
||||||
small: { default: false, type: Boolean },
|
small: { default: false, type: Boolean },
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const { botCount, selectedBot, allIsBotOnline, allAvailableBots } = useNamespacedGetters(
|
const botStore = useBotStore();
|
||||||
StoreModules.ftbot,
|
|
||||||
[
|
|
||||||
MultiBotStoreGetters.botCount,
|
|
||||||
MultiBotStoreGetters.selectedBot,
|
|
||||||
MultiBotStoreGetters.allIsBotOnline,
|
|
||||||
MultiBotStoreGetters.allAvailableBots,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
const { selectBot } = useNamespacedActions(StoreModules.ftbot, ['selectBot']);
|
const { selectBot } = useNamespacedActions(StoreModules.ftbot, ['selectBot']);
|
||||||
const editingBots = ref<string[]>([]);
|
const editingBots = ref<string[]>([]);
|
||||||
|
|
||||||
|
@ -68,10 +61,7 @@ export default defineComponent({
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
botCount,
|
botStore,
|
||||||
selectedBot,
|
|
||||||
allIsBotOnline,
|
|
||||||
allAvailableBots,
|
|
||||||
selectBot,
|
selectBot,
|
||||||
editingBots,
|
editingBots,
|
||||||
editBot,
|
editBot,
|
||||||
|
|
|
@ -25,9 +25,8 @@
|
||||||
import CheckIcon from 'vue-material-design-icons/Check.vue';
|
import CheckIcon from 'vue-material-design-icons/Check.vue';
|
||||||
import CloseIcon from 'vue-material-design-icons/Close.vue';
|
import CloseIcon from 'vue-material-design-icons/Close.vue';
|
||||||
import { BotDescriptor } from '@/types';
|
import { BotDescriptor } from '@/types';
|
||||||
import StoreModules from '@/store/storeSubModules';
|
|
||||||
import { defineComponent, ref } from '@vue/composition-api';
|
import { defineComponent, ref } from '@vue/composition-api';
|
||||||
import { useNamespacedActions } from 'vuex-composition-helpers';
|
import { useBotStore } from '@/stores/ftbotwrapper';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'BotRename',
|
name: 'BotRename',
|
||||||
|
@ -40,11 +39,12 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
emits: ['saved'],
|
emits: ['saved'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const { renameBot } = useNamespacedActions(StoreModules.ftbot, ['renameBot']);
|
const botStore = useBotStore();
|
||||||
|
|
||||||
const newName = ref<string>(props.bot.botName);
|
const newName = ref<string>(props.bot.botName);
|
||||||
|
|
||||||
const save = () => {
|
const save = () => {
|
||||||
renameBot({
|
botStore.renameBot({
|
||||||
botId: props.bot.botId,
|
botId: props.bot.botId,
|
||||||
botName: newName.value,
|
botName: newName.value,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user