blob: 76c96c0635b0a1bd6bc89965a544801385d056b2 [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
Ed Tanous51abe872024-04-20 16:36:26 -070039 svg-inline
Dixsie Wolmers76ccbbc2020-08-24 21:25:57 -050040 class="header-logo"
41 src="@/assets/images/logo-header.svg"
42 :alt="altLogo"
43 />
SurenNeware1f8117f2020-09-22 19:28:56 +053044 </b-navbar-brand>
kennyneedsmilky14172d72021-11-10 15:26:07 -060045 <div v-if="isNavTagPresent" :key="routerKey" class="pl-2 nav-tags">
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +053046 <span>|</span>
47 <span class="pl-3 asset-tag">{{ assetTag }}</span>
48 <span class="pl-3">{{ modelType }}</span>
49 <span class="pl-3">{{ serialNumber }}</span>
Sukanya Pandeyc5c2ae92020-12-09 16:14:19 +053050 </div>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080051 </b-navbar-nav>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080052 <!-- Right aligned nav items -->
SurenNeware057232b2020-06-08 20:53:26 +053053 <b-navbar-nav class="ml-auto helper-menu">
Derick Montague965cf672020-07-23 17:24:39 -050054 <b-nav-item
Derick Montague828dda92021-06-28 15:52:22 -050055 to="/logs/event-logs"
Derick Montague965cf672020-07-23 17:24:39 -050056 data-test-id="appHeader-container-health"
57 >
Derick Montague68592032020-04-04 14:02:34 -050058 <status-icon :status="healthStatusIcon" />
SurenNeware057232b2020-06-08 20:53:26 +053059 {{ $t('appHeader.health') }}
Derick Montague68592032020-04-04 14:02:34 -050060 </b-nav-item>
Derick Montague965cf672020-07-23 17:24:39 -050061 <b-nav-item
Sandeepa Singh68cbbe92021-07-14 16:02:22 +053062 to="/operations/server-power-operations"
Derick Montague965cf672020-07-23 17:24:39 -050063 data-test-id="appHeader-container-power"
64 >
Derick Montague71114fe2021-05-06 18:17:34 -050065 <status-icon :status="serverStatusIcon" />
SurenNeware057232b2020-06-08 20:53:26 +053066 {{ $t('appHeader.power') }}
Derick Montague68592032020-04-04 14:02:34 -050067 </b-nav-item>
68 <!-- Using LI elements instead of b-nav-item to support semantic button elements -->
69 <li class="nav-item">
Derick Montague965cf672020-07-23 17:24:39 -050070 <b-button
71 id="app-header-refresh"
72 variant="link"
73 data-test-id="appHeader-button-refresh"
74 @click="refresh"
75 >
SurenNewarea5cbc442020-10-12 15:26:39 +053076 <icon-renew :title="$t('appHeader.titleRefresh')" />
SurenNeware057232b2020-06-08 20:53:26 +053077 <span class="responsive-text">{{ $t('appHeader.refresh') }}</span>
Derick Montague68592032020-04-04 14:02:34 -050078 </b-button>
79 </li>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053080 <li class="nav-item">
Derick Montague965cf672020-07-23 17:24:39 -050081 <b-dropdown
82 id="app-header-user"
83 variant="link"
84 right
85 data-test-id="appHeader-container-user"
86 >
Derick Montague602e98a2020-10-21 16:20:00 -050087 <template #button-content>
SurenNewarea5cbc442020-10-12 15:26:39 +053088 <icon-avatar :title="$t('appHeader.titleProfile')" />
SurenNeware057232b2020-06-08 20:53:26 +053089 <span class="responsive-text">{{ username }}</span>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053090 </template>
Derick Montague965cf672020-07-23 17:24:39 -050091 <b-dropdown-item
92 to="/profile-settings"
93 data-test-id="appHeader-link-profile"
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053094 >{{ $t('appHeader.profileSettings') }}
95 </b-dropdown-item>
Derick Montague965cf672020-07-23 17:24:39 -050096 <b-dropdown-item
97 data-test-id="appHeader-link-logout"
98 @click="logout"
99 >
100 {{ $t('appHeader.logOut') }}
101 </b-dropdown-item>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530102 </b-dropdown>
Derick Montague68592032020-04-04 14:02:34 -0500103 </li>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800104 </b-navbar-nav>
Derick Montaguea2988f42020-01-17 13:46:30 -0600105 </b-navbar>
106 </header>
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700107 <loading-bar />
Derick Montaguea2988f42020-01-17 13:46:30 -0600108 </div>
109</template>
110
111<script>
Sukanya Pandeydd6aa0a2020-10-08 20:47:39 +0530112import BVToastMixin from '@/components/Mixins/BVToastMixin';
Derick Montaguee2fd1562019-12-20 13:26:53 -0600113import IconAvatar from '@carbon/icons-vue/es/user--avatar/20';
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800114import IconClose from '@carbon/icons-vue/es/close/20';
115import IconMenu from '@carbon/icons-vue/es/menu/20';
Derick Montaguee2fd1562019-12-20 13:26:53 -0600116import IconRenew from '@carbon/icons-vue/es/renew/20';
SurenNeware61859092020-10-01 09:37:32 +0530117import StatusIcon from '@/components/Global/StatusIcon';
118import LoadingBar from '@/components/Global/LoadingBar';
Konstantinfb6c6de2023-06-14 17:23:14 +0300119import { mapState } from 'vuex';
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800120
Derick Montaguea2988f42020-01-17 13:46:30 -0600121export default {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600122 name: 'AppHeader',
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700123 components: {
124 IconAvatar,
125 IconClose,
126 IconMenu,
127 IconRenew,
128 StatusIcon,
Derick Montague602e98a2020-10-21 16:20:00 -0500129 LoadingBar,
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700130 },
Sukanya Pandeydd6aa0a2020-10-08 20:47:39 +0530131 mixins: [BVToastMixin],
kennyneedsmilky14172d72021-11-10 15:26:07 -0600132 props: {
Kenneth Fullbright00cb42b2021-12-21 13:56:08 -0600133 routerKey: {
134 type: Number,
135 default: 0,
136 },
kennyneedsmilky14172d72021-11-10 15:26:07 -0600137 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800138 data() {
139 return {
Mateusz Gapski03505912020-06-25 08:16:51 +0200140 isNavigationOpen: false,
Derick Montague932aff92021-08-26 14:06:49 -0500141 altLogo: process.env.VUE_APP_COMPANY_NAME || 'Built on OpenBMC',
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800142 };
143 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800144 computed: {
Konstantinfb6c6de2023-06-14 17:23:14 +0300145 ...mapState('authentication', ['consoleWindow']),
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +0530146 isNavTagPresent() {
147 return this.assetTag || this.modelType || this.serialNumber;
148 },
Sukanya Pandeyc5c2ae92020-12-09 16:14:19 +0530149 assetTag() {
150 return this.$store.getters['global/assetTag'];
151 },
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +0530152 modelType() {
153 return this.$store.getters['global/modelType'];
154 },
155 serialNumber() {
156 return this.$store.getters['global/serialNumber'];
157 },
Sukanya Pandeydd6aa0a2020-10-08 20:47:39 +0530158 isAuthorized() {
159 return this.$store.getters['global/isAuthorized'];
160 },
Damian Celicoaeb19812022-11-24 02:00:53 +0100161 userPrivilege() {
162 return this.$store.getters['global/userPrivilege'];
163 },
Derick Montague71114fe2021-05-06 18:17:34 -0500164 serverStatus() {
165 return this.$store.getters['global/serverStatus'];
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800166 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800167 healthStatus() {
168 return this.$store.getters['eventLog/healthStatus'];
169 },
Derick Montague71114fe2021-05-06 18:17:34 -0500170 serverStatusIcon() {
171 switch (this.serverStatus) {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600172 case 'on':
173 return 'success';
174 case 'error':
175 return 'danger';
Yoshie Muranakaa3cbc652020-05-13 12:55:48 -0700176 case 'diagnosticMode':
177 return 'warning';
Derick Montaguee2fd1562019-12-20 13:26:53 -0600178 case 'off':
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800179 default:
Derick Montaguee2fd1562019-12-20 13:26:53 -0600180 return 'secondary';
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800181 }
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800182 },
183 healthStatusIcon() {
184 switch (this.healthStatus) {
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700185 case 'OK':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800186 return 'success';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700187 case 'Warning':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800188 return 'warning';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700189 case 'Critical':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800190 return 'danger';
191 default:
192 return 'secondary';
193 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530194 },
195 username() {
196 return this.$store.getters['global/username'];
Derick Montague602e98a2020-10-21 16:20:00 -0500197 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800198 },
Sukanya Pandeydd6aa0a2020-10-08 20:47:39 +0530199 watch: {
Konstantinfb6c6de2023-06-14 17:23:14 +0300200 consoleWindow() {
201 if (this.consoleWindow === false) this.$eventBus.$consoleWindow.close();
202 },
Sukanya Pandeydd6aa0a2020-10-08 20:47:39 +0530203 isAuthorized(value) {
204 if (value === false) {
Yoshie Muranakaf92e2962021-02-09 12:41:53 -0800205 this.errorToast(this.$t('global.toast.unAuthDescription'), {
206 title: this.$t('global.toast.unAuthTitle'),
207 });
Sukanya Pandeydd6aa0a2020-10-08 20:47:39 +0530208 }
Derick Montague602e98a2020-10-21 16:20:00 -0500209 },
Sukanya Pandeydd6aa0a2020-10-08 20:47:39 +0530210 },
Derick Montague09e45cd2020-01-23 15:45:57 -0600211 created() {
Yoshie Muranakad624dae2020-09-21 14:35:58 -0700212 // Reset auth state to check if user is authenticated based
213 // on available browser cookies
214 this.$store.dispatch('authentication/resetStoreState');
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +0530215 this.getSystemInfo();
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800216 this.getEvents();
Derick Montague09e45cd2020-01-23 15:45:57 -0600217 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800218 mounted() {
219 this.$root.$on(
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530220 'change-is-navigation-open',
Ed Tanous81323992024-02-27 11:26:24 -0800221 (isNavigationOpen) => (this.isNavigationOpen = isNavigationOpen),
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800222 );
223 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800224 methods: {
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +0530225 getSystemInfo() {
226 this.$store.dispatch('global/getSystemInfo');
Derick Montaguee080a1a2019-12-04 16:30:08 -0600227 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800228 getEvents() {
229 this.$store.dispatch('eventLog/getEventLogData');
230 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -0800231 refresh() {
232 this.$emit('refresh');
233 },
Derick Montaguee080a1a2019-12-04 16:30:08 -0600234 logout() {
Derick Montaguec031b692020-02-12 15:55:42 -0600235 this.$store.dispatch('authentication/logout');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800236 },
237 toggleNavigation() {
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530238 this.$root.$emit('toggle-navigation');
Derick Montague602e98a2020-10-21 16:20:00 -0500239 },
Derick Montague80267972021-02-16 09:47:03 -0600240 setFocus(event) {
241 event.preventDefault();
242 this.$root.$emit('skip-navigation');
243 },
Derick Montague602e98a2020-10-21 16:20:00 -0500244 },
Derick Montaguea2988f42020-01-17 13:46:30 -0600245};
246</script>
247
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530248<style lang="scss">
Derick Montague7d4b53b2020-10-26 12:14:16 -0500249@mixin focus-box-shadow($padding-color: $navbar-color, $outline-color: $white) {
Ed Tanous81323992024-02-27 11:26:24 -0800250 box-shadow:
251 inset 0 0 0 3px $padding-color,
252 inset 0 0 0 5px $outline-color;
Derick Montague7d4b53b2020-10-26 12:14:16 -0500253}
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530254.app-header {
255 .link-skip-nav {
256 position: absolute;
257 top: -60px;
258 left: 0.5rem;
259 z-index: $zindex-popover;
260 transition: $duration--moderate-01 $exit-easing--expressive;
261 &:focus {
262 top: 0.5rem;
263 transition-timing-function: $entrance-easing--expressive;
264 }
Derick Montague75b48322019-12-06 01:24:41 -0600265 }
SurenNeware1f8117f2020-09-22 19:28:56 +0530266 .navbar-text,
267 .nav-link,
268 .btn-link {
269 color: color('white') !important;
270 fill: currentColor;
271 padding: 0.68rem 1rem !important;
272
273 &:hover {
274 background-color: theme-color-level(light, 10);
275 }
276 &:active {
277 background-color: theme-color-level(light, 9);
278 }
279 &:focus {
Derick Montague7d4b53b2020-10-26 12:14:16 -0500280 @include focus-box-shadow;
281 outline: 0;
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530282 }
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800283 }
284
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530285 .nav-item {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700286 fill: theme-color('light');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800287 }
288
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530289 .navbar {
290 padding: 0;
Mateusz Gapski21d6de02020-07-29 14:28:23 +0200291 background-color: $navbar-color;
SurenNeware057232b2020-06-08 20:53:26 +0530292 @include media-breakpoint-up($responsive-layout-bp) {
293 height: $header-height;
294 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530295
SurenNeware057232b2020-06-08 20:53:26 +0530296 .helper-menu {
297 @include media-breakpoint-down(sm) {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700298 background-color: gray('800');
SurenNeware057232b2020-06-08 20:53:26 +0530299 width: 100%;
300 justify-content: flex-end;
301
302 .nav-link,
303 .btn {
304 padding: $spacer / 1.125 $spacer / 2;
305 }
Derick Montague7d4b53b2020-10-26 12:14:16 -0500306
307 .nav-link:focus,
308 .btn:focus {
309 @include focus-box-shadow($gray-800);
310 }
SurenNeware057232b2020-06-08 20:53:26 +0530311 }
312
313 .responsive-text {
314 @include media-breakpoint-down(xs) {
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +0530315 @include sr-only;
SurenNeware057232b2020-06-08 20:53:26 +0530316 }
317 }
318 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530319 }
320
321 .navbar-nav {
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +0530322 @include media-breakpoint-up($responsive-layout-bp) {
323 padding: 0 $spacer;
324 }
SurenNeware1f8117f2020-09-22 19:28:56 +0530325 align-items: center;
326
327 .navbar-brand,
328 .nav-link {
329 transition: $focus-transition;
330 }
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +0530331 .nav-tags {
Sukanya Pandeyc5c2ae92020-12-09 16:14:19 +0530332 color: theme-color-level(light, 3);
Sukanya Pandey4dd7eab2021-08-16 18:59:14 +0530333 @include media-breakpoint-down(xs) {
334 @include sr-only;
335 }
336 .asset-tag {
337 @include media-breakpoint-down($responsive-layout-bp) {
338 @include sr-only;
339 }
340 }
Sukanya Pandeyc5c2ae92020-12-09 16:14:19 +0530341 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530342 }
343
344 .nav-trigger {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700345 fill: theme-color('light');
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530346 width: $header-height;
347 height: $header-height;
348 transition: none;
SurenNeware1f8117f2020-09-22 19:28:56 +0530349 display: inline-flex;
350 flex: 0 0 20px;
351 align-items: center;
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530352
353 svg {
354 margin: 0;
355 }
356
357 &:hover {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700358 fill: theme-color('light');
SurenNeware1f8117f2020-09-22 19:28:56 +0530359 background-color: theme-color-level(light, 10);
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530360 }
361
SurenNeware057232b2020-06-08 20:53:26 +0530362 &.open {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700363 background-color: gray('800');
SurenNeware057232b2020-06-08 20:53:26 +0530364 }
365
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530366 @include media-breakpoint-up($responsive-layout-bp) {
367 display: none;
368 }
369 }
370
SurenNeware1f8117f2020-09-22 19:28:56 +0530371 .dropdown-menu {
372 margin-top: 0;
373
374 @include media-breakpoint-only(md) {
375 margin-top: 4px;
SurenNeware057232b2020-06-08 20:53:26 +0530376 }
377 }
378
379 .navbar-expand {
380 @include media-breakpoint-down(sm) {
381 flex-flow: wrap;
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530382 }
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800383 }
384}
SurenNeware1f8117f2020-09-22 19:28:56 +0530385
386.navbar-brand {
387 padding: $spacer/2;
388 height: $header-height;
389 line-height: 1;
390 &:focus {
Ed Tanous81323992024-02-27 11:26:24 -0800391 box-shadow:
392 inset 0 0 0 3px $navbar-color,
393 inset 0 0 0 5px color('white');
SurenNeware1f8117f2020-09-22 19:28:56 +0530394 outline: 0;
395 }
396}
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800397</style>