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">
<span class="ml-2 mr-1 align-middle">{{
botStore.availableBots[bot.botId] ? '&#128994;' : '&#128308;'
botStore.botStores[bot.botId].isBotOnline ? '&#128994;' : '&#128308;'
}}</span>
<b-form-checkbox
v-model="autoRefreshLoc"

View File

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

View File

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