blob: 0ae18bebb10e76470697f1b665196a6cb609ce67 [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"
SurenNeware057232b2020-06-08 20:53:26 +053021 :class="{ open: isNavigationOpen }"
Yoshie Muranaka74f86872020-02-10 12:28:37 -080022 @click="toggleNavigation"
23 >
24 <icon-close v-if="isNavigationOpen" />
25 <icon-menu v-if="!isNavigationOpen" />
26 </b-button>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080027 <b-navbar-nav>
Dixsie Wolmers76ccbbc2020-08-24 21:25:57 -050028 <b-nav-item to="/" data-test-id="appHeader-container-overview">
29 <img
30 class="header-logo"
31 src="@/assets/images/logo-header.svg"
32 :alt="altLogo"
33 />
34 </b-nav-item>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080035 </b-navbar-nav>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080036 <!-- Right aligned nav items -->
SurenNeware057232b2020-06-08 20:53:26 +053037 <b-navbar-nav class="ml-auto helper-menu">
Derick Montague965cf672020-07-23 17:24:39 -050038 <b-nav-item
39 to="/health/event-logs"
40 data-test-id="appHeader-container-health"
41 >
Derick Montague68592032020-04-04 14:02:34 -050042 <status-icon :status="healthStatusIcon" />
SurenNeware057232b2020-06-08 20:53:26 +053043 {{ $t('appHeader.health') }}
Derick Montague68592032020-04-04 14:02:34 -050044 </b-nav-item>
Derick Montague965cf672020-07-23 17:24:39 -050045 <b-nav-item
46 to="/control/server-power-operations"
47 data-test-id="appHeader-container-power"
48 >
Derick Montague68592032020-04-04 14:02:34 -050049 <status-icon :status="hostStatusIcon" />
SurenNeware057232b2020-06-08 20:53:26 +053050 {{ $t('appHeader.power') }}
Derick Montague68592032020-04-04 14:02:34 -050051 </b-nav-item>
52 <!-- Using LI elements instead of b-nav-item to support semantic button elements -->
53 <li class="nav-item">
Derick Montague965cf672020-07-23 17:24:39 -050054 <b-button
55 id="app-header-refresh"
56 variant="link"
57 data-test-id="appHeader-button-refresh"
58 @click="refresh"
59 >
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080060 <icon-renew />
SurenNeware057232b2020-06-08 20:53:26 +053061 <span class="responsive-text">{{ $t('appHeader.refresh') }}</span>
Derick Montague68592032020-04-04 14:02:34 -050062 </b-button>
63 </li>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053064 <li class="nav-item">
Derick Montague965cf672020-07-23 17:24:39 -050065 <b-dropdown
66 id="app-header-user"
67 variant="link"
68 right
69 data-test-id="appHeader-container-user"
70 >
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053071 <template v-slot:button-content>
72 <icon-avatar />
SurenNeware057232b2020-06-08 20:53:26 +053073 <span class="responsive-text">{{ username }}</span>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053074 </template>
Derick Montague965cf672020-07-23 17:24:39 -050075 <b-dropdown-item
76 to="/profile-settings"
77 data-test-id="appHeader-link-profile"
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053078 >{{ $t('appHeader.profileSettings') }}
79 </b-dropdown-item>
Derick Montague965cf672020-07-23 17:24:39 -050080 <b-dropdown-item
81 data-test-id="appHeader-link-logout"
82 @click="logout"
83 >
84 {{ $t('appHeader.logOut') }}
85 </b-dropdown-item>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053086 </b-dropdown>
Derick Montague68592032020-04-04 14:02:34 -050087 </li>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080088 </b-navbar-nav>
Derick Montaguea2988f42020-01-17 13:46:30 -060089 </b-navbar>
90 </header>
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070091 <loading-bar />
Derick Montaguea2988f42020-01-17 13:46:30 -060092 </div>
93</template>
94
95<script>
Derick Montaguee2fd1562019-12-20 13:26:53 -060096import IconAvatar from '@carbon/icons-vue/es/user--avatar/20';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080097import IconClose from '@carbon/icons-vue/es/close/20';
98import IconMenu from '@carbon/icons-vue/es/menu/20';
Derick Montaguee2fd1562019-12-20 13:26:53 -060099import IconRenew from '@carbon/icons-vue/es/renew/20';
100import StatusIcon from '../Global/StatusIcon';
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700101import LoadingBar from '../Global/LoadingBar';
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800102
Derick Montaguea2988f42020-01-17 13:46:30 -0600103export default {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600104 name: 'AppHeader',
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700105 components: {
106 IconAvatar,
107 IconClose,
108 IconMenu,
109 IconRenew,
110 StatusIcon,
111 LoadingBar
112 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800113 data() {
114 return {
Mateusz Gapski03505912020-06-25 08:16:51 +0200115 isNavigationOpen: false,
116 altLogo: `${process.env.VUE_APP_COMPANY_NAME} logo`
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800117 };
118 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800119 computed: {
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800120 hostStatus() {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600121 return this.$store.getters['global/hostStatus'];
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800122 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800123 healthStatus() {
124 return this.$store.getters['eventLog/healthStatus'];
125 },
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800126 hostStatusIcon() {
127 switch (this.hostStatus) {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600128 case 'on':
129 return 'success';
130 case 'error':
131 return 'danger';
Yoshie Muranakaa3cbc652020-05-13 12:55:48 -0700132 case 'diagnosticMode':
133 return 'warning';
Derick Montaguee2fd1562019-12-20 13:26:53 -0600134 case 'off':
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800135 default:
Derick Montaguee2fd1562019-12-20 13:26:53 -0600136 return 'secondary';
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800137 }
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800138 },
139 healthStatusIcon() {
140 switch (this.healthStatus) {
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700141 case 'OK':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800142 return 'success';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700143 case 'Warning':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800144 return 'warning';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700145 case 'Critical':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800146 return 'danger';
147 default:
148 return 'secondary';
149 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530150 },
151 username() {
152 return this.$store.getters['global/username'];
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800153 }
154 },
Derick Montague09e45cd2020-01-23 15:45:57 -0600155 created() {
156 this.getHostInfo();
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800157 this.getEvents();
Derick Montague09e45cd2020-01-23 15:45:57 -0600158 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800159 mounted() {
160 this.$root.$on(
161 'change:isNavigationOpen',
162 isNavigationOpen => (this.isNavigationOpen = isNavigationOpen)
163 );
164 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800165 methods: {
166 getHostInfo() {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600167 this.$store.dispatch('global/getHostStatus');
Derick Montaguee080a1a2019-12-04 16:30:08 -0600168 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800169 getEvents() {
170 this.$store.dispatch('eventLog/getEventLogData');
171 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -0800172 refresh() {
173 this.$emit('refresh');
174 },
Derick Montaguee080a1a2019-12-04 16:30:08 -0600175 logout() {
Derick Montaguec031b692020-02-12 15:55:42 -0600176 this.$store.dispatch('authentication/logout');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800177 },
178 toggleNavigation() {
179 this.$root.$emit('toggle:navigation');
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800180 }
Derick Montaguea2988f42020-01-17 13:46:30 -0600181 }
182};
183</script>
184
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530185<style lang="scss">
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530186.app-header {
187 .link-skip-nav {
188 position: absolute;
189 top: -60px;
190 left: 0.5rem;
191 z-index: $zindex-popover;
192 transition: $duration--moderate-01 $exit-easing--expressive;
193 &:focus {
194 top: 0.5rem;
195 transition-timing-function: $entrance-easing--expressive;
196 }
Derick Montague75b48322019-12-06 01:24:41 -0600197 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530198 .navbar-dark {
199 .navbar-text,
200 .nav-link,
201 .btn-link {
202 color: $white !important;
203 fill: currentColor;
204 }
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800205 }
206
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530207 .nav-item {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700208 fill: theme-color('light');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800209 }
210
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530211 .navbar {
212 padding: 0;
SurenNeware057232b2020-06-08 20:53:26 +0530213 @include media-breakpoint-up($responsive-layout-bp) {
214 height: $header-height;
215 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530216
217 .btn-link {
218 padding: $spacer / 2;
219 }
SurenNeware057232b2020-06-08 20:53:26 +0530220
Mateusz Gapski03505912020-06-25 08:16:51 +0200221 .header-logo {
222 width: auto;
223 height: $header-height;
224 padding: $spacer/2 0;
225 }
226
SurenNeware057232b2020-06-08 20:53:26 +0530227 .helper-menu {
228 @include media-breakpoint-down(sm) {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700229 background-color: gray('800');
SurenNeware057232b2020-06-08 20:53:26 +0530230 width: 100%;
231 justify-content: flex-end;
232
233 .nav-link,
234 .btn {
235 padding: $spacer / 1.125 $spacer / 2;
236 }
237 }
238
239 .responsive-text {
240 @include media-breakpoint-down(xs) {
241 display: none;
242 }
243 }
244 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530245 }
246
247 .navbar-nav {
248 padding: 0 $spacer;
249 }
250
251 .nav-trigger {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700252 fill: theme-color('light');
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530253 width: $header-height;
254 height: $header-height;
255 transition: none;
256
257 svg {
258 margin: 0;
259 }
260
261 &:hover {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700262 fill: theme-color('light');
263 background-color: theme-color('dark');
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530264 }
265
SurenNeware057232b2020-06-08 20:53:26 +0530266 &.open {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700267 background-color: gray('800');
SurenNeware057232b2020-06-08 20:53:26 +0530268 }
269
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530270 @include media-breakpoint-up($responsive-layout-bp) {
271 display: none;
272 }
273 }
274
275 .dropdown {
276 .dropdown-menu {
SurenNeware057232b2020-06-08 20:53:26 +0530277 margin-top: 0;
278 @include media-breakpoint-up(md) {
279 margin-top: 7px;
280 }
281 }
282 }
283
284 .navbar-expand {
285 @include media-breakpoint-down(sm) {
286 flex-flow: wrap;
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530287 }
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800288 }
289}
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800290</style>