diff --git a/src/components/ftbot/ReloadControl.vue b/src/components/ftbot/ReloadControl.vue
index 1aed7c77..ad0e207d 100644
--- a/src/components/ftbot/ReloadControl.vue
+++ b/src/components/ftbot/ReloadControl.vue
@@ -15,8 +15,8 @@
diff --git a/src/components/layout/NavBar.vue b/src/components/layout/NavBar.vue
index 31e6bd59..cfdbd56d 100644
--- a/src/components/layout/NavBar.vue
+++ b/src/components/layout/NavBar.vue
@@ -6,6 +6,8 @@
Freqtrade UI
+
+
@@ -26,8 +28,10 @@
>
+
+
{{ botName || 'No bot selected' }}
@@ -81,13 +85,14 @@ import { BotStoreGetters } from '@/store/modules/ftbot';
import Favico from 'favico.js';
import { OpenTradeVizOptions, SettingsGetters } from '@/store/modules/settings';
import { MultiBotStoreGetters } from '@/store/modules/botStoreWrapper';
+import ReloadControl from '@/components/ftbot/ReloadControl.vue';
const ftbot = namespace('ftbot');
const layoutNs = namespace('layout');
const uiSettingsNs = namespace('uiSettings');
@Component({
- components: { LoginModal, BootswatchThemeSelect },
+ components: { LoginModal, BootswatchThemeSelect, ReloadControl },
})
export default class NavBar extends Vue {
pingInterval: number | null = null;
diff --git a/src/store/modules/botStoreWrapper.ts b/src/store/modules/botStoreWrapper.ts
index fc3fd6ec..d85baeaf 100644
--- a/src/store/modules/botStoreWrapper.ts
+++ b/src/store/modules/botStoreWrapper.ts
@@ -9,6 +9,8 @@ interface FTMultiBotState {
availableBots: BotDescriptors;
autoRefresh: boolean;
refreshing: boolean;
+ refreshInterval: number | null;
+ refreshIntervalSlow: number | null;
}
export enum MultiBotStoreGetters {
@@ -27,6 +29,8 @@ export default function createBotStore(store) {
availableBots: {},
autoRefresh: JSON.parse(localStorage.getItem(AUTO_REFRESH) || '{}'),
refreshing: false,
+ refreshInterval: null,
+ refreshIntervalSlow: null,
};
// All getters working on all bots should be prefixed with all.
@@ -91,6 +95,12 @@ export default function createBotStore(store) {
delete state.availableBots[botId];
}
},
+ setRefreshInterval(state: FTMultiBotState, interval: number | null) {
+ state.refreshInterval = interval;
+ },
+ setRefreshIntervalSlow(state: FTMultiBotState, interval: number | null) {
+ state.refreshIntervalSlow = interval;
+ },
};
const actions = {
@@ -125,8 +135,16 @@ export default function createBotStore(store) {
selectBot({ commit }, botId: string) {
commit('selectBot', botId);
},
- setAutoRefresh({ commit }, newRefreshValue) {
+ setAutoRefresh({ dispatch, commit }, newRefreshValue) {
+ 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 refreshAll({ dispatch, state, commit }, forceUpdate = false) {
@@ -177,6 +195,46 @@ export default function createBotStore(store) {
refreshOnce({ dispatch }) {
dispatch('getVersion');
},
+ startRefresh({ getters, state, dispatch, commit }, runNow: boolean) {
+ console.log('starting refresh');
+ // Start refresh timer
+ if (getters.hasBots !== true) {
+ console.log('Not logged in.');
+ return;
+ }
+ console.log('Starting automatic refresh.');
+ if (runNow) {
+ dispatch('refreshFrequent', false);
+ }
+ if (state.autoRefresh && !state.refreshInterval) {
+ // Set interval for refresh
+ const refreshInterval = window.setInterval(() => {
+ dispatch('refreshFrequent');
+ }, 5000);
+ commit('setRefreshInterval', refreshInterval);
+ }
+ if (runNow) {
+ dispatch('refreshSlow', true);
+ }
+ if (state.autoRefresh && !state.refreshIntervalSlow) {
+ const refreshIntervalSlow = window.setInterval(() => {
+ dispatch('refreshSlow', false);
+ }, 60000);
+ commit('setRefreshIntervalSlow', refreshIntervalSlow);
+ }
+ },
+ stopRefresh({ state, commit }: { state: FTMultiBotState; commit: any }) {
+ console.log('Stopping automatic refresh.');
+ if (state.refreshInterval) {
+ window.clearInterval(state.refreshInterval);
+ commit('setRefreshInterval', null);
+ }
+ if (state.refreshIntervalSlow) {
+ window.clearInterval(state.refreshIntervalSlow);
+ commit('setRefreshIntervalSlow', null);
+ }
+ },
+
pingAll({ getters, dispatch }) {
getters.allAvailableBotsList.forEach((e) => {
dispatch(`${e}/ping`);
diff --git a/src/views/Trading.vue b/src/views/Trading.vue
index 72b15097..f1994d80 100644
--- a/src/views/Trading.vue
+++ b/src/views/Trading.vue
@@ -18,8 +18,7 @@
drag-allow-from=".card-header"
>
-
-
+
-
+
+
+