mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-27 05:25:17 +00:00
Improve "no bot available" errorhandling
This commit is contained in:
parent
29d908bf47
commit
acd702dab3
|
@ -30,7 +30,7 @@
|
|||
<b-navbar-nav class="ml-auto">
|
||||
<li class="nav-item text-secondary mr-2">
|
||||
<b-nav-text class="verticalCenter small mr-2">
|
||||
{{ botName }}
|
||||
{{ botName || 'No bot selected' }}
|
||||
</b-nav-text>
|
||||
<b-nav-text class="verticalCenter">
|
||||
{{ isBotOnline ? 'Online' : 'Offline' }}
|
||||
|
|
|
@ -2,8 +2,7 @@ import Vue from 'vue';
|
|||
import VueRouter, { RouteConfig } from 'vue-router';
|
||||
import Home from '@/views/Home.vue';
|
||||
import Error404 from '@/views/Error404.vue';
|
||||
|
||||
import userService from '@/shared/userService';
|
||||
import store from '@/store';
|
||||
|
||||
Vue.use(VueRouter);
|
||||
|
||||
|
@ -68,11 +67,8 @@ const router = new VueRouter({
|
|||
});
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.name === 'Login' && userService.loggedIn()) {
|
||||
// No login if already logged in
|
||||
next({ path: '/' });
|
||||
}
|
||||
if (!to.meta?.allowAnonymous && !userService.loggedIn()) {
|
||||
const hasBots = store.getters['ftbot/hasBots'];
|
||||
if (!to.meta?.allowAnonymous && !hasBots) {
|
||||
// Forward to login if login is required
|
||||
next({
|
||||
path: '/login',
|
||||
|
|
|
@ -71,8 +71,12 @@ export default function createBotStore(store) {
|
|||
};
|
||||
// Autocreate Actions
|
||||
Object.keys(BotStoreActions).forEach((e) => {
|
||||
actions[e] = ({ state, dispatch }, ...args) => {
|
||||
actions[e] = ({ state, dispatch, getters }, ...args) => {
|
||||
if (getters.hasBots) {
|
||||
return dispatch(`${state.selectedBot}/${e}`, ...args);
|
||||
}
|
||||
console.warn(`bot ${state.selectedBot} is not registered.`);
|
||||
return {};
|
||||
};
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user