blob: d937293da1ed49e22e8450139c4e167b72d2230d [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 Montague75b48322019-12-06 01:24:41 -0600144.link-skip-nav {
145 position: absolute;
146 top: -60px;
147 left: 0.5rem;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800148 z-index: $zindex-popover;
149 transition: $duration--moderate-01 $exit-easing--expressive;
Derick Montague75b48322019-12-06 01:24:41 -0600150 &:focus {
151 top: 0.5rem;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800152 transition-timing-function: $entrance-easing--expressive;
Derick Montague75b48322019-12-06 01:24:41 -0600153 }
154}
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800155.navbar-dark {
156 .navbar-text,
Derick Montague68592032020-04-04 14:02:34 -0500157 .nav-link,
158 .btn-link {
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800159 color: $white !important;
Derick Montague68592032020-04-04 14:02:34 -0500160 fill: currentColor;
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800161 }
162}
Derick Montague68592032020-04-04 14:02:34 -0500163
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800164.nav-item {
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800165 fill: $light;
166}
167
168.navbar {
169 padding: 0;
170 height: $header-height;
171 overflow: hidden;
Derick Montague68592032020-04-04 14:02:34 -0500172
173 .btn-link {
174 padding: $spacer / 2;
175 }
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800176}
177
178.navbar-nav {
179 padding: 0 $spacer;
180}
181
182.nav-trigger {
Derick Montague7f970a12020-03-02 17:56:09 -0600183 fill: $light;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800184 width: $header-height;
185 height: $header-height;
186 transition: none;
187
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800188 svg {
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800189 margin: 0;
190 }
191
192 &:hover {
Derick Montague7f970a12020-03-02 17:56:09 -0600193 fill: $light;
194 background-color: $dark;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800195 }
196
197 @include media-breakpoint-up($responsive-layout-bp) {
198 display: none;
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800199 }
200}
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800201</style>