blob: 48a68fc3f7e4a925b28dd797037abeb34a83965d [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"
Yoshie Muranaka74f86872020-02-10 12:28:37 -080021 @click="toggleNavigation"
22 >
23 <icon-close v-if="isNavigationOpen" />
24 <icon-menu v-if="!isNavigationOpen" />
25 </b-button>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080026 <b-navbar-nav>
Yoshie Muranakae0b76c32020-02-28 14:18:20 -080027 <b-nav-text>{{ $t('appHeader.bmcSystemManagement') }}</b-nav-text>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080028 </b-navbar-nav>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080029 <!-- Right aligned nav items -->
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080030 <b-navbar-nav class="ml-auto">
Derick Montague68592032020-04-04 14:02:34 -050031 <b-nav-item>
32 {{ $t('appHeader.health') }}
33 <status-icon :status="healthStatusIcon" />
34 </b-nav-item>
35 <b-nav-item>
36 {{ $t('appHeader.power') }}
37 <status-icon :status="hostStatusIcon" />
38 </b-nav-item>
39 <!-- Using LI elements instead of b-nav-item to support semantic button elements -->
40 <li class="nav-item">
41 <b-button id="app-header-refresh" variant="link" @click="refresh">
Yoshie Muranakae0b76c32020-02-28 14:18:20 -080042 {{ $t('appHeader.refresh') }}
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080043 <icon-renew />
Derick Montague68592032020-04-04 14:02:34 -050044 </b-button>
45 </li>
46 <li>
47 <b-button id="app-header-logout" variant="link" @click="logout">
Yoshie Muranakae0b76c32020-02-28 14:18:20 -080048 {{ $t('appHeader.logOut') }}
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080049 <icon-avatar />
Derick Montague68592032020-04-04 14:02:34 -050050 </b-button>
51 </li>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080052 </b-navbar-nav>
Derick Montaguea2988f42020-01-17 13:46:30 -060053 </b-navbar>
54 </header>
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070055 <loading-bar />
Derick Montaguea2988f42020-01-17 13:46:30 -060056 </div>
57</template>
58
59<script>
Derick Montaguee2fd1562019-12-20 13:26:53 -060060import IconAvatar from '@carbon/icons-vue/es/user--avatar/20';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080061import IconClose from '@carbon/icons-vue/es/close/20';
62import IconMenu from '@carbon/icons-vue/es/menu/20';
Derick Montaguee2fd1562019-12-20 13:26:53 -060063import IconRenew from '@carbon/icons-vue/es/renew/20';
64import StatusIcon from '../Global/StatusIcon';
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070065import LoadingBar from '../Global/LoadingBar';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080066
Derick Montaguea2988f42020-01-17 13:46:30 -060067export default {
Derick Montaguee2fd1562019-12-20 13:26:53 -060068 name: 'AppHeader',
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070069 components: {
70 IconAvatar,
71 IconClose,
72 IconMenu,
73 IconRenew,
74 StatusIcon,
75 LoadingBar
76 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -080077 data() {
78 return {
79 isNavigationOpen: false
80 };
81 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080082 computed: {
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080083 hostStatus() {
Derick Montaguee2fd1562019-12-20 13:26:53 -060084 return this.$store.getters['global/hostStatus'];
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080085 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -080086 healthStatus() {
87 return this.$store.getters['eventLog/healthStatus'];
88 },
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080089 hostStatusIcon() {
90 switch (this.hostStatus) {
Derick Montaguee2fd1562019-12-20 13:26:53 -060091 case 'on':
92 return 'success';
93 case 'error':
94 return 'danger';
Yoshie Muranakaa3cbc652020-05-13 12:55:48 -070095 case 'diagnosticMode':
96 return 'warning';
Derick Montaguee2fd1562019-12-20 13:26:53 -060097 case 'off':
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080098 default:
Derick Montaguee2fd1562019-12-20 13:26:53 -060099 return 'secondary';
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800100 }
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800101 },
102 healthStatusIcon() {
103 switch (this.healthStatus) {
104 case 'good':
105 return 'success';
106 case 'warning':
107 return 'warning';
108 case 'critical':
109 return 'danger';
110 default:
111 return 'secondary';
112 }
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800113 }
114 },
Derick Montague09e45cd2020-01-23 15:45:57 -0600115 created() {
116 this.getHostInfo();
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800117 this.getEvents();
Derick Montague09e45cd2020-01-23 15:45:57 -0600118 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800119 mounted() {
120 this.$root.$on(
121 'change:isNavigationOpen',
122 isNavigationOpen => (this.isNavigationOpen = isNavigationOpen)
123 );
124 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800125 methods: {
126 getHostInfo() {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600127 this.$store.dispatch('global/getHostStatus');
Derick Montaguee080a1a2019-12-04 16:30:08 -0600128 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800129 getEvents() {
130 this.$store.dispatch('eventLog/getEventLogData');
131 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -0800132 refresh() {
133 this.$emit('refresh');
134 },
Derick Montaguee080a1a2019-12-04 16:30:08 -0600135 logout() {
Derick Montaguec031b692020-02-12 15:55:42 -0600136 this.$store.dispatch('authentication/logout');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800137 },
138 toggleNavigation() {
139 this.$root.$emit('toggle:navigation');
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800140 }
Derick Montaguea2988f42020-01-17 13:46:30 -0600141 }
142};
143</script>
144
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800145<style lang="scss" scoped>
Derick Montague40865722020-04-13 17:01:19 -0500146@import 'src/assets/styles/helpers';
147
Derick Montague75b48322019-12-06 01:24:41 -0600148.link-skip-nav {
149 position: absolute;
150 top: -60px;
151 left: 0.5rem;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800152 z-index: $zindex-popover;
153 transition: $duration--moderate-01 $exit-easing--expressive;
Derick Montague75b48322019-12-06 01:24:41 -0600154 &:focus {
155 top: 0.5rem;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800156 transition-timing-function: $entrance-easing--expressive;
Derick Montague75b48322019-12-06 01:24:41 -0600157 }
158}
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800159.navbar-dark {
160 .navbar-text,
Derick Montague68592032020-04-04 14:02:34 -0500161 .nav-link,
162 .btn-link {
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800163 color: $white !important;
Derick Montague68592032020-04-04 14:02:34 -0500164 fill: currentColor;
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800165 }
166}
Derick Montague68592032020-04-04 14:02:34 -0500167
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800168.nav-item {
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800169 fill: $light;
170}
171
172.navbar {
173 padding: 0;
174 height: $header-height;
175 overflow: hidden;
Derick Montague68592032020-04-04 14:02:34 -0500176
177 .btn-link {
178 padding: $spacer / 2;
179 }
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800180}
181
182.navbar-nav {
183 padding: 0 $spacer;
184}
185
186.nav-trigger {
Derick Montague7f970a12020-03-02 17:56:09 -0600187 fill: $light;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800188 width: $header-height;
189 height: $header-height;
190 transition: none;
191
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800192 svg {
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800193 margin: 0;
194 }
195
196 &:hover {
Derick Montague7f970a12020-03-02 17:56:09 -0600197 fill: $light;
198 background-color: $dark;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800199 }
200
201 @include media-breakpoint-up($responsive-layout-bp) {
202 display: none;
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800203 }
204}
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800205</style>