blob: 4f46848075a5ac97e3e769089a0fbca71e3edc93 [file] [log] [blame]
Derick Montaguee080a1a2019-12-04 16:30:08 -06001<template>
Yoshie Muranaka74f86872020-02-10 12:28:37 -08002 <div class="app-container">
kennyneedsmilky14172d72021-11-10 15:26:07 -06003 <app-header
4 ref="focusTarget"
5 class="app-header"
6 :router-key="routerKey"
7 @refresh="refresh"
8 />
Yoshie Muranaka74f86872020-02-10 12:28:37 -08009 <app-navigation class="app-navigation" />
10 <page-container class="app-content">
11 <router-view ref="routerView" :key="routerKey" />
Dixsie Wolmers970ea7d2020-11-16 16:46:01 -060012 <!-- Scroll to top button -->
13 <button-back-to-top />
Yoshie Muranaka74f86872020-02-10 12:28:37 -080014 </page-container>
Derick Montaguee080a1a2019-12-04 16:30:08 -060015 </div>
16</template>
17
18<script>
Derick Montaguee2fd1562019-12-20 13:26:53 -060019import AppHeader from '@/components/AppHeader';
20import AppNavigation from '@/components/AppNavigation';
SurenNeware61859092020-10-01 09:37:32 +053021import PageContainer from '@/components/Global/PageContainer';
Dixsie Wolmers970ea7d2020-11-16 16:46:01 -060022import ButtonBackToTop from '@/components/Global/ButtonBackToTop';
Dixsie Wolmersdc6b3cd2021-05-20 19:01:42 -050023import JumpLinkMixin from '@/components/Mixins/JumpLinkMixin';
Dixsie Wolmers970ea7d2020-11-16 16:46:01 -060024
Derick Montaguee080a1a2019-12-04 16:30:08 -060025export default {
Derick Montaguee2fd1562019-12-20 13:26:53 -060026 name: 'App',
Derick Montaguee080a1a2019-12-04 16:30:08 -060027 components: {
28 AppHeader,
Yoshie Muranaka8d129102019-12-19 09:51:55 -080029 AppNavigation,
Derick Montague602e98a2020-10-21 16:20:00 -050030 PageContainer,
Dixsie Wolmers970ea7d2020-11-16 16:46:01 -060031 ButtonBackToTop,
Derick Montague75b48322019-12-06 01:24:41 -060032 },
Dixsie Wolmersdc6b3cd2021-05-20 19:01:42 -050033 mixins: [JumpLinkMixin],
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080034 data() {
35 return {
Derick Montague602e98a2020-10-21 16:20:00 -050036 routerKey: 0,
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080037 };
38 },
Derick Montague75b48322019-12-06 01:24:41 -060039 watch: {
Derick Montague602e98a2020-10-21 16:20:00 -050040 $route: function () {
Derick Montague602e98a2020-10-21 16:20:00 -050041 this.$nextTick(function () {
Derick Montague80267972021-02-16 09:47:03 -060042 this.setFocus(this.$refs.focusTarget.$el);
Derick Montague75b48322019-12-06 01:24:41 -060043 });
Derick Montague602e98a2020-10-21 16:20:00 -050044 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080045 },
Yoshie Muranaka6f712842021-02-04 11:23:03 -080046 mounted() {
47 this.$root.$on('refresh-application', () => this.refresh());
BlueSnake00248d5bc2024-02-01 16:55:54 +030048 setInterval(() => {
49 if (!localStorage.getItem('storedUsername')) {
Ed Tanous883a0d52024-03-23 14:56:34 -070050 this.$eventBus.$consoleWindow?.close();
BlueSnake00248d5bc2024-02-01 16:55:54 +030051 this.refresh();
52 }
53 }, 10000);
Yoshie Muranaka6f712842021-02-04 11:23:03 -080054 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080055 methods: {
56 refresh() {
Shubhi Garg20ce44a2024-12-02 14:56:48 +053057 // Clear all toast messages
58 document.querySelectorAll('.toast').forEach((toast) => {
59 const toastId = toast.id;
60 if (toastId) {
61 this.$bvToast.hide(toastId);
62 }
63 });
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080064 // Changing the component :key value will trigger
65 // a component re-rendering and 'refresh' the view
66 this.routerKey += 1;
Derick Montague602e98a2020-10-21 16:20:00 -050067 },
68 },
Derick Montaguee080a1a2019-12-04 16:30:08 -060069};
70</script>
71
72<style lang="scss" scoped>
Ed Tanous7d6b44c2024-03-23 14:56:34 -070073@import '@/assets/styles/bmc/helpers/_index.scss';
74@import '@/assets/styles/bootstrap/_helpers.scss';
75
Yoshie Muranaka74f86872020-02-10 12:28:37 -080076.app-container {
77 display: grid;
78 grid-template-columns: 100%;
79 grid-template-rows: auto;
80 grid-template-areas:
81 'header'
82 'content';
83
84 @include media-breakpoint-up($responsive-layout-bp) {
85 grid-template-columns: $navigation-width 1fr;
86 grid-template-areas:
87 'header header'
88 'navigation content';
89 }
90}
91
92.app-header {
93 grid-area: header;
94 position: sticky;
95 top: 0;
96 z-index: $zindex-fixed + 1;
97}
98
99.app-navigation {
100 grid-area: navigation;
101}
102
103.app-content {
104 grid-area: content;
105 background-color: $white;
Derick Montaguee080a1a2019-12-04 16:30:08 -0600106}
107</style>