blob: 08c82565499c3be779c63321e360666584119590 [file] [log] [blame]
Derick Montaguea2988f42020-01-17 13:46:30 -06001<template>
2 <div>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -08003 <a class="link-skip-nav btn btn-light" href="#main-content">
Yoshie Muranakae0b76c32020-02-28 14:18:20 -08004 {{ $t('appHeader.skipToContent') }}
Yoshie Muranakadc04feb2019-12-04 08:41:22 -08005 </a>
Derick Montague75b48322019-12-06 01:24:41 -06006 <header id="page-header">
Yoshie Muranaka74f86872020-02-10 12:28:37 -08007 <b-navbar variant="dark" type="dark">
Yoshie Muranakadc04feb2019-12-04 08:41:22 -08008 <!-- Left aligned nav items -->
Yoshie Muranaka74f86872020-02-10 12:28:37 -08009 <b-button
10 class="nav-trigger"
11 aria-hidden="true"
12 title="Open navigation"
13 type="button"
14 variant="link"
15 :aria-expanded="isNavigationOpen"
16 :class="{ 'nav-open': isNavigationOpen }"
17 @click="toggleNavigation"
18 >
19 <icon-close v-if="isNavigationOpen" />
20 <icon-menu v-if="!isNavigationOpen" />
21 </b-button>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080022 <b-navbar-nav>
Yoshie Muranakae0b76c32020-02-28 14:18:20 -080023 <b-nav-text>{{ $t('appHeader.bmcSystemManagement') }}</b-nav-text>
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080024 </b-navbar-nav>
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080025 <!-- Right aligned nav items -->
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080026 <b-navbar-nav class="ml-auto">
27 <b-nav>
28 <b-nav-item>
Yoshie Muranakae0b76c32020-02-28 14:18:20 -080029 {{ $t('appHeader.health') }}
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -080030 <status-icon :status="healthStatusIcon" />
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080031 </b-nav-item>
32 <b-nav-item>
Yoshie Muranakae0b76c32020-02-28 14:18:20 -080033 {{ $t('appHeader.power') }}
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080034 <status-icon :status="hostStatusIcon" />
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080035 </b-nav-item>
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080036 <b-nav-item @click="refresh">
Yoshie Muranakae0b76c32020-02-28 14:18:20 -080037 {{ $t('appHeader.refresh') }}
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080038 <icon-renew />
39 </b-nav-item>
40 <b-nav-item @click="logout">
Yoshie Muranakae0b76c32020-02-28 14:18:20 -080041 {{ $t('appHeader.logOut') }}
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080042 <icon-avatar />
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080043 </b-nav-item>
44 </b-nav>
45 </b-navbar-nav>
Derick Montaguea2988f42020-01-17 13:46:30 -060046 </b-navbar>
47 </header>
48 </div>
49</template>
50
51<script>
Derick Montaguee2fd1562019-12-20 13:26:53 -060052import IconAvatar from '@carbon/icons-vue/es/user--avatar/20';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080053import IconClose from '@carbon/icons-vue/es/close/20';
54import IconMenu from '@carbon/icons-vue/es/menu/20';
Derick Montaguee2fd1562019-12-20 13:26:53 -060055import IconRenew from '@carbon/icons-vue/es/renew/20';
56import StatusIcon from '../Global/StatusIcon';
Yoshie Muranaka74f86872020-02-10 12:28:37 -080057
Derick Montaguea2988f42020-01-17 13:46:30 -060058export default {
Derick Montaguee2fd1562019-12-20 13:26:53 -060059 name: 'AppHeader',
Yoshie Muranaka74f86872020-02-10 12:28:37 -080060 components: { IconAvatar, IconClose, IconMenu, IconRenew, StatusIcon },
61 data() {
62 return {
63 isNavigationOpen: false
64 };
65 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080066 computed: {
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080067 hostStatus() {
Derick Montaguee2fd1562019-12-20 13:26:53 -060068 return this.$store.getters['global/hostStatus'];
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080069 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -080070 healthStatus() {
71 return this.$store.getters['eventLog/healthStatus'];
72 },
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080073 hostStatusIcon() {
74 switch (this.hostStatus) {
Derick Montaguee2fd1562019-12-20 13:26:53 -060075 case 'on':
76 return 'success';
77 case 'error':
78 return 'danger';
79 case 'off':
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080080 default:
Derick Montaguee2fd1562019-12-20 13:26:53 -060081 return 'secondary';
Yoshie Muranakadc04feb2019-12-04 08:41:22 -080082 }
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -080083 },
84 healthStatusIcon() {
85 switch (this.healthStatus) {
86 case 'good':
87 return 'success';
88 case 'warning':
89 return 'warning';
90 case 'critical':
91 return 'danger';
92 default:
93 return 'secondary';
94 }
Yoshie Muranakab8b6f792019-12-03 14:47:32 -080095 }
96 },
Derick Montague09e45cd2020-01-23 15:45:57 -060097 created() {
98 this.getHostInfo();
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -080099 this.getEvents();
Derick Montague09e45cd2020-01-23 15:45:57 -0600100 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800101 mounted() {
102 this.$root.$on(
103 'change:isNavigationOpen',
104 isNavigationOpen => (this.isNavigationOpen = isNavigationOpen)
105 );
106 },
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800107 methods: {
108 getHostInfo() {
Derick Montaguee2fd1562019-12-20 13:26:53 -0600109 this.$store.dispatch('global/getHostStatus');
Derick Montaguee080a1a2019-12-04 16:30:08 -0600110 },
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800111 getEvents() {
112 this.$store.dispatch('eventLog/getEventLogData');
113 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -0800114 refresh() {
115 this.$emit('refresh');
116 },
Derick Montaguee080a1a2019-12-04 16:30:08 -0600117 logout() {
Derick Montaguec031b692020-02-12 15:55:42 -0600118 this.$store.dispatch('authentication/logout');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800119 },
120 toggleNavigation() {
121 this.$root.$emit('toggle:navigation');
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800122 }
Derick Montaguea2988f42020-01-17 13:46:30 -0600123 }
124};
125</script>
126
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800127<style lang="scss" scoped>
Derick Montague75b48322019-12-06 01:24:41 -0600128.link-skip-nav {
129 position: absolute;
130 top: -60px;
131 left: 0.5rem;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800132 z-index: $zindex-popover;
133 transition: $duration--moderate-01 $exit-easing--expressive;
Derick Montague75b48322019-12-06 01:24:41 -0600134 &:focus {
135 top: 0.5rem;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800136 transition-timing-function: $entrance-easing--expressive;
Derick Montague75b48322019-12-06 01:24:41 -0600137 }
138}
Yoshie Muranaka1ace1d92020-02-06 13:47:28 -0800139.navbar-dark {
140 .navbar-text,
141 .nav-link {
142 color: $white !important;
143 }
144}
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800145.nav-item {
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800146 fill: $light;
147}
148
149.navbar {
150 padding: 0;
151 height: $header-height;
152 overflow: hidden;
153}
154
155.navbar-nav {
156 padding: 0 $spacer;
157}
158
159.nav-trigger {
Derick Montague7f970a12020-03-02 17:56:09 -0600160 fill: $light;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800161 width: $header-height;
162 height: $header-height;
163 transition: none;
164
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800165 svg {
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800166 margin: 0;
167 }
168
169 &:hover {
Derick Montague7f970a12020-03-02 17:56:09 -0600170 fill: $light;
171 background-color: $dark;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800172 }
173
174 @include media-breakpoint-up($responsive-layout-bp) {
175 display: none;
Yoshie Muranakadc04feb2019-12-04 08:41:22 -0800176 }
177}
Yoshie Muranakab8b6f792019-12-03 14:47:32 -0800178</style>