Add Sysinfo endpoint

This commit is contained in:
Matthias 2021-10-09 15:17:53 +02:00
parent a24a93411e
commit 67cb1af105
3 changed files with 26 additions and 0 deletions

View File

@ -30,6 +30,7 @@ import {
PairHistory,
LogLine,
BacktestSteps,
SysInfoResponse,
} from '@/types';
import {
@ -70,6 +71,7 @@ export enum BotStoreGetters {
stakeCurrencyDecimals = 'stakeCurrencyDecimals',
strategyPlotConfig = 'strategyPlotConfig',
version = 'version',
sysinfo = 'sysinfo',
profit = 'profit',
botState = 'botState',
whitelist = 'whitelist',
@ -136,6 +138,7 @@ export enum BotStoreActions {
pollBacktest = 'pollBacktest',
removeBacktest = 'removeBacktest',
stopBacktest = 'stopBacktest',
sysInfo = 'sysInfo',
logout = 'logout',
}
@ -244,6 +247,9 @@ export function createBotSubStore(botId: string, botName: string) {
[BotStoreGetters.version](state: FtbotStateType): string {
return state.version;
},
[BotStoreGetters.version](state: FtbotStateType): SysInfoResponse | {} {
return state.sysinfo;
},
[BotStoreGetters.profit](state: FtbotStateType): ProfitInterface | {} {
return state.profit;
},
@ -423,6 +429,9 @@ export function createBotSubStore(botId: string, botName: string) {
setBacktestResultKey(state: FtbotStateType, key: string) {
state.selectedBacktestResultKey = key;
},
updateSysInfo(state, sysinfo: SysInfoResponse) {
state.sysinfo = sysinfo;
},
},
actions: {
[BotStoreActions.botAdded]({ commit }) {
@ -942,6 +951,15 @@ export function createBotSubStore(botId: string, botName: string) {
return Promise.reject(err);
}
},
async [BotStoreActions.sysInfo]({ commit }) {
try {
const result = await api.get('/sysinfo');
commit('updateSysInfo', result.data);
return Promise.resolve(result.data);
} catch (err) {
return Promise.reject(err);
}
},
},
};
}

View File

@ -14,6 +14,7 @@ import {
StrategyBacktestResult,
BacktestSteps,
LogLine,
SysInfoResponse,
} from '@/types';
export interface FtbotStateType {
@ -56,6 +57,7 @@ export interface FtbotStateType {
backtestResult?: BacktestResult;
selectedBacktestResultKey: string;
backtestHistory: Record<string, StrategyBacktestResult>;
sysinfo: SysInfoResponse | {};
}
const state = (): FtbotStateType => {
@ -98,6 +100,7 @@ const state = (): FtbotStateType => {
backtestResult: undefined,
selectedBacktestResultKey: '',
backtestHistory: {},
sysinfo: {},
};
};
export default state;

View File

@ -134,3 +134,8 @@ export interface PairHistory {
/** Data end date in as millisecond timestamp */
data_stop_ts: number;
}
export interface SysInfoResponse {
cpu_pct: number[];
ram_pct: number;
}