Conditionally show Trade OR backtest points

This commit is contained in:
Matthias 2021-04-24 20:01:37 +02:00
parent 916fd67f9c
commit 8a3451e4cf
3 changed files with 19 additions and 8 deletions

View File

@ -10,10 +10,10 @@
<b-collapse id="nav-collapse" is-nav>
<b-navbar-nav>
<b-nav-item to="/trade">Trade</b-nav-item>
<b-nav-item v-if="!canRunBacktest" to="/trade">Trade</b-nav-item>
<!-- <b-nav-item to="/graph">Graph</b-nav-item> -->
<b-nav-item to="/dashboard">Dashboard</b-nav-item>
<b-nav-item to="/backtest">Backtest</b-nav-item>
<b-nav-item v-if="!canRunBacktest" to="/dashboard">Dashboard</b-nav-item>
<b-nav-item v-if="canRunBacktest" to="/backtest">Backtest</b-nav-item>
<BootswatchThemeSelect />
</b-navbar-nav>
<!-- Right aligned nav items -->
@ -76,10 +76,14 @@ export default class NavBar extends Vue {
@ftbot.Action ping;
@ftbot.Action getState;
@ftbot.Getter [BotStoreGetters.botName]: string;
@ftbot.Getter [BotStoreGetters.openTradeCount]: number;
@ftbot.Getter [BotStoreGetters.canRunBacktest]!: boolean;
@layoutNs.Getter [LayoutGetters.getLayoutLocked]: boolean;
@layoutNs.Action [LayoutActions.resetDashboardLayout];
@ -95,6 +99,11 @@ export default class NavBar extends Vue {
mounted() {
this.ping();
this.pingInterval = window.setInterval(this.ping, 60000);
if (this.loggedIn) {
// Query botstate - this will enable / disable certain modes
this.getState();
}
}
beforeDestroy() {

View File

@ -51,6 +51,7 @@ export enum BotStoreGetters {
isWebserverMode = 'isWebserverMode',
refreshRequired = 'refreshRequired',
selectedBacktestResult = 'selectedBacktestResult',
canRunBacktest = 'canRunBacktest',
}
export default {
@ -116,6 +117,10 @@ export default {
[BotStoreGetters.selectedBacktestResult](state: FtbotStateType): StrategyBacktestResult {
return state.backtestHistory[state.selectedBacktestResultKey];
},
[BotStoreGetters.canRunBacktest](state: FtbotStateType): boolean {
/** Determines if bot runs in webserver mode */
return state.botState?.runmode === RunModes.WEBSERVER;
},
},
mutations: {
updateRefreshRequired(state: FtbotStateType, refreshRequired: boolean) {

View File

@ -274,7 +274,6 @@ import {
BotState,
PairHistoryPayload,
PlotConfig,
RunModes,
StrategyBacktestResult,
} from '@/types';
@ -357,6 +356,8 @@ export default class Backtesting extends Vue {
@ftbot.Getter [BotStoreGetters.selectedBacktestResult]!: StrategyBacktestResult;
@ftbot.Getter [BotStoreGetters.canRunBacktest]!: boolean;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@ftbot.Action getPairHistory!: (payload: PairHistoryPayload) => void;
@ -376,10 +377,6 @@ export default class Backtesting extends Vue {
formatPercent = formatPercent;
get canRunBacktest() {
return this.botState?.runmode === RunModes.WEBSERVER;
}
get hasBacktestResult() {
return this.backtestHistory ? Object.keys(this.backtestHistory).length !== 0 : false;
}