blob: 2ad208fc8d96c6e9608d025dee3e43101ce1038d [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"
Yoshie Muranaka74f86872020-02-10 12:28:37 -080021 @click="toggleNavigation"
22 >
23 <icon-close v-if="isNavigationOpen" />
24 <icon-menu v-if="!isNavigationOpen" />
25 </b-button>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080026 <b-navbar-nav>
Yoshie Muranakae0b76c32020-02-28 14:18:20 -080027 <b-nav-text>{{ $t('appHeader.bmcSystemManagement') }}</b-nav-text>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080028 </b-navbar-nav>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080029 <!-- Right aligned nav items -->
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080030 <b-navbar-nav class="ml-auto">
Derick Montague68592032020-04-04 14:02:34 -050031 <b-nav-item>
32 {{ $t('appHeader.health') }}
33 <status-icon :status="healthStatusIcon" />
34 </b-nav-item>
35 <b-nav-item>
36 {{ $t('appHeader.power') }}
37 <status-icon :status="hostStatusIcon" />
38 </b-nav-item>
39 <!-- Using LI elements instead of b-nav-item to support semantic button elements -->
40 <li class="nav-item">
41 <b-button id="app-header-refresh" variant="link" @click="refresh">
Yoshie Muranakae0b76c32020-02-28 14:18:20 -080042 {{ $t('appHeader.refresh') }}
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080043 <icon-renew />
Derick Montague68592032020-04-04 14:02:34 -050044 </b-button>
45 </li>
46 <li>
47 <b-button id="app-header-logout" variant="link" @click="logout">
Yoshie Muranakae0b76c32020-02-28 14:18:20 -080048 {{ $t('appHeader.logOut') }}
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080049 <icon-avatar />
Derick Montague68592032020-04-04 14:02:34 -050050 </b-button>
51 </li>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080052 </b-navbar-nav>
Derick Montaguea2988f42020-01-17 13:46:30 -060053 </b-navbar>
54 </header>
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070055 <loading-bar />
Derick Montaguea2988f42020-01-17 13:46:30 -060056 </div>
57</template>
58
59<script>
Derick Montaguee2fd1562019-12-20 13:26:53 -060060import IconAvatar from '@carbon/icons-vue/es/user--avatar/20';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080061import IconClose from '@carbon/icons-vue/es/close/20';
62import IconMenu from '@carbon/icons-vue/es/menu/20';
Derick Montaguee2fd1562019-12-20 13:26:53 -060063import IconRenew from '@carbon/icons-vue/es/renew/20';
64import StatusIcon from '../Global/StatusIcon';
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070065import LoadingBar from '../Global/LoadingBar';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080066
Derick Montaguea2988f42020-01-17 13:46:30 -060067export default {
Derick Montaguee2fd1562019-12-20 13:26:53 -060068 name: 'AppHeader',
Yoshie Muranaka3be801a2020-04-21 11:34:56 -070069 components: {
70 IconAvatar,
71 IconClose,
72 IconMenu,
73 IconRenew,
74 StatusIcon,
75 LoadingBar
76 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -080077 data() {
78 return {
79 isNavigationOpen: false
80 };
81 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080082 computed: {
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080083 hostStatus() {
Derick Montaguee2fd1562019-12-20 13:26:53 -060084 return this.$store.getters['global/hostStatus'];
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080085 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -080086 healthStatus() {
87 return this.$store.getters['eventLog/healthStatus'];
88 },
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080089 hostStatusIcon() {
90 switch (this.hostStatus) {
Derick Montaguee2fd1562019-12-20 13:26:53 -060091 case 'on':
92 return 'success';
93 case 'error':
94 return 'danger';
95 case 'off':
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080096 default:
Derick Montaguee2fd1562019-12-20 13:26:53 -060097 return 'secondary';
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080098 }
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -080099 },
100 healthStatusIcon() {
101 switch (this.healthStatus) {
102 case 'good':
103 return 'success';
104 case 'warning':
105 return 'warning';
106 case 'critical':
107 return 'danger';
108 default:
109 return 'secondary';
110 }
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800111 }
112 },
Derick Montague09e45cd2020-01-23 15:45:57 -0600113 created() {
114 this.getHostInfo();
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800115 this.getEvents();
Derick Montague09e45cd2020-01-23 15:45:57 -0600116 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800117 mounted() {
118 this.$root.$on(
119 'change:isNavigationOpen',
120 isNavigationOpen => (this.isNavigationOpen = isNavigationOpen)
121 );
122 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800123 methods: {
124 getHostInfo() {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600125 this.$store.dispatch('global/getHostStatus');
Derick Montaguee080a1a2019-12-04 16:30:08 -0600126 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800127 getEvents() {
128 this.$store.dispatch('eventLog/getEventLogData');
129 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -0800130 refresh() {
131 this.$emit('refresh');
132 },
Derick Montaguee080a1a2019-12-04 16:30:08 -0600133 logout() {
Derick Montaguec031b692020-02-12 15:55:42 -0600134 this.$store.dispatch('authentication/logout');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800135 },
136 toggleNavigation() {
137 this.$root.$emit('toggle:navigation');
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800138 }
Derick Montaguea2988f42020-01-17 13:46:30 -0600139 }
140};
141</script>
142
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800143<style lang="scss" scoped>
Derick Montague40865722020-04-13 17:01:19 -0500144@import 'src/assets/styles/helpers';
145
Derick Montague75b48322019-12-06 01:24:41 -0600146.link-skip-nav {
147 position: absolute;
148 top: -60px;
149 left: 0.5rem;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800150 z-index: $zindex-popover;
151 transition: $duration--moderate-01 $exit-easing--expressive;
Derick Montague75b48322019-12-06 01:24:41 -0600152 &:focus {
153 top: 0.5rem;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800154 transition-timing-function: $entrance-easing--expressive;
Derick Montague75b48322019-12-06 01:24:41 -0600155 }
156}
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800157.navbar-dark {
158 .navbar-text,
Derick Montague68592032020-04-04 14:02:34 -0500159 .nav-link,
160 .btn-link {
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800161 color: $white !important;
Derick Montague68592032020-04-04 14:02:34 -0500162 fill: currentColor;
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800163 }
164}
Derick Montague68592032020-04-04 14:02:34 -0500165
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800166.nav-item {
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800167 fill: $light;
168}
169
170.navbar {
171 padding: 0;
172 height: $header-height;
173 overflow: hidden;
Derick Montague68592032020-04-04 14:02:34 -0500174
175 .btn-link {
176 padding: $spacer / 2;
177 }
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800178}
179
180.navbar-nav {
181 padding: 0 $spacer;
182}
183
184.nav-trigger {
Derick Montague7f970a12020-03-02 17:56:09 -0600185 fill: $light;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800186 width: $header-height;
187 height: $header-height;
188 transition: none;
189
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800190 svg {
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800191 margin: 0;
192 }
193
194 &:hover {
Derick Montague7f970a12020-03-02 17:56:09 -0600195 fill: $light;
196 background-color: $dark;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800197 }
198
199 @include media-breakpoint-up($responsive-layout-bp) {
200 display: none;
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800201 }
202}
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800203</style>