blob: 4162add873d110b10071b3e7ab10fd9860fd35dd [file] [log] [blame]
Derick Montaguea2988f42020-01-17 13:46:30 -06001<template>
2 <div>
Derick Montague75b48322019-12-06 01:24:41 -06003 <header id="page-header">
Derick Montague68592032020-04-04 14:02:34 -05004 <a role="link" class="link-skip-nav btn btn-light" href="#main-content">
5 {{ $t('appHeader.skipToContent') }}
6 </a>
7
8 <b-navbar
9 variant="dark"
10 type="dark"
11 :aria-label="$t('appHeader.applicationHeader')"
12 >
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080013 <!-- Left aligned nav items -->
Yoshie Muranaka74f86872020-02-10 12:28:37 -080014 <b-button
Derick Montague68592032020-04-04 14:02:34 -050015 id="app-header-trigger"
Yoshie Muranaka74f86872020-02-10 12:28:37 -080016 class="nav-trigger"
17 aria-hidden="true"
18 title="Open navigation"
19 type="button"
20 variant="link"
SurenNeware057232b2020-06-08 20:53:26 +053021 :class="{ open: isNavigationOpen }"
Yoshie Muranaka74f86872020-02-10 12:28:37 -080022 @click="toggleNavigation"
23 >
24 <icon-close v-if="isNavigationOpen" />
25 <icon-menu v-if="!isNavigationOpen" />
26 </b-button>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080027 <b-navbar-nav>
Mateusz Gapski03505912020-06-25 08:16:51 +020028 <img
29 class="header-logo"
30 src="@/assets/images/logo-header.svg"
31 :alt="altLogo"
32 />
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080033 </b-navbar-nav>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080034 <!-- Right aligned nav items -->
SurenNeware057232b2020-06-08 20:53:26 +053035 <b-navbar-nav class="ml-auto helper-menu">
Dixsie Wolmers13cdbcd2020-06-02 08:22:07 -050036 <b-nav-item to="/health/event-logs">
Derick Montague68592032020-04-04 14:02:34 -050037 <status-icon :status="healthStatusIcon" />
SurenNeware057232b2020-06-08 20:53:26 +053038 {{ $t('appHeader.health') }}
Derick Montague68592032020-04-04 14:02:34 -050039 </b-nav-item>
Dixsie Wolmers13cdbcd2020-06-02 08:22:07 -050040 <b-nav-item to="/control/server-power-operations">
Derick Montague68592032020-04-04 14:02:34 -050041 <status-icon :status="hostStatusIcon" />
SurenNeware057232b2020-06-08 20:53:26 +053042 {{ $t('appHeader.power') }}
Derick Montague68592032020-04-04 14:02:34 -050043 </b-nav-item>
44 <!-- Using LI elements instead of b-nav-item to support semantic button elements -->
45 <li class="nav-item">
46 <b-button id="app-header-refresh" variant="link" @click="refresh">
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080047 <icon-renew />
SurenNeware057232b2020-06-08 20:53:26 +053048 <span class="responsive-text">{{ $t('appHeader.refresh') }}</span>
Derick Montague68592032020-04-04 14:02:34 -050049 </b-button>
50 </li>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053051 <li class="nav-item">
52 <b-dropdown id="app-header-user" variant="link" right>
53 <template v-slot:button-content>
54 <icon-avatar />
SurenNeware057232b2020-06-08 20:53:26 +053055 <span class="responsive-text">{{ username }}</span>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053056 </template>
57 <b-dropdown-item to="/profile-settings"
58 >{{ $t('appHeader.profileSettings') }}
59 </b-dropdown-item>
60 <b-dropdown-item @click="logout">{{
61 $t('appHeader.logOut')
62 }}</b-dropdown-item>
63 </b-dropdown>
Derick Montague68592032020-04-04 14:02:34 -050064 </li>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080065 </b-navbar-nav>
Derick Montaguea2988f42020-01-17 13:46:30 -060066 </b-navbar>
67 </header>
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070068 <loading-bar />
Derick Montaguea2988f42020-01-17 13:46:30 -060069 </div>
70</template>
71
72<script>
Derick Montaguee2fd1562019-12-20 13:26:53 -060073import IconAvatar from '@carbon/icons-vue/es/user--avatar/20';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080074import IconClose from '@carbon/icons-vue/es/close/20';
75import IconMenu from '@carbon/icons-vue/es/menu/20';
Derick Montaguee2fd1562019-12-20 13:26:53 -060076import IconRenew from '@carbon/icons-vue/es/renew/20';
77import StatusIcon from '../Global/StatusIcon';
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070078import LoadingBar from '../Global/LoadingBar';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080079
Derick Montaguea2988f42020-01-17 13:46:30 -060080export default {
Derick Montaguee2fd1562019-12-20 13:26:53 -060081 name: 'AppHeader',
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070082 components: {
83 IconAvatar,
84 IconClose,
85 IconMenu,
86 IconRenew,
87 StatusIcon,
88 LoadingBar
89 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -080090 data() {
91 return {
Mateusz Gapski03505912020-06-25 08:16:51 +020092 isNavigationOpen: false,
93 altLogo: `${process.env.VUE_APP_COMPANY_NAME} logo`
Yoshie Muranaka74f86872020-02-10 12:28:37 -080094 };
95 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080096 computed: {
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080097 hostStatus() {
Derick Montaguee2fd1562019-12-20 13:26:53 -060098 return this.$store.getters['global/hostStatus'];
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080099 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800100 healthStatus() {
101 return this.$store.getters['eventLog/healthStatus'];
102 },
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800103 hostStatusIcon() {
104 switch (this.hostStatus) {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600105 case 'on':
106 return 'success';
107 case 'error':
108 return 'danger';
Yoshie Muranakaa3cbc652020-05-13 12:55:48 -0700109 case 'diagnosticMode':
110 return 'warning';
Derick Montaguee2fd1562019-12-20 13:26:53 -0600111 case 'off':
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800112 default:
Derick Montaguee2fd1562019-12-20 13:26:53 -0600113 return 'secondary';
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800114 }
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800115 },
116 healthStatusIcon() {
117 switch (this.healthStatus) {
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700118 case 'OK':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800119 return 'success';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700120 case 'Warning':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800121 return 'warning';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700122 case 'Critical':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800123 return 'danger';
124 default:
125 return 'secondary';
126 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530127 },
128 username() {
129 return this.$store.getters['global/username'];
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800130 }
131 },
Derick Montague09e45cd2020-01-23 15:45:57 -0600132 created() {
133 this.getHostInfo();
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800134 this.getEvents();
Derick Montague09e45cd2020-01-23 15:45:57 -0600135 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800136 mounted() {
137 this.$root.$on(
138 'change:isNavigationOpen',
139 isNavigationOpen => (this.isNavigationOpen = isNavigationOpen)
140 );
141 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800142 methods: {
143 getHostInfo() {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600144 this.$store.dispatch('global/getHostStatus');
Derick Montaguee080a1a2019-12-04 16:30:08 -0600145 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800146 getEvents() {
147 this.$store.dispatch('eventLog/getEventLogData');
148 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -0800149 refresh() {
150 this.$emit('refresh');
151 },
Derick Montaguee080a1a2019-12-04 16:30:08 -0600152 logout() {
Derick Montaguec031b692020-02-12 15:55:42 -0600153 this.$store.dispatch('authentication/logout');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800154 },
155 toggleNavigation() {
156 this.$root.$emit('toggle:navigation');
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800157 }
Derick Montaguea2988f42020-01-17 13:46:30 -0600158 }
159};
160</script>
161
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530162<style lang="scss">
Derick Montague40865722020-04-13 17:01:19 -0500163@import 'src/assets/styles/helpers';
164
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530165.app-header {
166 .link-skip-nav {
167 position: absolute;
168 top: -60px;
169 left: 0.5rem;
170 z-index: $zindex-popover;
171 transition: $duration--moderate-01 $exit-easing--expressive;
172 &:focus {
173 top: 0.5rem;
174 transition-timing-function: $entrance-easing--expressive;
175 }
Derick Montague75b48322019-12-06 01:24:41 -0600176 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530177 .navbar-dark {
178 .navbar-text,
179 .nav-link,
180 .btn-link {
181 color: $white !important;
182 fill: currentColor;
183 }
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800184 }
185
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530186 .nav-item {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700187 fill: theme-color('light');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800188 }
189
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530190 .navbar {
191 padding: 0;
SurenNeware057232b2020-06-08 20:53:26 +0530192 @include media-breakpoint-up($responsive-layout-bp) {
193 height: $header-height;
194 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530195
196 .btn-link {
197 padding: $spacer / 2;
198 }
SurenNeware057232b2020-06-08 20:53:26 +0530199
Mateusz Gapski03505912020-06-25 08:16:51 +0200200 .header-logo {
201 width: auto;
202 height: $header-height;
203 padding: $spacer/2 0;
204 }
205
SurenNeware057232b2020-06-08 20:53:26 +0530206 .helper-menu {
207 @include media-breakpoint-down(sm) {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700208 background-color: gray('800');
SurenNeware057232b2020-06-08 20:53:26 +0530209 width: 100%;
210 justify-content: flex-end;
211
212 .nav-link,
213 .btn {
214 padding: $spacer / 1.125 $spacer / 2;
215 }
216 }
217
218 .responsive-text {
219 @include media-breakpoint-down(xs) {
220 display: none;
221 }
222 }
223 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530224 }
225
226 .navbar-nav {
227 padding: 0 $spacer;
228 }
229
230 .nav-trigger {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700231 fill: theme-color('light');
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530232 width: $header-height;
233 height: $header-height;
234 transition: none;
235
236 svg {
237 margin: 0;
238 }
239
240 &:hover {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700241 fill: theme-color('light');
242 background-color: theme-color('dark');
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530243 }
244
SurenNeware057232b2020-06-08 20:53:26 +0530245 &.open {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700246 background-color: gray('800');
SurenNeware057232b2020-06-08 20:53:26 +0530247 }
248
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530249 @include media-breakpoint-up($responsive-layout-bp) {
250 display: none;
251 }
252 }
253
254 .dropdown {
255 .dropdown-menu {
SurenNeware057232b2020-06-08 20:53:26 +0530256 margin-top: 0;
257 @include media-breakpoint-up(md) {
258 margin-top: 7px;
259 }
260 }
261 }
262
263 .navbar-expand {
264 @include media-breakpoint-down(sm) {
265 flex-flow: wrap;
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530266 }
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800267 }
268}
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800269</style>