Fix online status

This commit is contained in:
Matthias 2022-04-21 20:18:28 +02:00
parent 0c731255ab
commit 70011435de
3 changed files with 8 additions and 8 deletions

View File

@ -4,7 +4,7 @@
<div class="align-items-center d-flex"> <div class="align-items-center d-flex">
<span class="ml-2 mr-1 align-middle">{{ <span class="ml-2 mr-1 align-middle">{{
botStore.availableBots[bot.botId] ? '&#128994;' : '&#128308;' botStore.botStores[bot.botId].isBotOnline ? '&#128994;' : '&#128308;'
}}</span> }}</span>
<b-form-checkbox <b-form-checkbox
v-model="autoRefreshLoc" v-model="autoRefreshLoc"

View File

@ -98,7 +98,7 @@ export function createBotSubStore(botId: string, botName: string) {
selectedBacktestResultKey: '', selectedBacktestResultKey: '',
backtestHistory: {} as Record<string, StrategyBacktestResult>, backtestHistory: {} as Record<string, StrategyBacktestResult>,
backtestHistoryList: [] as BacktestHistoryEntry[], backtestHistoryList: [] as BacktestHistoryEntry[],
sysinfo: {} as SysInfoResponse, sysInfo: {} as SysInfoResponse,
}; };
}, },
getters: { getters: {
@ -164,15 +164,16 @@ export function createBotSubStore(botId: string, botName: string) {
botAdded() { botAdded() {
this.autoRefresh = userService.getAutoRefresh(); this.autoRefresh = userService.getAutoRefresh();
}, },
async ping() { async fetchPing() {
try { try {
const result = await api.get('/ping'); const result = await api.get('/ping');
const now = Date.now(); const now = Date.now();
// TODO: Name collision! // TODO: Name collision!
// this.ping = `${result.data.status} ${now.toString()}`; this.ping = `${result.data.status} ${now.toString()}`;
this.isBotOnline = true; this.isBotOnline = true;
return Promise.resolve(); return Promise.resolve();
} catch (error) { } catch (error) {
console.log('ping fail');
this.isBotOnline = false; this.isBotOnline = false;
return Promise.reject(); return Promise.reject();
} }
@ -789,10 +790,9 @@ export function createBotSubStore(botId: string, botName: string) {
setBacktestResultKey(key: string) { setBacktestResultKey(key: string) {
this.selectedBacktestResultKey = key; this.selectedBacktestResultKey = key;
}, },
async sysInfo() { async getSysInfo() {
try { try {
// TODO: TYPE me const { data } = await api.get<SysInfoResponse>('/sysinfo');
const { data } = await api.get('/sysinfo');
this.sysInfo = data; this.sysInfo = data;
return Promise.resolve(data); return Promise.resolve(data);
} catch (err) { } catch (err) {

View File

@ -266,7 +266,7 @@ export const useBotStore = defineStore('wrapper', {
await Promise.all( await Promise.all(
Object.entries(this.botStores).map(async ([_, v]) => { Object.entries(this.botStores).map(async ([_, v]) => {
try { try {
await v.ping(); await v.fetchPing();
} catch { } catch {
// pass // pass
} }