mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-23 11:35:14 +00:00
Move autoRefresh to single bot stores
This commit is contained in:
parent
10d13d788e
commit
76eff0dc4b
|
@ -6,6 +6,15 @@
|
||||||
<span class="ml-2 align-middle">{{
|
<span class="ml-2 align-middle">{{
|
||||||
allIsBotOnline[bot.botId] ? '🟢' : '🔴'
|
allIsBotOnline[bot.botId] ? '🟢' : '🔴'
|
||||||
}}</span>
|
}}</span>
|
||||||
|
<b-form-checkbox
|
||||||
|
v-model="autoRefreshLoc"
|
||||||
|
class="ml-auto float-right mr-2 my-auto"
|
||||||
|
title="AutoRefresh"
|
||||||
|
variant="secondary"
|
||||||
|
@change="changeEvent"
|
||||||
|
>
|
||||||
|
R
|
||||||
|
</b-form-checkbox>
|
||||||
<div v-if="!noButtons" class="d-flex flex-align-cent">
|
<div v-if="!noButtons" class="d-flex flex-align-cent">
|
||||||
<b-button class="ml-1" size="sm" title="Edit bot" @click="clickRemoveBot(bot)">
|
<b-button class="ml-1" size="sm" title="Edit bot" @click="clickRemoveBot(bot)">
|
||||||
<EditIcon :size="16" title="Edit Button" />
|
<EditIcon :size="16" title="Edit Button" />
|
||||||
|
@ -37,12 +46,27 @@ export default class BotList extends Vue {
|
||||||
|
|
||||||
@ftbot.Getter [MultiBotStoreGetters.allIsBotOnline];
|
@ftbot.Getter [MultiBotStoreGetters.allIsBotOnline];
|
||||||
|
|
||||||
|
@ftbot.Getter [MultiBotStoreGetters.allAutoRefresh];
|
||||||
|
|
||||||
@ftbot.Getter [MultiBotStoreGetters.allAvailableBots]: BotDescriptors;
|
@ftbot.Getter [MultiBotStoreGetters.allAvailableBots]: BotDescriptors;
|
||||||
|
|
||||||
@ftbot.Action removeBot;
|
@ftbot.Action removeBot;
|
||||||
|
|
||||||
@ftbot.Action selectBot;
|
@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) {
|
clickRemoveBot(bot: BotDescriptor) {
|
||||||
//
|
//
|
||||||
this.$bvModal
|
this.$bvModal
|
||||||
|
|
|
@ -7,7 +7,6 @@ const AUTO_REFRESH = 'ft_auto_refresh';
|
||||||
interface FTMultiBotState {
|
interface FTMultiBotState {
|
||||||
selectedBot: string;
|
selectedBot: string;
|
||||||
availableBots: BotDescriptors;
|
availableBots: BotDescriptors;
|
||||||
autoRefresh: boolean;
|
|
||||||
refreshing: boolean;
|
refreshing: boolean;
|
||||||
refreshInterval: number | null;
|
refreshInterval: number | null;
|
||||||
refreshIntervalSlow: number | null;
|
refreshIntervalSlow: number | null;
|
||||||
|
@ -22,14 +21,13 @@ export enum MultiBotStoreGetters {
|
||||||
allAvailableBotsList = 'allAvailableBotsList',
|
allAvailableBotsList = 'allAvailableBotsList',
|
||||||
allIsBotOnline = 'allIsBotOnline',
|
allIsBotOnline = 'allIsBotOnline',
|
||||||
nextBotId = 'nextBotId',
|
nextBotId = 'nextBotId',
|
||||||
autoRefresh = 'autoRefresh',
|
allAutoRefresh = 'allAutoRefresh',
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function createBotStore(store) {
|
export default function createBotStore(store) {
|
||||||
const state: FTMultiBotState = {
|
const state: FTMultiBotState = {
|
||||||
selectedBot: '',
|
selectedBot: '',
|
||||||
availableBots: {},
|
availableBots: {},
|
||||||
autoRefresh: JSON.parse(localStorage.getItem(AUTO_REFRESH) || '{}'),
|
|
||||||
refreshing: false,
|
refreshing: false,
|
||||||
refreshInterval: null,
|
refreshInterval: null,
|
||||||
refreshIntervalSlow: null,
|
refreshIntervalSlow: null,
|
||||||
|
@ -62,6 +60,13 @@ export default function createBotStore(store) {
|
||||||
});
|
});
|
||||||
return result;
|
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 {
|
[MultiBotStoreGetters.nextBotId](state: FTMultiBotState): string {
|
||||||
let botCount = Object.keys(state.availableBots).length;
|
let botCount = Object.keys(state.availableBots).length;
|
||||||
|
|
||||||
|
@ -70,9 +75,6 @@ export default function createBotStore(store) {
|
||||||
}
|
}
|
||||||
return `ftbot.${botCount}`;
|
return `ftbot.${botCount}`;
|
||||||
},
|
},
|
||||||
[MultiBotStoreGetters.autoRefresh](state: FTMultiBotState): boolean {
|
|
||||||
return state.autoRefresh;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
// Autocreate getters from botStores
|
// Autocreate getters from botStores
|
||||||
Object.keys(BotStoreGetters).forEach((e) => {
|
Object.keys(BotStoreGetters).forEach((e) => {
|
||||||
|
@ -143,19 +145,6 @@ export default function createBotStore(store) {
|
||||||
selectBot({ commit }, botId: string) {
|
selectBot({ commit }, botId: string) {
|
||||||
commit('selectBot', botId);
|
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) {
|
async refreshFull({ dispatch, state, commit }, forceUpdate = false) {
|
||||||
if (state.refreshing) {
|
if (state.refreshing) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -45,6 +45,7 @@ import { showAlert } from '../alerts';
|
||||||
export enum BotStoreGetters {
|
export enum BotStoreGetters {
|
||||||
botName = 'botName',
|
botName = 'botName',
|
||||||
isBotOnline = 'isBotOnline',
|
isBotOnline = 'isBotOnline',
|
||||||
|
autoRefresh = 'autoRefresh',
|
||||||
openTrades = 'openTrades',
|
openTrades = 'openTrades',
|
||||||
openTradeCount = 'openTradeCount',
|
openTradeCount = 'openTradeCount',
|
||||||
tradeDetail = 'tradeDetail',
|
tradeDetail = 'tradeDetail',
|
||||||
|
@ -89,6 +90,8 @@ export enum BotStoreGetters {
|
||||||
|
|
||||||
export enum BotStoreActions {
|
export enum BotStoreActions {
|
||||||
ping = 'ping',
|
ping = 'ping',
|
||||||
|
setIsBotOnline = 'setIsBotOnline',
|
||||||
|
setAutoRefresh = 'setAutoRefresh',
|
||||||
setRefreshRequired = 'setRefreshRequired',
|
setRefreshRequired = 'setRefreshRequired',
|
||||||
refreshSlow = 'refreshSlow',
|
refreshSlow = 'refreshSlow',
|
||||||
refreshFrequent = 'refreshFrequent',
|
refreshFrequent = 'refreshFrequent',
|
||||||
|
@ -146,6 +149,9 @@ export function createBotSubStore(botId: string) {
|
||||||
[BotStoreGetters.isBotOnline](state: FtbotStateType): boolean {
|
[BotStoreGetters.isBotOnline](state: FtbotStateType): boolean {
|
||||||
return state.isBotOnline;
|
return state.isBotOnline;
|
||||||
},
|
},
|
||||||
|
[BotStoreGetters.autoRefresh](state: FtbotStateType): boolean {
|
||||||
|
return state.autoRefresh;
|
||||||
|
},
|
||||||
[BotStoreGetters.plotConfig](state: FtbotStateType) {
|
[BotStoreGetters.plotConfig](state: FtbotStateType) {
|
||||||
return state.customPlotConfig[state.plotConfigName] || { ...EMPTY_PLOTCONFIG };
|
return state.customPlotConfig[state.plotConfigName] || { ...EMPTY_PLOTCONFIG };
|
||||||
},
|
},
|
||||||
|
@ -292,6 +298,9 @@ export function createBotSubStore(botId: string) {
|
||||||
setIsBotOnline(state: FtbotStateType, isBotOnline: boolean) {
|
setIsBotOnline(state: FtbotStateType, isBotOnline: boolean) {
|
||||||
state.isBotOnline = isBotOnline;
|
state.isBotOnline = isBotOnline;
|
||||||
},
|
},
|
||||||
|
setAutoRefresh(state: FtbotStateType, newRefreshValue: boolean) {
|
||||||
|
state.autoRefresh = newRefreshValue;
|
||||||
|
},
|
||||||
updateRefreshRequired(state: FtbotStateType, refreshRequired: boolean) {
|
updateRefreshRequired(state: FtbotStateType, refreshRequired: boolean) {
|
||||||
state.refreshRequired = refreshRequired;
|
state.refreshRequired = refreshRequired;
|
||||||
},
|
},
|
||||||
|
@ -411,6 +420,17 @@ export function createBotSubStore(botId: string) {
|
||||||
[BotStoreActions.setRefreshRequired]({ commit }, refreshRequired: boolean) {
|
[BotStoreActions.setRefreshRequired]({ commit }, refreshRequired: boolean) {
|
||||||
commit('updateRefreshRequired', refreshRequired);
|
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) {
|
[BotStoreActions.setIsBotOnline]({ commit }, refreshRequired: boolean) {
|
||||||
commit('setIsBotOnline', refreshRequired);
|
commit('setIsBotOnline', refreshRequired);
|
||||||
},
|
},
|
||||||
|
|
|
@ -19,6 +19,7 @@ import {
|
||||||
export interface FtbotStateType {
|
export interface FtbotStateType {
|
||||||
ping: string;
|
ping: string;
|
||||||
isBotOnline: boolean;
|
isBotOnline: boolean;
|
||||||
|
autoRefresh: boolean;
|
||||||
version: string;
|
version: string;
|
||||||
lastLogs: LogLine[];
|
lastLogs: LogLine[];
|
||||||
refreshRequired: boolean;
|
refreshRequired: boolean;
|
||||||
|
@ -60,6 +61,7 @@ const state = (): FtbotStateType => {
|
||||||
return {
|
return {
|
||||||
ping: '',
|
ping: '',
|
||||||
isBotOnline: false,
|
isBotOnline: false,
|
||||||
|
autoRefresh: false,
|
||||||
version: '',
|
version: '',
|
||||||
lastLogs: [],
|
lastLogs: [],
|
||||||
refreshRequired: true,
|
refreshRequired: true,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user