blob: a198495346c18a0cbb7e0a766e91ab6f10573fc5 [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 Montague80267972021-02-16 09:47:03 -06004 <a
5 class="link-skip-nav btn btn-light"
6 href="#main-content"
7 @click="setFocus"
8 >
Derick Montague68592032020-04-04 14:02:34 -05009 {{ $t('appHeader.skipToContent') }}
10 </a>
11
Mateusz Gapski21d6de02020-07-29 14:28:23 +020012 <b-navbar type="dark" :aria-label="$t('appHeader.applicationHeader')">
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"
Yoshie Muranaka74f86872020-02-10 12:28:37 -080018 type="button"
19 variant="link"
SurenNeware057232b2020-06-08 20:53:26 +053020 :class="{ open: isNavigationOpen }"
Yoshie Muranaka74f86872020-02-10 12:28:37 -080021 @click="toggleNavigation"
22 >
SurenNewarea5cbc442020-10-12 15:26:39 +053023 <icon-close
24 v-if="isNavigationOpen"
25 :title="$t('appHeader.titleHideNavigation')"
26 />
27 <icon-menu
28 v-if="!isNavigationOpen"
29 :title="$t('appHeader.titleShowNavigation')"
30 />
Yoshie Muranaka74f86872020-02-10 12:28:37 -080031 </b-button>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080032 <b-navbar-nav>
Sukanya Pandeyc5c2ae92020-12-09 16:14:19 +053033 <b-navbar-brand
34 class="mr-0"
35 to="/"
36 data-test-id="appHeader-container-overview"
37 >
Dixsie Wolmers76ccbbc2020-08-24 21:25:57 -050038 <img
39 class="header-logo"
40 src="@/assets/images/logo-header.svg"
41 :alt="altLogo"
42 />
SurenNeware1f8117f2020-09-22 19:28:56 +053043 </b-navbar-brand>
kennyneedsmilky14172d72021-11-10 15:26:07 -060044 <div v-if="isNavTagPresent" :key="routerKey" class="pl-2 nav-tags">
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +053045 <span>|</span>
46 <span class="pl-3 asset-tag">{{ assetTag }}</span>
47 <span class="pl-3">{{ modelType }}</span>
48 <span class="pl-3">{{ serialNumber }}</span>
Sukanya Pandeyc5c2ae92020-12-09 16:14:19 +053049 </div>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080050 </b-navbar-nav>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080051 <!-- Right aligned nav items -->
SurenNeware057232b2020-06-08 20:53:26 +053052 <b-navbar-nav class="ml-auto helper-menu">
Derick Montague965cf672020-07-23 17:24:39 -050053 <b-nav-item
Derick Montague828dda92021-06-28 15:52:22 -050054 to="/logs/event-logs"
Derick Montague965cf672020-07-23 17:24:39 -050055 data-test-id="appHeader-container-health"
56 >
Derick Montague68592032020-04-04 14:02:34 -050057 <status-icon :status="healthStatusIcon" />
SurenNeware057232b2020-06-08 20:53:26 +053058 {{ $t('appHeader.health') }}
Derick Montague68592032020-04-04 14:02:34 -050059 </b-nav-item>
Derick Montague965cf672020-07-23 17:24:39 -050060 <b-nav-item
Sandeepa Singh68cbbe92021-07-14 16:02:22 +053061 to="/operations/server-power-operations"
Derick Montague965cf672020-07-23 17:24:39 -050062 data-test-id="appHeader-container-power"
63 >
Derick Montague71114fe2021-05-06 18:17:34 -050064 <status-icon :status="serverStatusIcon" />
SurenNeware057232b2020-06-08 20:53:26 +053065 {{ $t('appHeader.power') }}
Derick Montague68592032020-04-04 14:02:34 -050066 </b-nav-item>
67 <!-- Using LI elements instead of b-nav-item to support semantic button elements -->
68 <li class="nav-item">
Derick Montague965cf672020-07-23 17:24:39 -050069 <b-button
70 id="app-header-refresh"
71 variant="link"
72 data-test-id="appHeader-button-refresh"
73 @click="refresh"
74 >
SurenNewarea5cbc442020-10-12 15:26:39 +053075 <icon-renew :title="$t('appHeader.titleRefresh')" />
SurenNeware057232b2020-06-08 20:53:26 +053076 <span class="responsive-text">{{ $t('appHeader.refresh') }}</span>
Derick Montague68592032020-04-04 14:02:34 -050077 </b-button>
78 </li>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053079 <li class="nav-item">
Derick Montague965cf672020-07-23 17:24:39 -050080 <b-dropdown
81 id="app-header-user"
82 variant="link"
83 right
84 data-test-id="appHeader-container-user"
85 >
Derick Montague602e98a2020-10-21 16:20:00 -050086 <template #button-content>
SurenNewarea5cbc442020-10-12 15:26:39 +053087 <icon-avatar :title="$t('appHeader.titleProfile')" />
SurenNeware057232b2020-06-08 20:53:26 +053088 <span class="responsive-text">{{ username }}</span>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053089 </template>
Derick Montague965cf672020-07-23 17:24:39 -050090 <b-dropdown-item
91 to="/profile-settings"
92 data-test-id="appHeader-link-profile"
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053093 >{{ $t('appHeader.profileSettings') }}
94 </b-dropdown-item>
Derick Montague965cf672020-07-23 17:24:39 -050095 <b-dropdown-item
96 data-test-id="appHeader-link-logout"
97 @click="logout"
98 >
99 {{ $t('appHeader.logOut') }}
100 </b-dropdown-item>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530101 </b-dropdown>
Derick Montague68592032020-04-04 14:02:34 -0500102 </li>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800103 </b-navbar-nav>
Derick Montaguea2988f42020-01-17 13:46:30 -0600104 </b-navbar>
105 </header>
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700106 <loading-bar />
Derick Montaguea2988f42020-01-17 13:46:30 -0600107 </div>
108</template>
109
110<script>
Sukanya Pandeydd6aa0a2020-10-08 20:47:39 +0530111import BVToastMixin from '@/components/Mixins/BVToastMixin';
Derick Montaguee2fd1562019-12-20 13:26:53 -0600112import IconAvatar from '@carbon/icons-vue/es/user--avatar/20';
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800113import IconClose from '@carbon/icons-vue/es/close/20';
114import IconMenu from '@carbon/icons-vue/es/menu/20';
Derick Montaguee2fd1562019-12-20 13:26:53 -0600115import IconRenew from '@carbon/icons-vue/es/renew/20';
SurenNeware61859092020-10-01 09:37:32 +0530116import StatusIcon from '@/components/Global/StatusIcon';
117import LoadingBar from '@/components/Global/LoadingBar';
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800118
Derick Montaguea2988f42020-01-17 13:46:30 -0600119export default {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600120 name: 'AppHeader',
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700121 components: {
122 IconAvatar,
123 IconClose,
124 IconMenu,
125 IconRenew,
126 StatusIcon,
Derick Montague602e98a2020-10-21 16:20:00 -0500127 LoadingBar,
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700128 },
Sukanya Pandeydd6aa0a2020-10-08 20:47:39 +0530129 mixins: [BVToastMixin],
kennyneedsmilky14172d72021-11-10 15:26:07 -0600130 props: {
Kenneth Fullbright00cb42b2021-12-21 13:56:08 -0600131 routerKey: {
132 type: Number,
133 default: 0,
134 },
kennyneedsmilky14172d72021-11-10 15:26:07 -0600135 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800136 data() {
137 return {
Mateusz Gapski03505912020-06-25 08:16:51 +0200138 isNavigationOpen: false,
Derick Montague932aff92021-08-26 14:06:49 -0500139 altLogo: process.env.VUE_APP_COMPANY_NAME || 'Built on OpenBMC',
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800140 };
141 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800142 computed: {
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +0530143 isNavTagPresent() {
144 return this.assetTag || this.modelType || this.serialNumber;
145 },
Sukanya Pandeyc5c2ae92020-12-09 16:14:19 +0530146 assetTag() {
147 return this.$store.getters['global/assetTag'];
148 },
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +0530149 modelType() {
150 return this.$store.getters['global/modelType'];
151 },
152 serialNumber() {
153 return this.$store.getters['global/serialNumber'];
154 },
Sukanya Pandeydd6aa0a2020-10-08 20:47:39 +0530155 isAuthorized() {
156 return this.$store.getters['global/isAuthorized'];
157 },
Damian Celicoaeb19812022-11-24 02:00:53 +0100158 userPrivilege() {
159 return this.$store.getters['global/userPrivilege'];
160 },
Derick Montague71114fe2021-05-06 18:17:34 -0500161 serverStatus() {
162 return this.$store.getters['global/serverStatus'];
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800163 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800164 healthStatus() {
165 return this.$store.getters['eventLog/healthStatus'];
166 },
Derick Montague71114fe2021-05-06 18:17:34 -0500167 serverStatusIcon() {
168 switch (this.serverStatus) {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600169 case 'on':
170 return 'success';
171 case 'error':
172 return 'danger';
Yoshie Muranakaa3cbc652020-05-13 12:55:48 -0700173 case 'diagnosticMode':
174 return 'warning';
Derick Montaguee2fd1562019-12-20 13:26:53 -0600175 case 'off':
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800176 default:
Derick Montaguee2fd1562019-12-20 13:26:53 -0600177 return 'secondary';
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800178 }
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800179 },
180 healthStatusIcon() {
181 switch (this.healthStatus) {
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700182 case 'OK':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800183 return 'success';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700184 case 'Warning':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800185 return 'warning';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700186 case 'Critical':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800187 return 'danger';
188 default:
189 return 'secondary';
190 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530191 },
192 username() {
193 return this.$store.getters['global/username'];
Derick Montague602e98a2020-10-21 16:20:00 -0500194 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800195 },
Sukanya Pandeydd6aa0a2020-10-08 20:47:39 +0530196 watch: {
197 isAuthorized(value) {
198 if (value === false) {
Yoshie Muranakaf92e2962021-02-09 12:41:53 -0800199 this.errorToast(this.$t('global.toast.unAuthDescription'), {
200 title: this.$t('global.toast.unAuthTitle'),
201 });
Sukanya Pandeydd6aa0a2020-10-08 20:47:39 +0530202 }
Derick Montague602e98a2020-10-21 16:20:00 -0500203 },
Sukanya Pandeydd6aa0a2020-10-08 20:47:39 +0530204 },
Derick Montague09e45cd2020-01-23 15:45:57 -0600205 created() {
Yoshie Muranakad624dae2020-09-21 14:35:58 -0700206 // Reset auth state to check if user is authenticated based
207 // on available browser cookies
208 this.$store.dispatch('authentication/resetStoreState');
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +0530209 this.getSystemInfo();
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800210 this.getEvents();
Derick Montague09e45cd2020-01-23 15:45:57 -0600211 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800212 mounted() {
213 this.$root.$on(
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530214 'change-is-navigation-open',
Derick Montague602e98a2020-10-21 16:20:00 -0500215 (isNavigationOpen) => (this.isNavigationOpen = isNavigationOpen)
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800216 );
217 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800218 methods: {
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +0530219 getSystemInfo() {
220 this.$store.dispatch('global/getSystemInfo');
Derick Montaguee080a1a2019-12-04 16:30:08 -0600221 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800222 getEvents() {
223 this.$store.dispatch('eventLog/getEventLogData');
224 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -0800225 refresh() {
226 this.$emit('refresh');
227 },
Derick Montaguee080a1a2019-12-04 16:30:08 -0600228 logout() {
Derick Montaguec031b692020-02-12 15:55:42 -0600229 this.$store.dispatch('authentication/logout');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800230 },
231 toggleNavigation() {
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530232 this.$root.$emit('toggle-navigation');
Derick Montague602e98a2020-10-21 16:20:00 -0500233 },
Derick Montague80267972021-02-16 09:47:03 -0600234 setFocus(event) {
235 event.preventDefault();
236 this.$root.$emit('skip-navigation');
237 },
Derick Montague602e98a2020-10-21 16:20:00 -0500238 },
Derick Montaguea2988f42020-01-17 13:46:30 -0600239};
240</script>
241
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530242<style lang="scss">
Derick Montague7d4b53b2020-10-26 12:14:16 -0500243@mixin focus-box-shadow($padding-color: $navbar-color, $outline-color: $white) {
244 box-shadow: inset 0 0 0 3px $padding-color, inset 0 0 0 5px $outline-color;
245}
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530246.app-header {
247 .link-skip-nav {
248 position: absolute;
249 top: -60px;
250 left: 0.5rem;
251 z-index: $zindex-popover;
252 transition: $duration--moderate-01 $exit-easing--expressive;
253 &:focus {
254 top: 0.5rem;
255 transition-timing-function: $entrance-easing--expressive;
256 }
Derick Montague75b48322019-12-06 01:24:41 -0600257 }
SurenNeware1f8117f2020-09-22 19:28:56 +0530258 .navbar-text,
259 .nav-link,
260 .btn-link {
261 color: color('white') !important;
262 fill: currentColor;
263 padding: 0.68rem 1rem !important;
264
265 &:hover {
266 background-color: theme-color-level(light, 10);
267 }
268 &:active {
269 background-color: theme-color-level(light, 9);
270 }
271 &:focus {
Derick Montague7d4b53b2020-10-26 12:14:16 -0500272 @include focus-box-shadow;
273 outline: 0;
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530274 }
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800275 }
276
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530277 .nav-item {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700278 fill: theme-color('light');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800279 }
280
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530281 .navbar {
282 padding: 0;
Mateusz Gapski21d6de02020-07-29 14:28:23 +0200283 background-color: $navbar-color;
SurenNeware057232b2020-06-08 20:53:26 +0530284 @include media-breakpoint-up($responsive-layout-bp) {
285 height: $header-height;
286 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530287
SurenNeware057232b2020-06-08 20:53:26 +0530288 .helper-menu {
289 @include media-breakpoint-down(sm) {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700290 background-color: gray('800');
SurenNeware057232b2020-06-08 20:53:26 +0530291 width: 100%;
292 justify-content: flex-end;
293
294 .nav-link,
295 .btn {
296 padding: $spacer / 1.125 $spacer / 2;
297 }
Derick Montague7d4b53b2020-10-26 12:14:16 -0500298
299 .nav-link:focus,
300 .btn:focus {
301 @include focus-box-shadow($gray-800);
302 }
SurenNeware057232b2020-06-08 20:53:26 +0530303 }
304
305 .responsive-text {
306 @include media-breakpoint-down(xs) {
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +0530307 @include sr-only;
SurenNeware057232b2020-06-08 20:53:26 +0530308 }
309 }
310 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530311 }
312
313 .navbar-nav {
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +0530314 @include media-breakpoint-up($responsive-layout-bp) {
315 padding: 0 $spacer;
316 }
SurenNeware1f8117f2020-09-22 19:28:56 +0530317 align-items: center;
318
319 .navbar-brand,
320 .nav-link {
321 transition: $focus-transition;
322 }
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +0530323 .nav-tags {
Sukanya Pandeyc5c2ae92020-12-09 16:14:19 +0530324 color: theme-color-level(light, 3);
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +0530325 @include media-breakpoint-down(xs) {
326 @include sr-only;
327 }
328 .asset-tag {
329 @include media-breakpoint-down($responsive-layout-bp) {
330 @include sr-only;
331 }
332 }
Sukanya Pandeyc5c2ae92020-12-09 16:14:19 +0530333 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530334 }
335
336 .nav-trigger {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700337 fill: theme-color('light');
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530338 width: $header-height;
339 height: $header-height;
340 transition: none;
SurenNeware1f8117f2020-09-22 19:28:56 +0530341 display: inline-flex;
342 flex: 0 0 20px;
343 align-items: center;
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530344
345 svg {
346 margin: 0;
347 }
348
349 &:hover {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700350 fill: theme-color('light');
SurenNeware1f8117f2020-09-22 19:28:56 +0530351 background-color: theme-color-level(light, 10);
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530352 }
353
SurenNeware057232b2020-06-08 20:53:26 +0530354 &.open {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700355 background-color: gray('800');
SurenNeware057232b2020-06-08 20:53:26 +0530356 }
357
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530358 @include media-breakpoint-up($responsive-layout-bp) {
359 display: none;
360 }
361 }
362
SurenNeware1f8117f2020-09-22 19:28:56 +0530363 .dropdown-menu {
364 margin-top: 0;
365
366 @include media-breakpoint-only(md) {
367 margin-top: 4px;
SurenNeware057232b2020-06-08 20:53:26 +0530368 }
369 }
370
371 .navbar-expand {
372 @include media-breakpoint-down(sm) {
373 flex-flow: wrap;
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530374 }
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800375 }
376}
SurenNeware1f8117f2020-09-22 19:28:56 +0530377
378.navbar-brand {
379 padding: $spacer/2;
380 height: $header-height;
381 line-height: 1;
382 &:focus {
383 box-shadow: inset 0 0 0 3px $navbar-color, inset 0 0 0 5px color('white');
384 outline: 0;
385 }
386}
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800387</style>