blob: aadb8e7fed6c050caae63754dc672663cb5125ac [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
Mateusz Gapski21d6de02020-07-29 14:28:23 +02008 <b-navbar type="dark" :aria-label="$t('appHeader.applicationHeader')">
Yoshie Muranakadc04feb2019-12-04 08:41:22 -08009 <!-- Left aligned nav items -->
Yoshie Muranaka74f86872020-02-10 12:28:37 -080010 <b-button
Derick Montague68592032020-04-04 14:02:34 -050011 id="app-header-trigger"
Yoshie Muranaka74f86872020-02-10 12:28:37 -080012 class="nav-trigger"
13 aria-hidden="true"
Yoshie Muranaka74f86872020-02-10 12:28:37 -080014 type="button"
15 variant="link"
SurenNeware057232b2020-06-08 20:53:26 +053016 :class="{ open: isNavigationOpen }"
Yoshie Muranaka74f86872020-02-10 12:28:37 -080017 @click="toggleNavigation"
18 >
SurenNewarea5cbc442020-10-12 15:26:39 +053019 <icon-close
20 v-if="isNavigationOpen"
21 :title="$t('appHeader.titleHideNavigation')"
22 />
23 <icon-menu
24 v-if="!isNavigationOpen"
25 :title="$t('appHeader.titleShowNavigation')"
26 />
Yoshie Muranaka74f86872020-02-10 12:28:37 -080027 </b-button>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080028 <b-navbar-nav>
Dixsie Wolmers76ccbbc2020-08-24 21:25:57 -050029 <b-nav-item to="/" data-test-id="appHeader-container-overview">
30 <img
31 class="header-logo"
32 src="@/assets/images/logo-header.svg"
33 :alt="altLogo"
34 />
35 </b-nav-item>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080036 </b-navbar-nav>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080037 <!-- Right aligned nav items -->
SurenNeware057232b2020-06-08 20:53:26 +053038 <b-navbar-nav class="ml-auto helper-menu">
Derick Montague965cf672020-07-23 17:24:39 -050039 <b-nav-item
40 to="/health/event-logs"
41 data-test-id="appHeader-container-health"
42 >
Derick Montague68592032020-04-04 14:02:34 -050043 <status-icon :status="healthStatusIcon" />
SurenNeware057232b2020-06-08 20:53:26 +053044 {{ $t('appHeader.health') }}
Derick Montague68592032020-04-04 14:02:34 -050045 </b-nav-item>
Derick Montague965cf672020-07-23 17:24:39 -050046 <b-nav-item
47 to="/control/server-power-operations"
48 data-test-id="appHeader-container-power"
49 >
Derick Montague68592032020-04-04 14:02:34 -050050 <status-icon :status="hostStatusIcon" />
SurenNeware057232b2020-06-08 20:53:26 +053051 {{ $t('appHeader.power') }}
Derick Montague68592032020-04-04 14:02:34 -050052 </b-nav-item>
53 <!-- Using LI elements instead of b-nav-item to support semantic button elements -->
54 <li class="nav-item">
Derick Montague965cf672020-07-23 17:24:39 -050055 <b-button
56 id="app-header-refresh"
57 variant="link"
58 data-test-id="appHeader-button-refresh"
59 @click="refresh"
60 >
SurenNewarea5cbc442020-10-12 15:26:39 +053061 <icon-renew :title="$t('appHeader.titleRefresh')" />
SurenNeware057232b2020-06-08 20:53:26 +053062 <span class="responsive-text">{{ $t('appHeader.refresh') }}</span>
Derick Montague68592032020-04-04 14:02:34 -050063 </b-button>
64 </li>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053065 <li class="nav-item">
Derick Montague965cf672020-07-23 17:24:39 -050066 <b-dropdown
67 id="app-header-user"
68 variant="link"
69 right
70 data-test-id="appHeader-container-user"
71 >
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053072 <template v-slot:button-content>
SurenNewarea5cbc442020-10-12 15:26:39 +053073 <icon-avatar :title="$t('appHeader.titleProfile')" />
SurenNeware057232b2020-06-08 20:53:26 +053074 <span class="responsive-text">{{ username }}</span>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053075 </template>
Derick Montague965cf672020-07-23 17:24:39 -050076 <b-dropdown-item
77 to="/profile-settings"
78 data-test-id="appHeader-link-profile"
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053079 >{{ $t('appHeader.profileSettings') }}
80 </b-dropdown-item>
Derick Montague965cf672020-07-23 17:24:39 -050081 <b-dropdown-item
82 data-test-id="appHeader-link-logout"
83 @click="logout"
84 >
85 {{ $t('appHeader.logOut') }}
86 </b-dropdown-item>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053087 </b-dropdown>
Derick Montague68592032020-04-04 14:02:34 -050088 </li>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080089 </b-navbar-nav>
Derick Montaguea2988f42020-01-17 13:46:30 -060090 </b-navbar>
91 </header>
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070092 <loading-bar />
Derick Montaguea2988f42020-01-17 13:46:30 -060093 </div>
94</template>
95
96<script>
Derick Montaguee2fd1562019-12-20 13:26:53 -060097import IconAvatar from '@carbon/icons-vue/es/user--avatar/20';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080098import IconClose from '@carbon/icons-vue/es/close/20';
99import IconMenu from '@carbon/icons-vue/es/menu/20';
Derick Montaguee2fd1562019-12-20 13:26:53 -0600100import IconRenew from '@carbon/icons-vue/es/renew/20';
101import StatusIcon from '../Global/StatusIcon';
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700102import LoadingBar from '../Global/LoadingBar';
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800103
Derick Montaguea2988f42020-01-17 13:46:30 -0600104export default {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600105 name: 'AppHeader',
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700106 components: {
107 IconAvatar,
108 IconClose,
109 IconMenu,
110 IconRenew,
111 StatusIcon,
112 LoadingBar
113 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800114 data() {
115 return {
Mateusz Gapski03505912020-06-25 08:16:51 +0200116 isNavigationOpen: false,
117 altLogo: `${process.env.VUE_APP_COMPANY_NAME} logo`
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800118 };
119 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800120 computed: {
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800121 hostStatus() {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600122 return this.$store.getters['global/hostStatus'];
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800123 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800124 healthStatus() {
125 return this.$store.getters['eventLog/healthStatus'];
126 },
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800127 hostStatusIcon() {
128 switch (this.hostStatus) {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600129 case 'on':
130 return 'success';
131 case 'error':
132 return 'danger';
Yoshie Muranakaa3cbc652020-05-13 12:55:48 -0700133 case 'diagnosticMode':
134 return 'warning';
Derick Montaguee2fd1562019-12-20 13:26:53 -0600135 case 'off':
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800136 default:
Derick Montaguee2fd1562019-12-20 13:26:53 -0600137 return 'secondary';
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800138 }
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800139 },
140 healthStatusIcon() {
141 switch (this.healthStatus) {
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700142 case 'OK':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800143 return 'success';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700144 case 'Warning':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800145 return 'warning';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700146 case 'Critical':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800147 return 'danger';
148 default:
149 return 'secondary';
150 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530151 },
152 username() {
153 return this.$store.getters['global/username'];
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800154 }
155 },
Derick Montague09e45cd2020-01-23 15:45:57 -0600156 created() {
157 this.getHostInfo();
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800158 this.getEvents();
Derick Montague09e45cd2020-01-23 15:45:57 -0600159 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800160 mounted() {
161 this.$root.$on(
162 'change:isNavigationOpen',
163 isNavigationOpen => (this.isNavigationOpen = isNavigationOpen)
164 );
165 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800166 methods: {
167 getHostInfo() {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600168 this.$store.dispatch('global/getHostStatus');
Derick Montaguee080a1a2019-12-04 16:30:08 -0600169 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800170 getEvents() {
171 this.$store.dispatch('eventLog/getEventLogData');
172 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -0800173 refresh() {
174 this.$emit('refresh');
175 },
Derick Montaguee080a1a2019-12-04 16:30:08 -0600176 logout() {
Derick Montaguec031b692020-02-12 15:55:42 -0600177 this.$store.dispatch('authentication/logout');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800178 },
179 toggleNavigation() {
180 this.$root.$emit('toggle:navigation');
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800181 }
Derick Montaguea2988f42020-01-17 13:46:30 -0600182 }
183};
184</script>
185
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530186<style lang="scss">
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530187.app-header {
188 .link-skip-nav {
189 position: absolute;
190 top: -60px;
191 left: 0.5rem;
192 z-index: $zindex-popover;
193 transition: $duration--moderate-01 $exit-easing--expressive;
194 &:focus {
195 top: 0.5rem;
196 transition-timing-function: $entrance-easing--expressive;
197 }
Derick Montague75b48322019-12-06 01:24:41 -0600198 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530199 .navbar-dark {
200 .navbar-text,
201 .nav-link,
202 .btn-link {
SurenNewarea5cbc442020-10-12 15:26:39 +0530203 color: theme-color('light') !important;
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530204 fill: currentColor;
205 }
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800206 }
207
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530208 .nav-item {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700209 fill: theme-color('light');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800210 }
211
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530212 .navbar {
213 padding: 0;
Mateusz Gapski21d6de02020-07-29 14:28:23 +0200214 background-color: $navbar-color;
SurenNeware057232b2020-06-08 20:53:26 +0530215 @include media-breakpoint-up($responsive-layout-bp) {
216 height: $header-height;
217 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530218
219 .btn-link {
220 padding: $spacer / 2;
221 }
SurenNeware057232b2020-06-08 20:53:26 +0530222
Mateusz Gapski03505912020-06-25 08:16:51 +0200223 .header-logo {
224 width: auto;
225 height: $header-height;
226 padding: $spacer/2 0;
227 }
228
SurenNeware057232b2020-06-08 20:53:26 +0530229 .helper-menu {
230 @include media-breakpoint-down(sm) {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700231 background-color: gray('800');
SurenNeware057232b2020-06-08 20:53:26 +0530232 width: 100%;
233 justify-content: flex-end;
234
235 .nav-link,
236 .btn {
237 padding: $spacer / 1.125 $spacer / 2;
238 }
239 }
240
241 .responsive-text {
242 @include media-breakpoint-down(xs) {
243 display: none;
244 }
245 }
246 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530247 }
248
249 .navbar-nav {
250 padding: 0 $spacer;
251 }
252
253 .nav-trigger {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700254 fill: theme-color('light');
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530255 width: $header-height;
256 height: $header-height;
257 transition: none;
258
259 svg {
260 margin: 0;
261 }
262
263 &:hover {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700264 fill: theme-color('light');
265 background-color: theme-color('dark');
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530266 }
267
SurenNeware057232b2020-06-08 20:53:26 +0530268 &.open {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700269 background-color: gray('800');
SurenNeware057232b2020-06-08 20:53:26 +0530270 }
271
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530272 @include media-breakpoint-up($responsive-layout-bp) {
273 display: none;
274 }
275 }
276
277 .dropdown {
278 .dropdown-menu {
SurenNeware057232b2020-06-08 20:53:26 +0530279 margin-top: 0;
280 @include media-breakpoint-up(md) {
281 margin-top: 7px;
282 }
283 }
284 }
285
286 .navbar-expand {
287 @include media-breakpoint-down(sm) {
288 flex-flow: wrap;
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530289 }
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800290 }
291}
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800292</style>