blob: 114d6c9dd576c10a89de5b627f8bd986c34a0016 [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>
55 </div>
56</template>
57
58<script>
Derick Montaguee2fd1562019-12-20 13:26:53 -060059import IconAvatar from '@carbon/icons-vue/es/user--avatar/20';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080060import IconClose from '@carbon/icons-vue/es/close/20';
61import IconMenu from '@carbon/icons-vue/es/menu/20';
Derick Montaguee2fd1562019-12-20 13:26:53 -060062import IconRenew from '@carbon/icons-vue/es/renew/20';
63import StatusIcon from '../Global/StatusIcon';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080064
Derick Montaguea2988f42020-01-17 13:46:30 -060065export default {
Derick Montaguee2fd1562019-12-20 13:26:53 -060066 name: 'AppHeader',
Yoshie Muranaka74f86872020-02-10 12:28:37 -080067 components: { IconAvatar, IconClose, IconMenu, IconRenew, StatusIcon },
68 data() {
69 return {
70 isNavigationOpen: false
71 };
72 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080073 computed: {
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080074 hostStatus() {
Derick Montaguee2fd1562019-12-20 13:26:53 -060075 return this.$store.getters['global/hostStatus'];
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080076 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -080077 healthStatus() {
78 return this.$store.getters['eventLog/healthStatus'];
79 },
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080080 hostStatusIcon() {
81 switch (this.hostStatus) {
Derick Montaguee2fd1562019-12-20 13:26:53 -060082 case 'on':
83 return 'success';
84 case 'error':
85 return 'danger';
86 case 'off':
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080087 default:
Derick Montaguee2fd1562019-12-20 13:26:53 -060088 return 'secondary';
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080089 }
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -080090 },
91 healthStatusIcon() {
92 switch (this.healthStatus) {
93 case 'good':
94 return 'success';
95 case 'warning':
96 return 'warning';
97 case 'critical':
98 return 'danger';
99 default:
100 return 'secondary';
101 }
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800102 }
103 },
Derick Montague09e45cd2020-01-23 15:45:57 -0600104 created() {
105 this.getHostInfo();
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800106 this.getEvents();
Derick Montague09e45cd2020-01-23 15:45:57 -0600107 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800108 mounted() {
109 this.$root.$on(
110 'change:isNavigationOpen',
111 isNavigationOpen => (this.isNavigationOpen = isNavigationOpen)
112 );
113 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800114 methods: {
115 getHostInfo() {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600116 this.$store.dispatch('global/getHostStatus');
Derick Montaguee080a1a2019-12-04 16:30:08 -0600117 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800118 getEvents() {
119 this.$store.dispatch('eventLog/getEventLogData');
120 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -0800121 refresh() {
122 this.$emit('refresh');
123 },
Derick Montaguee080a1a2019-12-04 16:30:08 -0600124 logout() {
Derick Montaguec031b692020-02-12 15:55:42 -0600125 this.$store.dispatch('authentication/logout');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800126 },
127 toggleNavigation() {
128 this.$root.$emit('toggle:navigation');
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800129 }
Derick Montaguea2988f42020-01-17 13:46:30 -0600130 }
131};
132</script>
133
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800134<style lang="scss" scoped>
Derick Montague75b48322019-12-06 01:24:41 -0600135.link-skip-nav {
136 position: absolute;
137 top: -60px;
138 left: 0.5rem;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800139 z-index: $zindex-popover;
140 transition: $duration--moderate-01 $exit-easing--expressive;
Derick Montague75b48322019-12-06 01:24:41 -0600141 &:focus {
142 top: 0.5rem;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800143 transition-timing-function: $entrance-easing--expressive;
Derick Montague75b48322019-12-06 01:24:41 -0600144 }
145}
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800146.navbar-dark {
147 .navbar-text,
Derick Montague68592032020-04-04 14:02:34 -0500148 .nav-link,
149 .btn-link {
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800150 color: $white !important;
Derick Montague68592032020-04-04 14:02:34 -0500151 fill: currentColor;
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800152 }
153}
Derick Montague68592032020-04-04 14:02:34 -0500154
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800155.nav-item {
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800156 fill: $light;
157}
158
159.navbar {
160 padding: 0;
161 height: $header-height;
162 overflow: hidden;
Derick Montague68592032020-04-04 14:02:34 -0500163
164 .btn-link {
165 padding: $spacer / 2;
166 }
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800167}
168
169.navbar-nav {
170 padding: 0 $spacer;
171}
172
173.nav-trigger {
Derick Montague7f970a12020-03-02 17:56:09 -0600174 fill: $light;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800175 width: $header-height;
176 height: $header-height;
177 transition: none;
178
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800179 svg {
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800180 margin: 0;
181 }
182
183 &:hover {
Derick Montague7f970a12020-03-02 17:56:09 -0600184 fill: $light;
185 background-color: $dark;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800186 }
187
188 @include media-breakpoint-up($responsive-layout-bp) {
189 display: none;
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800190 }
191}
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800192</style>