blob: 7f18e1d2877c1dd8e4d97287b872d6bfc822ccac [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>
Yoshie Muranakae0b76c32020-02-28 14:18:20 -080028 <b-nav-text>{{ $t('appHeader.bmcSystemManagement') }}</b-nav-text>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080029 </b-navbar-nav>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080030 <!-- Right aligned nav items -->
SurenNeware057232b2020-06-08 20:53:26 +053031 <b-navbar-nav class="ml-auto helper-menu">
Dixsie Wolmers13cdbcd2020-06-02 08:22:07 -050032 <b-nav-item to="/health/event-logs">
Derick Montague68592032020-04-04 14:02:34 -050033 <status-icon :status="healthStatusIcon" />
SurenNeware057232b2020-06-08 20:53:26 +053034 {{ $t('appHeader.health') }}
Derick Montague68592032020-04-04 14:02:34 -050035 </b-nav-item>
Dixsie Wolmers13cdbcd2020-06-02 08:22:07 -050036 <b-nav-item to="/control/server-power-operations">
Derick Montague68592032020-04-04 14:02:34 -050037 <status-icon :status="hostStatusIcon" />
SurenNeware057232b2020-06-08 20:53:26 +053038 {{ $t('appHeader.power') }}
Derick Montague68592032020-04-04 14:02:34 -050039 </b-nav-item>
40 <!-- Using LI elements instead of b-nav-item to support semantic button elements -->
41 <li class="nav-item">
42 <b-button id="app-header-refresh" variant="link" @click="refresh">
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080043 <icon-renew />
SurenNeware057232b2020-06-08 20:53:26 +053044 <span class="responsive-text">{{ $t('appHeader.refresh') }}</span>
Derick Montague68592032020-04-04 14:02:34 -050045 </b-button>
46 </li>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053047 <li class="nav-item">
48 <b-dropdown id="app-header-user" variant="link" right>
49 <template v-slot:button-content>
50 <icon-avatar />
SurenNeware057232b2020-06-08 20:53:26 +053051 <span class="responsive-text">{{ username }}</span>
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053052 </template>
53 <b-dropdown-item to="/profile-settings"
54 >{{ $t('appHeader.profileSettings') }}
55 </b-dropdown-item>
56 <b-dropdown-item @click="logout">{{
57 $t('appHeader.logOut')
58 }}</b-dropdown-item>
59 </b-dropdown>
Derick Montague68592032020-04-04 14:02:34 -050060 </li>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080061 </b-navbar-nav>
Derick Montaguea2988f42020-01-17 13:46:30 -060062 </b-navbar>
63 </header>
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070064 <loading-bar />
Derick Montaguea2988f42020-01-17 13:46:30 -060065 </div>
66</template>
67
68<script>
Derick Montaguee2fd1562019-12-20 13:26:53 -060069import IconAvatar from '@carbon/icons-vue/es/user--avatar/20';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080070import IconClose from '@carbon/icons-vue/es/close/20';
71import IconMenu from '@carbon/icons-vue/es/menu/20';
Derick Montaguee2fd1562019-12-20 13:26:53 -060072import IconRenew from '@carbon/icons-vue/es/renew/20';
73import StatusIcon from '../Global/StatusIcon';
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070074import LoadingBar from '../Global/LoadingBar';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080075
Derick Montaguea2988f42020-01-17 13:46:30 -060076export default {
Derick Montaguee2fd1562019-12-20 13:26:53 -060077 name: 'AppHeader',
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070078 components: {
79 IconAvatar,
80 IconClose,
81 IconMenu,
82 IconRenew,
83 StatusIcon,
84 LoadingBar
85 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -080086 data() {
87 return {
88 isNavigationOpen: false
89 };
90 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080091 computed: {
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080092 hostStatus() {
Derick Montaguee2fd1562019-12-20 13:26:53 -060093 return this.$store.getters['global/hostStatus'];
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080094 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -080095 healthStatus() {
96 return this.$store.getters['eventLog/healthStatus'];
97 },
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080098 hostStatusIcon() {
99 switch (this.hostStatus) {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600100 case 'on':
101 return 'success';
102 case 'error':
103 return 'danger';
Yoshie Muranakaa3cbc652020-05-13 12:55:48 -0700104 case 'diagnosticMode':
105 return 'warning';
Derick Montaguee2fd1562019-12-20 13:26:53 -0600106 case 'off':
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800107 default:
Derick Montaguee2fd1562019-12-20 13:26:53 -0600108 return 'secondary';
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800109 }
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800110 },
111 healthStatusIcon() {
112 switch (this.healthStatus) {
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700113 case 'OK':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800114 return 'success';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700115 case 'Warning':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800116 return 'warning';
Yoshie Muranakace9a3ef2020-05-06 14:33:22 -0700117 case 'Critical':
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800118 return 'danger';
119 default:
120 return 'secondary';
121 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530122 },
123 username() {
124 return this.$store.getters['global/username'];
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800125 }
126 },
Derick Montague09e45cd2020-01-23 15:45:57 -0600127 created() {
128 this.getHostInfo();
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800129 this.getEvents();
Derick Montague09e45cd2020-01-23 15:45:57 -0600130 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800131 mounted() {
132 this.$root.$on(
133 'change:isNavigationOpen',
134 isNavigationOpen => (this.isNavigationOpen = isNavigationOpen)
135 );
136 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800137 methods: {
138 getHostInfo() {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600139 this.$store.dispatch('global/getHostStatus');
Derick Montaguee080a1a2019-12-04 16:30:08 -0600140 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800141 getEvents() {
142 this.$store.dispatch('eventLog/getEventLogData');
143 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -0800144 refresh() {
145 this.$emit('refresh');
146 },
Derick Montaguee080a1a2019-12-04 16:30:08 -0600147 logout() {
Derick Montaguec031b692020-02-12 15:55:42 -0600148 this.$store.dispatch('authentication/logout');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800149 },
150 toggleNavigation() {
151 this.$root.$emit('toggle:navigation');
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800152 }
Derick Montaguea2988f42020-01-17 13:46:30 -0600153 }
154};
155</script>
156
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530157<style lang="scss">
Derick Montague40865722020-04-13 17:01:19 -0500158@import 'src/assets/styles/helpers';
159
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530160.app-header {
161 .link-skip-nav {
162 position: absolute;
163 top: -60px;
164 left: 0.5rem;
165 z-index: $zindex-popover;
166 transition: $duration--moderate-01 $exit-easing--expressive;
167 &:focus {
168 top: 0.5rem;
169 transition-timing-function: $entrance-easing--expressive;
170 }
Derick Montague75b48322019-12-06 01:24:41 -0600171 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530172 .navbar-dark {
173 .navbar-text,
174 .nav-link,
175 .btn-link {
176 color: $white !important;
177 fill: currentColor;
178 }
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800179 }
180
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530181 .nav-item {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700182 fill: theme-color('light');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800183 }
184
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530185 .navbar {
186 padding: 0;
SurenNeware057232b2020-06-08 20:53:26 +0530187 @include media-breakpoint-up($responsive-layout-bp) {
188 height: $header-height;
189 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530190
191 .btn-link {
192 padding: $spacer / 2;
193 }
SurenNeware057232b2020-06-08 20:53:26 +0530194
195 .helper-menu {
196 @include media-breakpoint-down(sm) {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700197 background-color: gray('800');
SurenNeware057232b2020-06-08 20:53:26 +0530198 width: 100%;
199 justify-content: flex-end;
200
201 .nav-link,
202 .btn {
203 padding: $spacer / 1.125 $spacer / 2;
204 }
205 }
206
207 .responsive-text {
208 @include media-breakpoint-down(xs) {
209 display: none;
210 }
211 }
212 }
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530213 }
214
215 .navbar-nav {
216 padding: 0 $spacer;
217 }
218
219 .nav-trigger {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700220 fill: theme-color('light');
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530221 width: $header-height;
222 height: $header-height;
223 transition: none;
224
225 svg {
226 margin: 0;
227 }
228
229 &:hover {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700230 fill: theme-color('light');
231 background-color: theme-color('dark');
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530232 }
233
SurenNeware057232b2020-06-08 20:53:26 +0530234 &.open {
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700235 background-color: gray('800');
SurenNeware057232b2020-06-08 20:53:26 +0530236 }
237
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530238 @include media-breakpoint-up($responsive-layout-bp) {
239 display: none;
240 }
241 }
242
243 .dropdown {
244 .dropdown-menu {
SurenNeware057232b2020-06-08 20:53:26 +0530245 margin-top: 0;
246 @include media-breakpoint-up(md) {
247 margin-top: 7px;
248 }
249 }
250 }
251
252 .navbar-expand {
253 @include media-breakpoint-down(sm) {
254 flex-flow: wrap;
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +0530255 }
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800256 }
257}
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800258</style>