Implement layout reset

This commit is contained in:
Matthias 2020-08-18 08:53:20 +02:00
parent 829cb07745
commit a7d78b7c74
2 changed files with 24 additions and 4 deletions

View File

@ -27,6 +27,7 @@
<b-avatar button>FT</b-avatar> <b-avatar button>FT</b-avatar>
</template> </template>
<b-dropdown-item to="/settings">Settings</b-dropdown-item> <b-dropdown-item to="/settings">Settings</b-dropdown-item>
<b-dropdown-item @click="resetDynamicLayout">Reset Layout</b-dropdown-item>
<b-dropdown-item to="/" @click.native="logout()">Sign Out</b-dropdown-item> <b-dropdown-item to="/" @click.native="logout()">Sign Out</b-dropdown-item>
</b-nav-item-dropdown> </b-nav-item-dropdown>
</li> </li>
@ -48,6 +49,7 @@ import userService from '@/shared/userService';
import BootswatchThemeSelect from '@/components/BootswatchThemeSelect.vue'; import BootswatchThemeSelect from '@/components/BootswatchThemeSelect.vue';
const ftbot = namespace('ftbot'); const ftbot = namespace('ftbot');
const layoutNs = namespace('layout');
@Component({ @Component({
components: { LoginModal, BootswatchThemeSelect }, components: { LoginModal, BootswatchThemeSelect },
@ -63,6 +65,10 @@ export default class NavBar extends Vue {
@ftbot.Action ping; @ftbot.Action ping;
@layoutNs.Action resetDashboardLayout;
@layoutNs.Action resetTradingLayout;
mounted() { mounted() {
this.ping(); this.ping();
this.pingInterval = setInterval(this.ping, 60000); this.pingInterval = setInterval(this.ping, 60000);
@ -78,6 +84,20 @@ export default class NavBar extends Vue {
userService.logout(); userService.logout();
this.setLoggedIn(false); this.setLoggedIn(false);
} }
resetDynamicLayout(): void {
const route = this.$router.currentRoute.path;
console.log(`resetLayout called for ${route}`);
switch (route) {
case '/trade':
this.resetTradingLayout();
break;
case '/dashboard':
this.resetDashboardLayout();
break;
default:
}
}
} }
</script> </script>

View File

@ -18,8 +18,8 @@ const DEFAULT_DASHBOARD_LAYOUT: GridItemData[] = [
export default { export default {
namespaced: true, namespaced: true,
state: { state: {
dashboardLayout: DEFAULT_DASHBOARD_LAYOUT, dashboardLayout: JSON.parse(JSON.stringify(DEFAULT_DASHBOARD_LAYOUT)),
tradingLayout: DEFAULT_TRADING_LAYOUT, tradingLayout: JSON.parse(JSON.stringify(DEFAULT_TRADING_LAYOUT)),
}, },
getters: { getters: {
@ -43,11 +43,11 @@ export default {
actions: { actions: {
resetDashboardLayout({ commit }) { resetDashboardLayout({ commit }) {
commit('setDashboardLayout', DEFAULT_DASHBOARD_LAYOUT); commit('setDashboardLayout', JSON.parse(JSON.stringify(DEFAULT_DASHBOARD_LAYOUT)));
}, },
resetTradingLayout({ commit }) { resetTradingLayout({ commit }) {
commit('setTradingLayout', DEFAULT_TRADING_LAYOUT); commit('setTradingLayout', JSON.parse(JSON.stringify(DEFAULT_TRADING_LAYOUT)));
}, },
}, },
}; };