blob: 7a2c34247dda472acbb80ce374a366a3215e0f7e [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() {
jason westoverd36ac8a2025-11-03 20:58:59 -060047 require('@/eventBus').default.$on('refresh-application', () =>
48 this.refresh(),
49 );
BlueSnake00248d5bc2024-02-01 16:55:54 +030050 setInterval(() => {
51 if (!localStorage.getItem('storedUsername')) {
Ed Tanous883a0d52024-03-23 14:56:34 -070052 this.$eventBus.$consoleWindow?.close();
BlueSnake00248d5bc2024-02-01 16:55:54 +030053 this.refresh();
54 }
55 }, 10000);
Yoshie Muranaka6f712842021-02-04 11:23:03 -080056 },
jason westoverd36ac8a2025-11-03 20:58:59 -060057 beforeUnmount() {
58 require('@/eventBus').default.$off(
59 'refresh-application',
60 this.handleRefreshApplication,
61 );
62 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080063 methods: {
jason westoverd36ac8a2025-11-03 20:58:59 -060064 handleRefreshApplication() {
65 this.refresh();
66 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080067 refresh() {
Shubhi Garg20ce44a2024-12-02 14:56:48 +053068 // Clear all toast messages
69 document.querySelectorAll('.toast').forEach((toast) => {
70 const toastId = toast.id;
71 if (toastId) {
72 this.$bvToast.hide(toastId);
73 }
74 });
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080075 // Changing the component :key value will trigger
76 // a component re-rendering and 'refresh' the view
77 this.routerKey += 1;
Derick Montague602e98a2020-10-21 16:20:00 -050078 },
79 },
Derick Montaguee080a1a2019-12-04 16:30:08 -060080};
81</script>
82
83<style lang="scss" scoped>
Yoshie Muranaka74f86872020-02-10 12:28:37 -080084.app-container {
85 display: grid;
86 grid-template-columns: 100%;
87 grid-template-rows: auto;
88 grid-template-areas:
89 'header'
90 'content';
91
92 @include media-breakpoint-up($responsive-layout-bp) {
93 grid-template-columns: $navigation-width 1fr;
94 grid-template-areas:
95 'header header'
96 'navigation content';
97 }
98}
99
100.app-header {
101 grid-area: header;
102 position: sticky;
103 top: 0;
104 z-index: $zindex-fixed + 1;
105}
106
107.app-navigation {
108 grid-area: navigation;
109}
110
111.app-content {
112 grid-area: content;
113 background-color: $white;
Derick Montaguee080a1a2019-12-04 16:30:08 -0600114}
115</style>