mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-26 04:55:15 +00:00
Add "logged out" state to BotEntry
This commit is contained in:
parent
70b348e3f1
commit
a4aa87aed8
|
@ -12,11 +12,17 @@
|
|||
@change="changeEvent"
|
||||
>
|
||||
<OnlineIcon
|
||||
v-if="botStore.botStores[bot.botId].isBotLoggedIn"
|
||||
:size="18"
|
||||
class="ms-2 me-1 align-middle"
|
||||
:class="botStore.botStores[bot.botId].isBotOnline ? 'online' : 'offline'"
|
||||
:title="botStore.botStores[bot.botId].isBotOnline ? 'Online' : 'Offline'"
|
||||
></OnlineIcon>
|
||||
<LoggedOutIcon
|
||||
v-else
|
||||
class="offline"
|
||||
title="Login info expied, please login again."
|
||||
></LoggedOutIcon>
|
||||
</b-form-checkbox>
|
||||
<div v-if="!noButtons" class="float-end d-flex flex-align-center">
|
||||
<b-button class="ms-1" size="sm" title="Delete bot" @click="$emit('edit')">
|
||||
|
@ -44,6 +50,7 @@
|
|||
import EditIcon from 'vue-material-design-icons/Pencil.vue';
|
||||
import DeleteIcon from 'vue-material-design-icons/Delete.vue';
|
||||
import OnlineIcon from 'vue-material-design-icons/Circle.vue';
|
||||
import LoggedOutIcon from 'vue-material-design-icons/Cancel.vue';
|
||||
import { BotDescriptor } from '@/types';
|
||||
import { defineComponent, computed, ref } from 'vue';
|
||||
import { useBotStore } from '@/stores/ftbotwrapper';
|
||||
|
@ -54,6 +61,7 @@ export default defineComponent({
|
|||
DeleteIcon,
|
||||
EditIcon,
|
||||
OnlineIcon,
|
||||
LoggedOutIcon,
|
||||
},
|
||||
props: {
|
||||
bot: { required: true, type: Object as () => BotDescriptor },
|
||||
|
|
|
@ -50,6 +50,11 @@ export function useApi(userService: UserService, botId: string) {
|
|||
.catch((error) => {
|
||||
console.log('No new token received');
|
||||
console.log(error);
|
||||
const botStore = useBotStore();
|
||||
if (botStore.botStores[botId]) {
|
||||
botStore.botStores[botId].setIsBotOnline(false);
|
||||
botStore.botStores[botId].isBotLoggedIn = false;
|
||||
}
|
||||
});
|
||||
|
||||
// maybe redirect to /login if needed !
|
||||
|
|
|
@ -80,6 +80,13 @@ export class UserService {
|
|||
};
|
||||
}
|
||||
|
||||
setRefreshTokenExpired(): void {
|
||||
const loginInfo = this.getLoginInfo();
|
||||
loginInfo.refreshToken = '';
|
||||
loginInfo.accessToken = '';
|
||||
this.storeLoginInfo(loginInfo);
|
||||
}
|
||||
|
||||
public static getAvailableBots(): BotDescriptors {
|
||||
const allInfo = UserService.getAllLoginInfos();
|
||||
const response: BotDescriptors = {};
|
||||
|
@ -167,8 +174,9 @@ export class UserService {
|
|||
.catch((err) => {
|
||||
console.error(err);
|
||||
if (err.response && err.response.status === 401) {
|
||||
// in case of errors when using the refresh token - logout.
|
||||
this.logout();
|
||||
// Refresh token did not refresh.
|
||||
console.log('Refresh token did not refresh.');
|
||||
this.setRefreshTokenExpired();
|
||||
} else if (err.response && (err.response.status === 500 || err.response.status === 404)) {
|
||||
console.log('Bot seems to be offline... - retrying later');
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ export function createBotSubStore(botId: string, botName: string) {
|
|||
ping: '',
|
||||
botStatusAvailable: false,
|
||||
isBotOnline: false,
|
||||
isBotLoggedIn: true,
|
||||
autoRefresh: false,
|
||||
refreshing: false,
|
||||
versionState: '',
|
||||
|
@ -824,7 +825,6 @@ export function createBotSubStore(botId: string, botName: string) {
|
|||
showNotification(msg, botName);
|
||||
break;
|
||||
case FtWsMessageTypes.newCandle:
|
||||
console.log('exitFill', msg);
|
||||
const [pair, timeframe] = msg.data;
|
||||
// TODO: check for active bot ...
|
||||
if (pair === this.selectedPair) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user