diff --git a/src/components/Login.vue b/src/components/Login.vue index 2e42e984..ab40725c 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -75,12 +75,10 @@ import { useUserService } from '@/shared/userService'; import { AuthPayload } from '@/types'; -import { MultiBotStoreGetters } from '@/store/modules/botStoreWrapper'; -import StoreModules from '@/store/storeSubModules'; import { defineComponent, ref } from '@vue/composition-api'; -import { useActions, useNamespacedActions, useNamespacedGetters } from 'vuex-composition-helpers'; import { useRouter, useRoute } from 'vue2-helpers/vue-router'; +import { useBotStore } from '@/stores/ftbotwrapper'; const defaultURL = window.location.origin || 'http://localhost:3000'; @@ -93,15 +91,7 @@ export default defineComponent({ setup(props, { emit }) { const router = useRouter(); const route = useRoute(); - const { nextBotId, selectedBot } = useNamespacedGetters(StoreModules.ftbot, [ - MultiBotStoreGetters.nextBotId, - MultiBotStoreGetters.selectedBot, - ]); - const { addBot, selectBot, allRefreshFull } = useNamespacedActions(StoreModules.ftbot, [ - 'addBot', - 'selectBot', - 'allRefreshFull', - ]); + const botStore = useBotStore(); const nameState = ref(); const pwdState = ref(); @@ -147,24 +137,24 @@ export default defineComponent({ return; } errorMessage.value = ''; - const userService = useUserService(nextBotId.value); + const userService = useUserService(botStore.nextBotId); // Push the name to submitted names userService .login(auth.value) .then(() => { - const botId = nextBotId.value; - addBot({ + const botId = botStore.nextBotId; + botStore.addBot({ botName: auth.value.botName, botId, botUrl: auth.value.url, }); - if (selectedBot.value === '') { + if (botStore.selectedBot === '') { console.log(`selecting bot ${botId}`); - selectBot(botId); + botStore.selectBot(botId); } emitLoginResult(true); - allRefreshFull(); + botStore.allRefreshFull(); if (props.inModal === false) { if (typeof route?.query.redirect === 'string') { const resolved = router.resolve({ path: route.query.redirect }); @@ -181,7 +171,7 @@ export default defineComponent({ .catch((error) => { errorMessageCORS.value = false; // this.nameState = false; - console.error(error.response); + console.error(error); if (error.response && error.response.status === 401) { nameState.value = false; pwdState.value = false; diff --git a/src/components/charts/PlotConfigurator.vue b/src/components/charts/PlotConfigurator.vue index 95b33baa..8f1057be 100644 --- a/src/components/charts/PlotConfigurator.vue +++ b/src/components/charts/PlotConfigurator.vue @@ -123,11 +123,10 @@ import { PlotConfig, EMPTY_PLOTCONFIG, IndicatorConfig } from '@/types'; import { getCustomPlotConfig } from '@/shared/storage'; import PlotIndicator from '@/components/charts/PlotIndicator.vue'; -import StoreModules from '@/store/storeSubModules'; import { showAlert } from '@/stores/alerts'; import { defineComponent, computed, ref, watch, onMounted } from '@vue/composition-api'; -import { useNamespacedActions, useNamespacedGetters } from 'vuex-composition-helpers'; +import { useBotStore } from '@/stores/ftbotwrapper'; export default defineComponent({ name: 'PlotConfigurator', @@ -139,25 +138,12 @@ export default defineComponent({ }, emits: ['input'], setup(props, { emit }) { - const { getStrategyPlotConfig, saveCustomPlotConfig, updatePlotConfigName } = - useNamespacedActions(StoreModules.ftbot, [ - 'getStrategyPlotConfig', - 'saveCustomPlotConfig', - 'updatePlotConfigName', - ]); - const { strategyPlotConfig, plotConfigName } = useNamespacedGetters(StoreModules.ftbot, [ - 'strategyPlotConfig', - 'plotConfigName', - ]); + const botStore = useBotStore(); + const plotConfig = ref(EMPTY_PLOTCONFIG); - const plotOptions = [ - { text: 'Main Plot', value: 'main_plot' }, - { text: 'Subplots', value: 'subplots' }, - ]; const plotConfigNameLoc = ref('default'); const newSubplotName = ref(''); - const selAvailableIndicator = ref(''); const selIndicatorName = ref(''); const addNewIndicator = ref(false); const showConfig = ref(false); @@ -302,9 +288,11 @@ export default defineComponent({ }; const loadPlotConfigFromStrategy = async () => { try { - await getStrategyPlotConfig(); - plotConfig.value = strategyPlotConfig.value; - emit('input', plotConfig.value); + await botStore.activeBot.getStrategyPlotConfig(); + if (botStore.activeBot.strategyPlotConfig) { + plotConfig.value = botStore.activeBot.strategyPlotConfig; + emit('input', plotConfig.value); + } } catch (data) { // showAlert('Failed to load Plot configuration from Strategy.'); @@ -312,27 +300,23 @@ export default defineComponent({ }; const savePlotConfig = () => { - saveCustomPlotConfig({ [plotConfigNameLoc.value]: plotConfig.value }); + botStore.activeBot.saveCustomPlotConfig({ [plotConfigNameLoc.value]: plotConfig.value }); }; watch(props.value, () => { console.log('config value'); plotConfig.value = props.value; - plotConfigNameLoc.value = plotConfigName.value; + plotConfigNameLoc.value = botStore.activeBot.plotConfigName; }); onMounted(() => { console.log('Config Mounted', props.value); plotConfig.value = props.value; - plotConfigNameLoc.value = plotConfigName.value; + plotConfigNameLoc.value = botStore.activeBot.plotConfigName; }); return { - saveCustomPlotConfig, - getStrategyPlotConfig, - updatePlotConfigName, - strategyPlotConfig, - plotConfigName, + botStore, addIndicator, removeIndicator, addSubplot, diff --git a/src/components/ftbot/BotControls.vue b/src/components/ftbot/BotControls.vue index 049a21b1..6e582f90 100644 --- a/src/components/ftbot/BotControls.vue +++ b/src/components/ftbot/BotControls.vue @@ -2,7 +2,7 @@