blob: bdaca017c1a05e3c1e5378a1c5c458c2bf7b3fa4 [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"
14 title="Open navigation"
15 type="button"
16 variant="link"
SurenNeware057232b2020-06-08 20:53:26 +053017 :class="{ open: isNavigationOpen }"
Yoshie Muranaka74f86872020-02-10 12:28:37 -080018 @click="toggleNavigation"
19 >
20 <icon-close v-if="isNavigationOpen" />
21 <icon-menu v-if="!isNavigationOpen" />
22 </b-button>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080023 <b-navbar-nav>
Dixsie Wolmers76ccbbc2020-08-24 21:25:57 -050024 <b-nav-item to="/" data-test-id="appHeader-container-overview">
25 <img
26 class="header-logo"
27 src="@/assets/images/logo-header.svg"
28 :alt="altLogo"
29 />
30 </b-nav-item>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080031 </b-navbar-nav>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080032 <!-- Right aligned nav items -->
SurenNeware057232b2020-06-08 20:53:26 +053033 <b-navbar-nav class="ml-auto helper-menu">
Derick Montague965cf672020-07-23 17:24:39 -050034 <b-nav-item
35 to="/health/event-logs"
36 data-test-id="appHeader-container-health"
37 >
Derick Montague68592032020-04-04 14:02:34 -050038 <status-icon :status="healthStatusIcon" />
SurenNeware057232b2020-06-08 20:53:26 +053039 {{ $t('appHeader.health') }}
Derick Montague68592032020-04-04 14:02:34 -050040 </b-nav-item>
Derick Montague965cf672020-07-23 17:24:39 -050041 <b-nav-item
42 to="/control/server-power-operations"
43 data-test-id="appHeader-container-power"
44 >
Derick Montague68592032020-04-04 14:02:34 -050045 <status-icon :status="hostStatusIcon" />
SurenNeware057232b2020-06-08 20:53:26 +053046 {{ $t('appHeader.power') }}
Derick Montague68592032020-04-04 14:02:34 -050047 </b-nav-item>
48 <!-- Using LI elements instead of b-nav-item to support semantic button elements -->
49 <li class="nav-item">
Derick Montague965cf672020-07-23 17:24:39 -050050 <b-button
51 id="app-header-refresh"
52 variant="link"
53 data-test-id="appHeader-button-refresh"
54 @click="refresh"
55 >
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080056 <icon-renew />
SurenNeware057232b2020-06-08 20:53:26 +053057 <span class="responsive-text">{{ $t('appHeader.refresh') }}</span>
Derick Montague68592032020-04-04 14:02:34 -050058 </b-button>
59 </li>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053060 <li class="nav-item">
Derick Montague965cf672020-07-23 17:24:39 -050061 <b-dropdown
62 id="app-header-user"
63 variant="link"
64 right
65 data-test-id="appHeader-container-user"
66 >
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053067 <template v-slot:button-content>
68 <icon-avatar />
SurenNeware057232b2020-06-08 20:53:26 +053069 <span class="responsive-text">{{ username }}</span>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053070 </template>
Derick Montague965cf672020-07-23 17:24:39 -050071 <b-dropdown-item
72 to="/profile-settings"
73 data-test-id="appHeader-link-profile"
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053074 >{{ $t('appHeader.profileSettings') }}
75 </b-dropdown-item>
Derick Montague965cf672020-07-23 17:24:39 -050076 <b-dropdown-item
77 data-test-id="appHeader-link-logout"
78 @click="logout"
79 >
80 {{ $t('appHeader.logOut') }}
81 </b-dropdown-item>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053082 </b-dropdown>
Derick Montague68592032020-04-04 14:02:34 -050083 </li>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080084 </b-navbar-nav>
Derick Montaguea2988f42020-01-17 13:46:30 -060085 </b-navbar>
86 </header>
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070087 <loading-bar />
Derick Montaguea2988f42020-01-17 13:46:30 -060088 </div>
89</template>
90
91<script>
Derick Montaguee2fd1562019-12-20 13:26:53 -060092import IconAvatar from '@carbon/icons-vue/es/user--avatar/20';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080093import IconClose from '@carbon/icons-vue/es/close/20';
94import IconMenu from '@carbon/icons-vue/es/menu/20';
Derick Montaguee2fd1562019-12-20 13:26:53 -060095import IconRenew from '@carbon/icons-vue/es/renew/20';
96import StatusIcon from '../Global/StatusIcon';
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070097import LoadingBar from '../Global/LoadingBar';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080098
Derick Montaguea2988f42020-01-17 13:46:30 -060099export default {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600100 name: 'AppHeader',
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700101 components: {
102 IconAvatar,
103 IconClose,
104 IconMenu,
105 IconRenew,
106 StatusIcon,
107 LoadingBar
108 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800109 data() {
110 return {
Mateusz Gapski03505912020-06-25 08:16:51 +0200111 isNavigationOpen: false,
112 altLogo: `${process.env.VUE_APP_COMPANY_NAME} logo`
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800113 };
114 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800115 computed: {
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800116 hostStatus() {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600117 return this.$store.getters['global/hostStatus'];
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800118 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800119 healthStatus() {
120 return this.$store.getters['eventLog/healthStatus'];
121 },
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800122 hostStatusIcon() {
123 switch (this.hostStatus) {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600124 case 'on':
125 return 'success';
126 case 'error':
127 return 'danger';
Yoshie Muranakaa3cbc652020-05-13 12:55:48 -0700128 case 'diagnosticMode':
129 return 'warning';
Derick Montaguee2fd1562019-12-20 13:26:53 -0600130 case 'off':
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800131 default:
Derick Montaguee2fd1562019-12-20 13:26:53 -0600132 return 'secondary';
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800133 }
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800134 },
135 healthStatusIcon() {
136 switch (this.healthStatus) {
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700137 case 'OK':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800138 return 'success';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700139 case 'Warning':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800140 return 'warning';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700141 case 'Critical':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800142 return 'danger';
143 default:
144 return 'secondary';
145 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530146 },
147 username() {
148 return this.$store.getters['global/username'];
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800149 }
150 },
Derick Montague09e45cd2020-01-23 15:45:57 -0600151 created() {
152 this.getHostInfo();
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800153 this.getEvents();
Derick Montague09e45cd2020-01-23 15:45:57 -0600154 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800155 mounted() {
156 this.$root.$on(
157 'change:isNavigationOpen',
158 isNavigationOpen => (this.isNavigationOpen = isNavigationOpen)
159 );
160 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800161 methods: {
162 getHostInfo() {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600163 this.$store.dispatch('global/getHostStatus');
Derick Montaguee080a1a2019-12-04 16:30:08 -0600164 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800165 getEvents() {
166 this.$store.dispatch('eventLog/getEventLogData');
167 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -0800168 refresh() {
169 this.$emit('refresh');
170 },
Derick Montaguee080a1a2019-12-04 16:30:08 -0600171 logout() {
Derick Montaguec031b692020-02-12 15:55:42 -0600172 this.$store.dispatch('authentication/logout');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800173 },
174 toggleNavigation() {
175 this.$root.$emit('toggle:navigation');
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800176 }
Derick Montaguea2988f42020-01-17 13:46:30 -0600177 }
178};
179</script>
180
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530181<style lang="scss">
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530182.app-header {
183 .link-skip-nav {
184 position: absolute;
185 top: -60px;
186 left: 0.5rem;
187 z-index: $zindex-popover;
188 transition: $duration--moderate-01 $exit-easing--expressive;
189 &:focus {
190 top: 0.5rem;
191 transition-timing-function: $entrance-easing--expressive;
192 }
Derick Montague75b48322019-12-06 01:24:41 -0600193 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530194 .navbar-dark {
195 .navbar-text,
196 .nav-link,
197 .btn-link {
198 color: $white !important;
199 fill: currentColor;
200 }
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800201 }
202
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530203 .nav-item {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700204 fill: theme-color('light');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800205 }
206
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530207 .navbar {
208 padding: 0;
Mateusz Gapski21d6de02020-07-29 14:28:23 +0200209 background-color: $navbar-color;
SurenNeware057232b2020-06-08 20:53:26 +0530210 @include media-breakpoint-up($responsive-layout-bp) {
211 height: $header-height;
212 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530213
214 .btn-link {
215 padding: $spacer / 2;
216 }
SurenNeware057232b2020-06-08 20:53:26 +0530217
Mateusz Gapski03505912020-06-25 08:16:51 +0200218 .header-logo {
219 width: auto;
220 height: $header-height;
221 padding: $spacer/2 0;
222 }
223
SurenNeware057232b2020-06-08 20:53:26 +0530224 .helper-menu {
225 @include media-breakpoint-down(sm) {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700226 background-color: gray('800');
SurenNeware057232b2020-06-08 20:53:26 +0530227 width: 100%;
228 justify-content: flex-end;
229
230 .nav-link,
231 .btn {
232 padding: $spacer / 1.125 $spacer / 2;
233 }
234 }
235
236 .responsive-text {
237 @include media-breakpoint-down(xs) {
238 display: none;
239 }
240 }
241 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530242 }
243
244 .navbar-nav {
245 padding: 0 $spacer;
246 }
247
248 .nav-trigger {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700249 fill: theme-color('light');
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530250 width: $header-height;
251 height: $header-height;
252 transition: none;
253
254 svg {
255 margin: 0;
256 }
257
258 &:hover {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700259 fill: theme-color('light');
260 background-color: theme-color('dark');
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530261 }
262
SurenNeware057232b2020-06-08 20:53:26 +0530263 &.open {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700264 background-color: gray('800');
SurenNeware057232b2020-06-08 20:53:26 +0530265 }
266
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530267 @include media-breakpoint-up($responsive-layout-bp) {
268 display: none;
269 }
270 }
271
272 .dropdown {
273 .dropdown-menu {
SurenNeware057232b2020-06-08 20:53:26 +0530274 margin-top: 0;
275 @include media-breakpoint-up(md) {
276 margin-top: 7px;
277 }
278 }
279 }
280
281 .navbar-expand {
282 @include media-breakpoint-down(sm) {
283 flex-flow: wrap;
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530284 }
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800285 }
286}
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800287</style>