blob: 568f91881d31a710603b932d73e438f89f387f29 [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>
Mateusz Gapski03505912020-06-25 08:16:51 +020028 <img
29 class="header-logo"
30 src="@/assets/images/logo-header.svg"
31 :alt="altLogo"
32 />
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080033 </b-navbar-nav>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080034 <!-- Right aligned nav items -->
SurenNeware057232b2020-06-08 20:53:26 +053035 <b-navbar-nav class="ml-auto helper-menu">
Derick Montague965cf672020-07-23 17:24:39 -050036 <b-nav-item
37 to="/health/event-logs"
38 data-test-id="appHeader-container-health"
39 >
Derick Montague68592032020-04-04 14:02:34 -050040 <status-icon :status="healthStatusIcon" />
SurenNeware057232b2020-06-08 20:53:26 +053041 {{ $t('appHeader.health') }}
Derick Montague68592032020-04-04 14:02:34 -050042 </b-nav-item>
Derick Montague965cf672020-07-23 17:24:39 -050043 <b-nav-item
44 to="/control/server-power-operations"
45 data-test-id="appHeader-container-power"
46 >
Derick Montague68592032020-04-04 14:02:34 -050047 <status-icon :status="hostStatusIcon" />
SurenNeware057232b2020-06-08 20:53:26 +053048 {{ $t('appHeader.power') }}
Derick Montague68592032020-04-04 14:02:34 -050049 </b-nav-item>
50 <!-- Using LI elements instead of b-nav-item to support semantic button elements -->
51 <li class="nav-item">
Derick Montague965cf672020-07-23 17:24:39 -050052 <b-button
53 id="app-header-refresh"
54 variant="link"
55 data-test-id="appHeader-button-refresh"
56 @click="refresh"
57 >
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080058 <icon-renew />
SurenNeware057232b2020-06-08 20:53:26 +053059 <span class="responsive-text">{{ $t('appHeader.refresh') }}</span>
Derick Montague68592032020-04-04 14:02:34 -050060 </b-button>
61 </li>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053062 <li class="nav-item">
Derick Montague965cf672020-07-23 17:24:39 -050063 <b-dropdown
64 id="app-header-user"
65 variant="link"
66 right
67 data-test-id="appHeader-container-user"
68 >
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053069 <template v-slot:button-content>
70 <icon-avatar />
SurenNeware057232b2020-06-08 20:53:26 +053071 <span class="responsive-text">{{ username }}</span>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053072 </template>
Derick Montague965cf672020-07-23 17:24:39 -050073 <b-dropdown-item
74 to="/profile-settings"
75 data-test-id="appHeader-link-profile"
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053076 >{{ $t('appHeader.profileSettings') }}
77 </b-dropdown-item>
Derick Montague965cf672020-07-23 17:24:39 -050078 <b-dropdown-item
79 data-test-id="appHeader-link-logout"
80 @click="logout"
81 >
82 {{ $t('appHeader.logOut') }}
83 </b-dropdown-item>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053084 </b-dropdown>
Derick Montague68592032020-04-04 14:02:34 -050085 </li>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080086 </b-navbar-nav>
Derick Montaguea2988f42020-01-17 13:46:30 -060087 </b-navbar>
88 </header>
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070089 <loading-bar />
Derick Montaguea2988f42020-01-17 13:46:30 -060090 </div>
91</template>
92
93<script>
Derick Montaguee2fd1562019-12-20 13:26:53 -060094import IconAvatar from '@carbon/icons-vue/es/user--avatar/20';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080095import IconClose from '@carbon/icons-vue/es/close/20';
96import IconMenu from '@carbon/icons-vue/es/menu/20';
Derick Montaguee2fd1562019-12-20 13:26:53 -060097import IconRenew from '@carbon/icons-vue/es/renew/20';
98import StatusIcon from '../Global/StatusIcon';
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070099import LoadingBar from '../Global/LoadingBar';
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800100
Derick Montaguea2988f42020-01-17 13:46:30 -0600101export default {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600102 name: 'AppHeader',
Yoshie Muranaka3be801a2020-04-21 11:34:56 -0700103 components: {
104 IconAvatar,
105 IconClose,
106 IconMenu,
107 IconRenew,
108 StatusIcon,
109 LoadingBar
110 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800111 data() {
112 return {
Mateusz Gapski03505912020-06-25 08:16:51 +0200113 isNavigationOpen: false,
114 altLogo: `${process.env.VUE_APP_COMPANY_NAME} logo`
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800115 };
116 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800117 computed: {
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800118 hostStatus() {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600119 return this.$store.getters['global/hostStatus'];
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800120 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800121 healthStatus() {
122 return this.$store.getters['eventLog/healthStatus'];
123 },
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800124 hostStatusIcon() {
125 switch (this.hostStatus) {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600126 case 'on':
127 return 'success';
128 case 'error':
129 return 'danger';
Yoshie Muranakaa3cbc652020-05-13 12:55:48 -0700130 case 'diagnosticMode':
131 return 'warning';
Derick Montaguee2fd1562019-12-20 13:26:53 -0600132 case 'off':
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800133 default:
Derick Montaguee2fd1562019-12-20 13:26:53 -0600134 return 'secondary';
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800135 }
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800136 },
137 healthStatusIcon() {
138 switch (this.healthStatus) {
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700139 case 'OK':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800140 return 'success';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700141 case 'Warning':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800142 return 'warning';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700143 case 'Critical':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800144 return 'danger';
145 default:
146 return 'secondary';
147 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530148 },
149 username() {
150 return this.$store.getters['global/username'];
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800151 }
152 },
Derick Montague09e45cd2020-01-23 15:45:57 -0600153 created() {
154 this.getHostInfo();
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800155 this.getEvents();
Derick Montague09e45cd2020-01-23 15:45:57 -0600156 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800157 mounted() {
158 this.$root.$on(
159 'change:isNavigationOpen',
160 isNavigationOpen => (this.isNavigationOpen = isNavigationOpen)
161 );
162 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800163 methods: {
164 getHostInfo() {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600165 this.$store.dispatch('global/getHostStatus');
Derick Montaguee080a1a2019-12-04 16:30:08 -0600166 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800167 getEvents() {
168 this.$store.dispatch('eventLog/getEventLogData');
169 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -0800170 refresh() {
171 this.$emit('refresh');
172 },
Derick Montaguee080a1a2019-12-04 16:30:08 -0600173 logout() {
Derick Montaguec031b692020-02-12 15:55:42 -0600174 this.$store.dispatch('authentication/logout');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800175 },
176 toggleNavigation() {
177 this.$root.$emit('toggle:navigation');
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800178 }
Derick Montaguea2988f42020-01-17 13:46:30 -0600179 }
180};
181</script>
182
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530183<style lang="scss">
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530184.app-header {
185 .link-skip-nav {
186 position: absolute;
187 top: -60px;
188 left: 0.5rem;
189 z-index: $zindex-popover;
190 transition: $duration--moderate-01 $exit-easing--expressive;
191 &:focus {
192 top: 0.5rem;
193 transition-timing-function: $entrance-easing--expressive;
194 }
Derick Montague75b48322019-12-06 01:24:41 -0600195 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530196 .navbar-dark {
197 .navbar-text,
198 .nav-link,
199 .btn-link {
200 color: $white !important;
201 fill: currentColor;
202 }
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800203 }
204
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530205 .nav-item {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700206 fill: theme-color('light');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800207 }
208
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530209 .navbar {
210 padding: 0;
SurenNeware057232b2020-06-08 20:53:26 +0530211 @include media-breakpoint-up($responsive-layout-bp) {
212 height: $header-height;
213 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530214
215 .btn-link {
216 padding: $spacer / 2;
217 }
SurenNeware057232b2020-06-08 20:53:26 +0530218
Mateusz Gapski03505912020-06-25 08:16:51 +0200219 .header-logo {
220 width: auto;
221 height: $header-height;
222 padding: $spacer/2 0;
223 }
224
SurenNeware057232b2020-06-08 20:53:26 +0530225 .helper-menu {
226 @include media-breakpoint-down(sm) {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700227 background-color: gray('800');
SurenNeware057232b2020-06-08 20:53:26 +0530228 width: 100%;
229 justify-content: flex-end;
230
231 .nav-link,
232 .btn {
233 padding: $spacer / 1.125 $spacer / 2;
234 }
235 }
236
237 .responsive-text {
238 @include media-breakpoint-down(xs) {
239 display: none;
240 }
241 }
242 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530243 }
244
245 .navbar-nav {
246 padding: 0 $spacer;
247 }
248
249 .nav-trigger {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700250 fill: theme-color('light');
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530251 width: $header-height;
252 height: $header-height;
253 transition: none;
254
255 svg {
256 margin: 0;
257 }
258
259 &:hover {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700260 fill: theme-color('light');
261 background-color: theme-color('dark');
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530262 }
263
SurenNeware057232b2020-06-08 20:53:26 +0530264 &.open {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700265 background-color: gray('800');
SurenNeware057232b2020-06-08 20:53:26 +0530266 }
267
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530268 @include media-breakpoint-up($responsive-layout-bp) {
269 display: none;
270 }
271 }
272
273 .dropdown {
274 .dropdown-menu {
SurenNeware057232b2020-06-08 20:53:26 +0530275 margin-top: 0;
276 @include media-breakpoint-up(md) {
277 margin-top: 7px;
278 }
279 }
280 }
281
282 .navbar-expand {
283 @include media-breakpoint-down(sm) {
284 flex-flow: wrap;
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530285 }
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800286 }
287}
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800288</style>