1<template> 2 <div> 3 <header id="page-header"> 4 <a 5 class="link-skip-nav btn btn-light" 6 href="#main-content" 7 @click="setFocus" 8 > 9 {{ $t('appHeader.skipToContent') }} 10 </a> 11 12 <b-navbar type="dark" :aria-label="$t('appHeader.applicationHeader')"> 13 <!-- Left aligned nav items --> 14 <b-button 15 id="app-header-trigger" 16 class="nav-trigger" 17 aria-hidden="true" 18 type="button" 19 variant="link" 20 :class="{ open: isNavigationOpen }" 21 @click="toggleNavigation" 22 > 23 <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 /> 31 </b-button> 32 <b-navbar-nav> 33 <b-navbar-brand 34 class="mr-0" 35 to="/" 36 data-test-id="appHeader-container-overview" 37 > 38 <img 39 svg-inline 40 class="header-logo" 41 src="@/assets/images/logo-header.svg" 42 :alt="altLogo" 43 /> 44 </b-navbar-brand> 45 <div v-if="isNavTagPresent" :key="routerKey" class="pl-2 nav-tags"> 46 <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> 50 </div> 51 </b-navbar-nav> 52 <!-- Right aligned nav items --> 53 <b-navbar-nav class="ml-auto helper-menu"> 54 <b-nav-item 55 to="/logs/event-logs" 56 data-test-id="appHeader-container-health" 57 > 58 <status-icon :status="healthStatusIcon" /> 59 {{ $t('appHeader.health') }} 60 </b-nav-item> 61 <b-nav-item 62 to="/operations/server-power-operations" 63 data-test-id="appHeader-container-power" 64 > 65 <status-icon :status="serverStatusIcon" /> 66 {{ $t('appHeader.power') }} 67 </b-nav-item> 68 <!-- Using LI elements instead of b-nav-item to support semantic button elements --> 69 <li class="nav-item"> 70 <b-button 71 id="app-header-refresh" 72 variant="link" 73 data-test-id="appHeader-button-refresh" 74 @click="refresh" 75 > 76 <icon-renew :title="$t('appHeader.titleRefresh')" /> 77 <span class="responsive-text">{{ $t('appHeader.refresh') }}</span> 78 </b-button> 79 </li> 80 <li class="nav-item"> 81 <b-dropdown 82 id="app-header-user" 83 variant="link" 84 right 85 data-test-id="appHeader-container-user" 86 > 87 <template #button-content> 88 <icon-avatar :title="$t('appHeader.titleProfile')" /> 89 <span class="responsive-text">{{ username }}</span> 90 </template> 91 <b-dropdown-item 92 to="/profile-settings" 93 data-test-id="appHeader-link-profile" 94 >{{ $t('appHeader.profileSettings') }} 95 </b-dropdown-item> 96 <b-dropdown-item 97 data-test-id="appHeader-link-logout" 98 @click="logout" 99 > 100 {{ $t('appHeader.logOut') }} 101 </b-dropdown-item> 102 </b-dropdown> 103 </li> 104 </b-navbar-nav> 105 </b-navbar> 106 </header> 107 <loading-bar /> 108 </div> 109</template> 110 111<script> 112import BVToastMixin from '@/components/Mixins/BVToastMixin'; 113import IconAvatar from '@carbon/icons-vue/es/user--avatar/20'; 114import IconClose from '@carbon/icons-vue/es/close/20'; 115import IconMenu from '@carbon/icons-vue/es/menu/20'; 116import IconRenew from '@carbon/icons-vue/es/renew/20'; 117import StatusIcon from '@/components/Global/StatusIcon'; 118import LoadingBar from '@/components/Global/LoadingBar'; 119import { useI18n } from 'vue-i18n'; 120import { mapState } from 'vuex'; 121 122export default { 123 name: 'AppHeader', 124 components: { 125 IconAvatar, 126 IconClose, 127 IconMenu, 128 IconRenew, 129 StatusIcon, 130 LoadingBar, 131 }, 132 mixins: [BVToastMixin], 133 props: { 134 routerKey: { 135 type: Number, 136 default: 0, 137 }, 138 }, 139 data() { 140 return { 141 $t: useI18n().t, 142 isNavigationOpen: false, 143 altLogo: process.env.VUE_APP_COMPANY_NAME || 'Built on OpenBMC', 144 }; 145 }, 146 computed: { 147 ...mapState('authentication', ['consoleWindow']), 148 isNavTagPresent() { 149 return this.assetTag || this.modelType || this.serialNumber; 150 }, 151 assetTag() { 152 return this.$store.getters['global/assetTag']; 153 }, 154 modelType() { 155 return this.$store.getters['global/modelType']; 156 }, 157 serialNumber() { 158 return this.$store.getters['global/serialNumber']; 159 }, 160 isAuthorized() { 161 return this.$store.getters['global/isAuthorized']; 162 }, 163 userPrivilege() { 164 return this.$store.getters['global/userPrivilege']; 165 }, 166 serverStatus() { 167 return this.$store.getters['global/serverStatus']; 168 }, 169 healthStatus() { 170 return this.$store.getters['eventLog/healthStatus']; 171 }, 172 serverStatusIcon() { 173 switch (this.serverStatus) { 174 case 'on': 175 return 'success'; 176 case 'error': 177 return 'danger'; 178 case 'diagnosticMode': 179 return 'warning'; 180 case 'off': 181 default: 182 return 'secondary'; 183 } 184 }, 185 healthStatusIcon() { 186 switch (this.healthStatus) { 187 case 'OK': 188 return 'success'; 189 case 'Warning': 190 return 'warning'; 191 case 'Critical': 192 return 'danger'; 193 default: 194 return 'secondary'; 195 } 196 }, 197 username() { 198 return this.$store.getters['global/username']; 199 }, 200 }, 201 watch: { 202 consoleWindow() { 203 if (this.consoleWindow === false) this.$eventBus.$consoleWindow?.close(); 204 }, 205 isAuthorized(value) { 206 if (value === false) { 207 this.errorToast(this.$t('global.toast.unAuthDescription'), { 208 title: this.$t('global.toast.unAuthTitle'), 209 }); 210 } 211 }, 212 }, 213 created() { 214 // Reset auth state to check if user is authenticated based 215 // on available browser cookies 216 this.$store.dispatch('authentication/resetStoreState'); 217 this.getSystemInfo(); 218 this.getEvents(); 219 }, 220 mounted() { 221 this.$root.$on( 222 'change-is-navigation-open', 223 (isNavigationOpen) => (this.isNavigationOpen = isNavigationOpen), 224 ); 225 }, 226 methods: { 227 getSystemInfo() { 228 this.$store.dispatch('global/getSystemInfo'); 229 }, 230 getEvents() { 231 this.$store.dispatch('eventLog/getEventLogData'); 232 }, 233 refresh() { 234 this.$emit('refresh'); 235 }, 236 logout() { 237 this.$store.dispatch('authentication/logout'); 238 }, 239 toggleNavigation() { 240 this.$root.$emit('toggle-navigation'); 241 }, 242 setFocus(event) { 243 event.preventDefault(); 244 this.$root.$emit('skip-navigation'); 245 }, 246 }, 247}; 248</script> 249 250<style lang="scss"> 251@import '@/assets/styles/bmc/helpers/_index.scss'; 252@import '@/assets/styles/bootstrap/_helpers.scss'; 253 254@mixin focus-box-shadow($padding-color: $navbar-color, $outline-color: $white) { 255 box-shadow: 256 inset 0 0 0 3px $padding-color, 257 inset 0 0 0 5px $outline-color; 258} 259.app-header { 260 .link-skip-nav { 261 position: absolute; 262 top: -60px; 263 left: 0.5rem; 264 //z-index: $zindex-popover; 265 //transition: $duration--moderate-01 $exit-easing--expressive; 266 &:focus { 267 top: 0.5rem; 268 //transition-timing-function: $entrance-easing--expressive; 269 } 270 } 271 .navbar-text, 272 .nav-link, 273 .btn-link { 274 color: color('white') !important; 275 fill: currentColor; 276 padding: 0.68rem 1rem !important; 277 278 &:hover { 279 background-color: theme-color-level(light, 10); 280 } 281 &:active { 282 background-color: theme-color-level(light, 9); 283 } 284 &:focus { 285 @include focus-box-shadow; 286 outline: 0; 287 } 288 } 289 290 .nav-item { 291 fill: theme-color('light'); 292 } 293 294 .navbar { 295 padding: 0; 296 background-color: $navbar-color; 297 298 @include media-breakpoint-up($responsive-layout-bp) { 299 height: $header-height; 300 } 301 302 .helper-menu { 303 @include media-breakpoint-down(sm) { 304 background-color: gray('800'); 305 width: 100%; 306 justify-content: flex-end; 307 308 .nav-link, 309 .btn { 310 padding: $spacer / 1.125 $spacer / 2; 311 } 312 313 .nav-link:focus, 314 .btn:focus { 315 @include focus-box-shadow($gray-800); 316 } 317 } 318 319 .responsive-text { 320 @include media-breakpoint-down(xs) { 321 @include sr-only; 322 } 323 } 324 } 325 } 326 327 .navbar-nav { 328 @include media-breakpoint-up($responsive-layout-bp) { 329 padding: 0 $spacer; 330 } 331 align-items: center; 332 333 .navbar-brand, 334 .nav-link { 335 transition: $focus-transition; 336 } 337 .nav-tags { 338 color: theme-color-level(light, 3); 339 @include media-breakpoint-down(xs) { 340 @include sr-only; 341 } 342 .asset-tag { 343 @include media-breakpoint-down($responsive-layout-bp) { 344 @include sr-only; 345 } 346 } 347 } 348 } 349 350 .nav-trigger { 351 fill: theme-color('light'); 352 width: $header-height; 353 height: $header-height; 354 transition: none; 355 display: inline-flex; 356 flex: 0 0 20px; 357 align-items: center; 358 359 svg { 360 margin: 0; 361 } 362 363 &:hover { 364 fill: theme-color('light'); 365 background-color: theme-color-level(light, 10); 366 } 367 368 &.open { 369 background-color: gray('800'); 370 } 371 372 @include media-breakpoint-up($responsive-layout-bp) { 373 display: none; 374 } 375 } 376 377 .dropdown-menu { 378 margin-top: 0; 379 380 @include media-breakpoint-only(md) { 381 margin-top: 4px; 382 } 383 } 384 385 .navbar-expand { 386 @include media-breakpoint-down(sm) { 387 flex-flow: wrap; 388 } 389 } 390} 391 392.navbar-brand { 393 padding: $spacer/2; 394 height: $header-height; 395 line-height: 1; 396 &:focus { 397 box-shadow: 398 inset 0 0 0 3px $navbar-color, 399 inset 0 0 0 5px color('white'); 400 outline: 0; 401 } 402} 403</style> 404