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>
</template>
<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-nav-item-dropdown>
</li>
@ -48,6 +49,7 @@ import userService from '@/shared/userService';
import BootswatchThemeSelect from '@/components/BootswatchThemeSelect.vue';
const ftbot = namespace('ftbot');
const layoutNs = namespace('layout');
@Component({
components: { LoginModal, BootswatchThemeSelect },
@ -63,6 +65,10 @@ export default class NavBar extends Vue {
@ftbot.Action ping;
@layoutNs.Action resetDashboardLayout;
@layoutNs.Action resetTradingLayout;
mounted() {
this.ping();
this.pingInterval = setInterval(this.ping, 60000);
@ -78,6 +84,20 @@ export default class NavBar extends Vue {
userService.logout();
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>

View File

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