diff --git a/src/components/BotEntry.vue b/src/components/BotEntry.vue
index 124017ea..73c9e143 100644
--- a/src/components/BotEntry.vue
+++ b/src/components/BotEntry.vue
@@ -6,6 +6,15 @@
{{
allIsBotOnline[bot.botId] ? '🟢' : '🔴'
}}
+
+ R
+
@@ -37,12 +46,27 @@ export default class BotList extends Vue {
@ftbot.Getter [MultiBotStoreGetters.allIsBotOnline];
+ @ftbot.Getter [MultiBotStoreGetters.allAutoRefresh];
+
@ftbot.Getter [MultiBotStoreGetters.allAvailableBots]: BotDescriptors;
@ftbot.Action removeBot;
@ftbot.Action selectBot;
+ get autoRefreshLoc() {
+ return this.allAutoRefresh[this.bot.botId];
+ }
+
+ set autoRefreshLoc(v) {
+ // Dummy setter - Set via change event.
+ }
+
+ changeEvent(v) {
+ console.log('changeEvent', v);
+ this.$store.dispatch(`ftbot/${this.bot.botId}/setAutoRefresh`, v);
+ }
+
clickRemoveBot(bot: BotDescriptor) {
//
this.$bvModal
diff --git a/src/store/modules/botStoreWrapper.ts b/src/store/modules/botStoreWrapper.ts
index 02dc33a3..a7af5b62 100644
--- a/src/store/modules/botStoreWrapper.ts
+++ b/src/store/modules/botStoreWrapper.ts
@@ -7,7 +7,6 @@ const AUTO_REFRESH = 'ft_auto_refresh';
interface FTMultiBotState {
selectedBot: string;
availableBots: BotDescriptors;
- autoRefresh: boolean;
refreshing: boolean;
refreshInterval: number | null;
refreshIntervalSlow: number | null;
@@ -22,14 +21,13 @@ export enum MultiBotStoreGetters {
allAvailableBotsList = 'allAvailableBotsList',
allIsBotOnline = 'allIsBotOnline',
nextBotId = 'nextBotId',
- autoRefresh = 'autoRefresh',
+ allAutoRefresh = 'allAutoRefresh',
}
export default function createBotStore(store) {
const state: FTMultiBotState = {
selectedBot: '',
availableBots: {},
- autoRefresh: JSON.parse(localStorage.getItem(AUTO_REFRESH) || '{}'),
refreshing: false,
refreshInterval: null,
refreshIntervalSlow: null,
@@ -62,6 +60,13 @@ export default function createBotStore(store) {
});
return result;
},
+ [MultiBotStoreGetters.allAutoRefresh](state: FTMultiBotState, getters): {} {
+ const result = {};
+ getters.allAvailableBotsList.forEach((e) => {
+ result[e] = getters[`${e}/autoRefresh`];
+ });
+ return result;
+ },
[MultiBotStoreGetters.nextBotId](state: FTMultiBotState): string {
let botCount = Object.keys(state.availableBots).length;
@@ -70,9 +75,6 @@ export default function createBotStore(store) {
}
return `ftbot.${botCount}`;
},
- [MultiBotStoreGetters.autoRefresh](state: FTMultiBotState): boolean {
- return state.autoRefresh;
- },
};
// Autocreate getters from botStores
Object.keys(BotStoreGetters).forEach((e) => {
@@ -143,19 +145,6 @@ export default function createBotStore(store) {
selectBot({ commit }, botId: string) {
commit('selectBot', botId);
},
- setAutoRefresh({ dispatch, commit }, newRefreshValue) {
- // TODO: global autorefresh, or per subbot?
- console.log('setAutoRefresh', newRefreshValue);
- commit('setAutoRefresh', newRefreshValue);
- // TODO: Investigate this -
- // this ONLY works if ReloadControl is only visible once,otherwise it triggers twice
- if (newRefreshValue) {
- dispatch('startRefresh', true);
- } else {
- dispatch('stopRefresh');
- }
- localStorage.setItem(AUTO_REFRESH, JSON.stringify(newRefreshValue));
- },
async refreshFull({ dispatch, state, commit }, forceUpdate = false) {
if (state.refreshing) {
return;
diff --git a/src/store/modules/ftbot/index.ts b/src/store/modules/ftbot/index.ts
index 2b8efe66..3f1700eb 100644
--- a/src/store/modules/ftbot/index.ts
+++ b/src/store/modules/ftbot/index.ts
@@ -45,6 +45,7 @@ import { showAlert } from '../alerts';
export enum BotStoreGetters {
botName = 'botName',
isBotOnline = 'isBotOnline',
+ autoRefresh = 'autoRefresh',
openTrades = 'openTrades',
openTradeCount = 'openTradeCount',
tradeDetail = 'tradeDetail',
@@ -89,6 +90,8 @@ export enum BotStoreGetters {
export enum BotStoreActions {
ping = 'ping',
+ setIsBotOnline = 'setIsBotOnline',
+ setAutoRefresh = 'setAutoRefresh',
setRefreshRequired = 'setRefreshRequired',
refreshSlow = 'refreshSlow',
refreshFrequent = 'refreshFrequent',
@@ -146,6 +149,9 @@ export function createBotSubStore(botId: string) {
[BotStoreGetters.isBotOnline](state: FtbotStateType): boolean {
return state.isBotOnline;
},
+ [BotStoreGetters.autoRefresh](state: FtbotStateType): boolean {
+ return state.autoRefresh;
+ },
[BotStoreGetters.plotConfig](state: FtbotStateType) {
return state.customPlotConfig[state.plotConfigName] || { ...EMPTY_PLOTCONFIG };
},
@@ -292,6 +298,9 @@ export function createBotSubStore(botId: string) {
setIsBotOnline(state: FtbotStateType, isBotOnline: boolean) {
state.isBotOnline = isBotOnline;
},
+ setAutoRefresh(state: FtbotStateType, newRefreshValue: boolean) {
+ state.autoRefresh = newRefreshValue;
+ },
updateRefreshRequired(state: FtbotStateType, refreshRequired: boolean) {
state.refreshRequired = refreshRequired;
},
@@ -411,6 +420,17 @@ export function createBotSubStore(botId: string) {
[BotStoreActions.setRefreshRequired]({ commit }, refreshRequired: boolean) {
commit('updateRefreshRequired', refreshRequired);
},
+ [BotStoreActions.setAutoRefresh]({ dispatch, commit }, newRefreshValue) {
+ // commit('setAutoRefresh', newRefreshValue);
+ // TODO: Investigate this -
+ // this ONLY works if ReloadControl is only visible once,otherwise it triggers twice
+ if (newRefreshValue) {
+ // dispatch('startRefresh', true);
+ } else {
+ // dispatch('stopRefresh');
+ }
+ userService.setAutoRefresh(newRefreshValue);
+ },
[BotStoreActions.setIsBotOnline]({ commit }, refreshRequired: boolean) {
commit('setIsBotOnline', refreshRequired);
},
diff --git a/src/store/modules/ftbot/state.ts b/src/store/modules/ftbot/state.ts
index 62080af7..f08c0378 100644
--- a/src/store/modules/ftbot/state.ts
+++ b/src/store/modules/ftbot/state.ts
@@ -19,6 +19,7 @@ import {
export interface FtbotStateType {
ping: string;
isBotOnline: boolean;
+ autoRefresh: boolean;
version: string;
lastLogs: LogLine[];
refreshRequired: boolean;
@@ -60,6 +61,7 @@ const state = (): FtbotStateType => {
return {
ping: '',
isBotOnline: false,
+ autoRefresh: false,
version: '',
lastLogs: [],
refreshRequired: true,