mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-23 19:45:15 +00:00
Update Online visualization
This commit is contained in:
parent
cb8d0af126
commit
9ba4f7a70b
|
@ -40,6 +40,7 @@ export default class ReloadControl extends Vue {
|
||||||
this.stopRefresh();
|
this.stopRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO-multi: This should be per bot!
|
||||||
@Getter loggedIn;
|
@Getter loggedIn;
|
||||||
|
|
||||||
@State autoRefresh!: boolean;
|
@State autoRefresh!: boolean;
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
{{ isBotOnline ? 'Online' : 'Offline' }}
|
{{ isBotOnline ? 'Online' : 'Offline' }}
|
||||||
</b-nav-text>
|
</b-nav-text>
|
||||||
</li>
|
</li>
|
||||||
<li v-if="loggedIn" class="nav-item">
|
<li v-if="hasBots" class="nav-item">
|
||||||
<b-nav-item-dropdown right>
|
<b-nav-item-dropdown right>
|
||||||
<b-dropdown-item>V: {{ getUiVersion }}</b-dropdown-item>
|
<b-dropdown-item>V: {{ getUiVersion }}</b-dropdown-item>
|
||||||
<template #button-content>
|
<template #button-content>
|
||||||
|
@ -63,12 +63,13 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue, Watch } from 'vue-property-decorator';
|
import { Component, Vue, Watch } from 'vue-property-decorator';
|
||||||
import LoginModal from '@/views/LoginModal.vue';
|
import LoginModal from '@/views/LoginModal.vue';
|
||||||
import { State, Action, namespace, Getter } from 'vuex-class';
|
import { Action, namespace, Getter } from 'vuex-class';
|
||||||
import BootswatchThemeSelect from '@/components/BootswatchThemeSelect.vue';
|
import BootswatchThemeSelect from '@/components/BootswatchThemeSelect.vue';
|
||||||
import { LayoutActions, LayoutGetters } from '@/store/modules/layout';
|
import { LayoutActions, LayoutGetters } from '@/store/modules/layout';
|
||||||
import { BotStoreGetters } from '@/store/modules/ftbot';
|
import { BotStoreGetters } from '@/store/modules/ftbot';
|
||||||
import Favico from 'favico.js';
|
import Favico from 'favico.js';
|
||||||
import { OpenTradeVizOptions, SettingsGetters } from '@/store/modules/settings';
|
import { OpenTradeVizOptions, SettingsGetters } from '@/store/modules/settings';
|
||||||
|
import { MultiBotStoreGetters } from '@/store/modules/botStoreWrapper';
|
||||||
|
|
||||||
const ftbot = namespace('ftbot');
|
const ftbot = namespace('ftbot');
|
||||||
const layoutNs = namespace('layout');
|
const layoutNs = namespace('layout');
|
||||||
|
@ -80,10 +81,6 @@ const uiSettingsNs = namespace('uiSettings');
|
||||||
export default class NavBar extends Vue {
|
export default class NavBar extends Vue {
|
||||||
pingInterval: number | null = null;
|
pingInterval: number | null = null;
|
||||||
|
|
||||||
@State loggedIn!: boolean;
|
|
||||||
|
|
||||||
@State isBotOnline!: boolean;
|
|
||||||
|
|
||||||
@Action setLoggedIn;
|
@Action setLoggedIn;
|
||||||
|
|
||||||
@Action loadUIVersion;
|
@Action loadUIVersion;
|
||||||
|
@ -96,6 +93,10 @@ export default class NavBar extends Vue {
|
||||||
|
|
||||||
@ftbot.Action logout;
|
@ftbot.Action logout;
|
||||||
|
|
||||||
|
@ftbot.Getter [BotStoreGetters.isBotOnline]!: boolean;
|
||||||
|
|
||||||
|
@ftbot.Getter [MultiBotStoreGetters.hasBots]: boolean;
|
||||||
|
|
||||||
@ftbot.Getter [BotStoreGetters.botName]: string;
|
@ftbot.Getter [BotStoreGetters.botName]: string;
|
||||||
|
|
||||||
@ftbot.Getter [BotStoreGetters.openTradeCount]: number;
|
@ftbot.Getter [BotStoreGetters.openTradeCount]: number;
|
||||||
|
@ -119,7 +120,7 @@ export default class NavBar extends Vue {
|
||||||
this.loadUIVersion();
|
this.loadUIVersion();
|
||||||
this.pingInterval = window.setInterval(this.ping, 60000);
|
this.pingInterval = window.setInterval(this.ping, 60000);
|
||||||
|
|
||||||
if (this.loggedIn) {
|
if (this.hasBots) {
|
||||||
// Query botstate - this will enable / disable certain modes
|
// Query botstate - this will enable / disable certain modes
|
||||||
this.getState();
|
this.getState();
|
||||||
}
|
}
|
||||||
|
@ -133,6 +134,7 @@ export default class NavBar extends Vue {
|
||||||
|
|
||||||
clickLogout(): void {
|
clickLogout(): void {
|
||||||
this.logout();
|
this.logout();
|
||||||
|
// TODO: This should be per bot
|
||||||
this.setLoggedIn(false);
|
this.setLoggedIn(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import Vuex from 'vuex';
|
import Vuex from 'vuex';
|
||||||
|
|
||||||
import userService from '@/shared/userService';
|
|
||||||
import { getCurrentTheme, getTheme, storeCurrentTheme } from '@/shared/themes';
|
import { getCurrentTheme, getTheme, storeCurrentTheme } from '@/shared/themes';
|
||||||
import axios, { AxiosInstance } from 'axios';
|
import axios, { AxiosInstance } from 'axios';
|
||||||
import createBotStore from './modules/botStoreWrapper';
|
import createBotStore from './modules/botStoreWrapper';
|
||||||
|
@ -22,11 +21,8 @@ const store = new Vuex.Store({
|
||||||
uiSettings: settingsModule,
|
uiSettings: settingsModule,
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
ping: '',
|
|
||||||
loggedIn: userService.loggedIn(),
|
|
||||||
refreshing: false,
|
refreshing: false,
|
||||||
autoRefresh: JSON.parse(localStorage.getItem(AUTO_REFRESH) || '{}'),
|
autoRefresh: JSON.parse(localStorage.getItem(AUTO_REFRESH) || '{}'),
|
||||||
isBotOnline: false,
|
|
||||||
currentTheme: initCurrentTheme,
|
currentTheme: initCurrentTheme,
|
||||||
uiVersion: 'dev',
|
uiVersion: 'dev',
|
||||||
},
|
},
|
||||||
|
@ -44,25 +40,18 @@ const store = new Vuex.Store({
|
||||||
getUiVersion(state) {
|
getUiVersion(state) {
|
||||||
return state.uiVersion;
|
return state.uiVersion;
|
||||||
},
|
},
|
||||||
|
loggedIn(state, getters) {
|
||||||
|
return getters['ftbot/hasBots'];
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
setPing(state, ping) {
|
|
||||||
// console.log(ping);
|
|
||||||
const now = Date.now();
|
|
||||||
state.ping = `${ping.status} ${now.toString()}`;
|
|
||||||
},
|
|
||||||
setLoggedIn(state, loggedin: boolean) {
|
|
||||||
state.loggedIn = loggedin;
|
|
||||||
},
|
|
||||||
setAutoRefresh(state, newRefreshValue: boolean) {
|
setAutoRefresh(state, newRefreshValue: boolean) {
|
||||||
state.autoRefresh = newRefreshValue;
|
state.autoRefresh = newRefreshValue;
|
||||||
},
|
},
|
||||||
setRefreshing(state, refreshing: boolean) {
|
setRefreshing(state, refreshing: boolean) {
|
||||||
state.refreshing = refreshing;
|
state.refreshing = refreshing;
|
||||||
},
|
},
|
||||||
setIsBotOnline(state, isBotOnline: boolean) {
|
|
||||||
state.isBotOnline = isBotOnline;
|
|
||||||
},
|
|
||||||
mutateCurrentTheme(state, newTheme: string) {
|
mutateCurrentTheme(state, newTheme: string) {
|
||||||
storeCurrentTheme(newTheme);
|
storeCurrentTheme(newTheme);
|
||||||
state.currentTheme = newTheme;
|
state.currentTheme = newTheme;
|
||||||
|
|
|
@ -5,6 +5,12 @@ interface FTMultiBotState {
|
||||||
availableBots: string[];
|
availableBots: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum MultiBotStoreGetters {
|
||||||
|
hasBots = 'hasBots',
|
||||||
|
selectedBot = 'selectedBot',
|
||||||
|
allAvailableBots = 'allAvailableBots',
|
||||||
|
}
|
||||||
|
|
||||||
export default function createBotStore(store) {
|
export default function createBotStore(store) {
|
||||||
const state: FTMultiBotState = {
|
const state: FTMultiBotState = {
|
||||||
selectedBot: 'ftbot.0',
|
selectedBot: 'ftbot.0',
|
||||||
|
@ -13,13 +19,13 @@ export default function createBotStore(store) {
|
||||||
|
|
||||||
// All getters working on all bots should be prefixed with all.
|
// All getters working on all bots should be prefixed with all.
|
||||||
const getters = {
|
const getters = {
|
||||||
hasBots(state: FTMultiBotState): boolean {
|
[MultiBotStoreGetters.hasBots](state: FTMultiBotState): boolean {
|
||||||
return state.availableBots.length > 0;
|
return state.availableBots.length > 0;
|
||||||
},
|
},
|
||||||
selectedBot(state: FTMultiBotState): string {
|
[MultiBotStoreGetters.selectedBot](state: FTMultiBotState): string {
|
||||||
return state.selectedBot;
|
return state.selectedBot;
|
||||||
},
|
},
|
||||||
allAvailableBots(state: FTMultiBotState): string[] {
|
[MultiBotStoreGetters.allAvailableBots](state: FTMultiBotState): string[] {
|
||||||
return state.availableBots;
|
return state.availableBots;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,6 +43,7 @@ import { showAlert } from '../alerts';
|
||||||
|
|
||||||
export enum BotStoreGetters {
|
export enum BotStoreGetters {
|
||||||
botName = 'botName',
|
botName = 'botName',
|
||||||
|
isBotOnline = 'isBotOnline',
|
||||||
openTrades = 'openTrades',
|
openTrades = 'openTrades',
|
||||||
openTradeCount = 'openTradeCount',
|
openTradeCount = 'openTradeCount',
|
||||||
tradeDetail = 'tradeDetail',
|
tradeDetail = 'tradeDetail',
|
||||||
|
@ -137,6 +138,9 @@ export function createBotSubStore(botId: string) {
|
||||||
[BotStoreGetters.botName](state: FtbotStateType) {
|
[BotStoreGetters.botName](state: FtbotStateType) {
|
||||||
return state.botState?.bot_name || 'freqtrade';
|
return state.botState?.bot_name || 'freqtrade';
|
||||||
},
|
},
|
||||||
|
[BotStoreGetters.isBotOnline](state: FtbotStateType): boolean {
|
||||||
|
return state.isBotOnline;
|
||||||
|
},
|
||||||
[BotStoreGetters.plotConfig](state: FtbotStateType) {
|
[BotStoreGetters.plotConfig](state: FtbotStateType) {
|
||||||
return state.customPlotConfig[state.plotConfigName] || { ...EMPTY_PLOTCONFIG };
|
return state.customPlotConfig[state.plotConfigName] || { ...EMPTY_PLOTCONFIG };
|
||||||
},
|
},
|
||||||
|
@ -276,6 +280,13 @@ export function createBotSubStore(botId: string) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
|
setPing(state: FtbotStateType, ping) {
|
||||||
|
const now = Date.now();
|
||||||
|
state.ping = `${ping.status} ${now.toString()}`;
|
||||||
|
},
|
||||||
|
setIsBotOnline(state: FtbotStateType, isBotOnline: boolean) {
|
||||||
|
state.isBotOnline = isBotOnline;
|
||||||
|
},
|
||||||
updateRefreshRequired(state: FtbotStateType, refreshRequired: boolean) {
|
updateRefreshRequired(state: FtbotStateType, refreshRequired: boolean) {
|
||||||
state.refreshRequired = refreshRequired;
|
state.refreshRequired = refreshRequired;
|
||||||
},
|
},
|
||||||
|
@ -380,16 +391,14 @@ export function createBotSubStore(botId: string) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
[BotStoreActions.ping]({ commit, rootState }) {
|
[BotStoreActions.ping]({ commit }) {
|
||||||
if (rootState.loggedIn) {
|
|
||||||
api
|
api
|
||||||
.get('/ping')
|
.get('/ping')
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
commit('setPing', result.data, { root: true });
|
commit('setPing', result.data);
|
||||||
commit('setIsBotOnline', result.data, { root: true });
|
commit('setIsBotOnline', true);
|
||||||
})
|
})
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[BotStoreActions.logout]() {
|
[BotStoreActions.logout]() {
|
||||||
userService.logout();
|
userService.logout();
|
||||||
|
|
|
@ -17,6 +17,8 @@ import {
|
||||||
} from '@/types';
|
} from '@/types';
|
||||||
|
|
||||||
export interface FtbotStateType {
|
export interface FtbotStateType {
|
||||||
|
ping: string;
|
||||||
|
isBotOnline: boolean;
|
||||||
version: string;
|
version: string;
|
||||||
lastLogs: LogLine[];
|
lastLogs: LogLine[];
|
||||||
refreshRequired: boolean;
|
refreshRequired: boolean;
|
||||||
|
@ -56,6 +58,8 @@ export interface FtbotStateType {
|
||||||
|
|
||||||
const state = (): FtbotStateType => {
|
const state = (): FtbotStateType => {
|
||||||
return {
|
return {
|
||||||
|
ping: '',
|
||||||
|
isBotOnline: false,
|
||||||
version: '',
|
version: '',
|
||||||
lastLogs: [],
|
lastLogs: [],
|
||||||
refreshRequired: true,
|
refreshRequired: true,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user