Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 1 | <template> |
| 2 | <div> |
Derick Montague | 75b4832 | 2019-12-06 01:24:41 -0600 | [diff] [blame] | 3 | <header id="page-header"> |
Derick Montague | 6859203 | 2020-04-04 14:02:34 -0500 | [diff] [blame] | 4 | <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 Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 13 | <!-- Left aligned nav items --> |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 14 | <b-button |
Derick Montague | 6859203 | 2020-04-04 14:02:34 -0500 | [diff] [blame] | 15 | id="app-header-trigger" |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 16 | class="nav-trigger" |
| 17 | aria-hidden="true" |
| 18 | title="Open navigation" |
| 19 | type="button" |
| 20 | variant="link" |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 21 | @click="toggleNavigation" |
| 22 | > |
| 23 | <icon-close v-if="isNavigationOpen" /> |
| 24 | <icon-menu v-if="!isNavigationOpen" /> |
| 25 | </b-button> |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 26 | <b-navbar-nav> |
Yoshie Muranaka | e0b76c3 | 2020-02-28 14:18:20 -0800 | [diff] [blame] | 27 | <b-nav-text>{{ $t('appHeader.bmcSystemManagement') }}</b-nav-text> |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 28 | </b-navbar-nav> |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 29 | <!-- Right aligned nav items --> |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 30 | <b-navbar-nav class="ml-auto"> |
Derick Montague | 6859203 | 2020-04-04 14:02:34 -0500 | [diff] [blame] | 31 | <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 Muranaka | e0b76c3 | 2020-02-28 14:18:20 -0800 | [diff] [blame] | 42 | {{ $t('appHeader.refresh') }} |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 43 | <icon-renew /> |
Derick Montague | 6859203 | 2020-04-04 14:02:34 -0500 | [diff] [blame] | 44 | </b-button> |
| 45 | </li> |
| 46 | <li> |
| 47 | <b-button id="app-header-logout" variant="link" @click="logout"> |
Yoshie Muranaka | e0b76c3 | 2020-02-28 14:18:20 -0800 | [diff] [blame] | 48 | {{ $t('appHeader.logOut') }} |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 49 | <icon-avatar /> |
Derick Montague | 6859203 | 2020-04-04 14:02:34 -0500 | [diff] [blame] | 50 | </b-button> |
| 51 | </li> |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 52 | </b-navbar-nav> |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 53 | </b-navbar> |
| 54 | </header> |
Yoshie Muranaka | 3be801a | 2020-04-21 11:34:56 -0700 | [diff] [blame] | 55 | <loading-bar /> |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 56 | </div> |
| 57 | </template> |
| 58 | |
| 59 | <script> |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 60 | import IconAvatar from '@carbon/icons-vue/es/user--avatar/20'; |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 61 | import IconClose from '@carbon/icons-vue/es/close/20'; |
| 62 | import IconMenu from '@carbon/icons-vue/es/menu/20'; |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 63 | import IconRenew from '@carbon/icons-vue/es/renew/20'; |
| 64 | import StatusIcon from '../Global/StatusIcon'; |
Yoshie Muranaka | 3be801a | 2020-04-21 11:34:56 -0700 | [diff] [blame] | 65 | import LoadingBar from '../Global/LoadingBar'; |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 66 | |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 67 | export default { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 68 | name: 'AppHeader', |
Yoshie Muranaka | 3be801a | 2020-04-21 11:34:56 -0700 | [diff] [blame] | 69 | components: { |
| 70 | IconAvatar, |
| 71 | IconClose, |
| 72 | IconMenu, |
| 73 | IconRenew, |
| 74 | StatusIcon, |
| 75 | LoadingBar |
| 76 | }, |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 77 | data() { |
| 78 | return { |
| 79 | isNavigationOpen: false |
| 80 | }; |
| 81 | }, |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 82 | computed: { |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 83 | hostStatus() { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 84 | return this.$store.getters['global/hostStatus']; |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 85 | }, |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 86 | healthStatus() { |
| 87 | return this.$store.getters['eventLog/healthStatus']; |
| 88 | }, |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 89 | hostStatusIcon() { |
| 90 | switch (this.hostStatus) { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 91 | case 'on': |
| 92 | return 'success'; |
| 93 | case 'error': |
| 94 | return 'danger'; |
Yoshie Muranaka | a3cbc65 | 2020-05-13 12:55:48 -0700 | [diff] [blame^] | 95 | case 'diagnosticMode': |
| 96 | return 'warning'; |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 97 | case 'off': |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 98 | default: |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 99 | return 'secondary'; |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 100 | } |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 101 | }, |
| 102 | healthStatusIcon() { |
| 103 | switch (this.healthStatus) { |
| 104 | case 'good': |
| 105 | return 'success'; |
| 106 | case 'warning': |
| 107 | return 'warning'; |
| 108 | case 'critical': |
| 109 | return 'danger'; |
| 110 | default: |
| 111 | return 'secondary'; |
| 112 | } |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 113 | } |
| 114 | }, |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 115 | created() { |
| 116 | this.getHostInfo(); |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 117 | this.getEvents(); |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 118 | }, |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 119 | mounted() { |
| 120 | this.$root.$on( |
| 121 | 'change:isNavigationOpen', |
| 122 | isNavigationOpen => (this.isNavigationOpen = isNavigationOpen) |
| 123 | ); |
| 124 | }, |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 125 | methods: { |
| 126 | getHostInfo() { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 127 | this.$store.dispatch('global/getHostStatus'); |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 128 | }, |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 129 | getEvents() { |
| 130 | this.$store.dispatch('eventLog/getEventLogData'); |
| 131 | }, |
Yoshie Muranaka | eb154bb | 2020-02-07 12:18:45 -0800 | [diff] [blame] | 132 | refresh() { |
| 133 | this.$emit('refresh'); |
| 134 | }, |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 135 | logout() { |
Derick Montague | c031b69 | 2020-02-12 15:55:42 -0600 | [diff] [blame] | 136 | this.$store.dispatch('authentication/logout'); |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 137 | }, |
| 138 | toggleNavigation() { |
| 139 | this.$root.$emit('toggle:navigation'); |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 140 | } |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 141 | } |
| 142 | }; |
| 143 | </script> |
| 144 | |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 145 | <style lang="scss" scoped> |
Derick Montague | 4086572 | 2020-04-13 17:01:19 -0500 | [diff] [blame] | 146 | @import 'src/assets/styles/helpers'; |
| 147 | |
Derick Montague | 75b4832 | 2019-12-06 01:24:41 -0600 | [diff] [blame] | 148 | .link-skip-nav { |
| 149 | position: absolute; |
| 150 | top: -60px; |
| 151 | left: 0.5rem; |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 152 | z-index: $zindex-popover; |
| 153 | transition: $duration--moderate-01 $exit-easing--expressive; |
Derick Montague | 75b4832 | 2019-12-06 01:24:41 -0600 | [diff] [blame] | 154 | &:focus { |
| 155 | top: 0.5rem; |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 156 | transition-timing-function: $entrance-easing--expressive; |
Derick Montague | 75b4832 | 2019-12-06 01:24:41 -0600 | [diff] [blame] | 157 | } |
| 158 | } |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 159 | .navbar-dark { |
| 160 | .navbar-text, |
Derick Montague | 6859203 | 2020-04-04 14:02:34 -0500 | [diff] [blame] | 161 | .nav-link, |
| 162 | .btn-link { |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 163 | color: $white !important; |
Derick Montague | 6859203 | 2020-04-04 14:02:34 -0500 | [diff] [blame] | 164 | fill: currentColor; |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 165 | } |
| 166 | } |
Derick Montague | 6859203 | 2020-04-04 14:02:34 -0500 | [diff] [blame] | 167 | |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 168 | .nav-item { |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 169 | fill: $light; |
| 170 | } |
| 171 | |
| 172 | .navbar { |
| 173 | padding: 0; |
| 174 | height: $header-height; |
| 175 | overflow: hidden; |
Derick Montague | 6859203 | 2020-04-04 14:02:34 -0500 | [diff] [blame] | 176 | |
| 177 | .btn-link { |
| 178 | padding: $spacer / 2; |
| 179 | } |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | .navbar-nav { |
| 183 | padding: 0 $spacer; |
| 184 | } |
| 185 | |
| 186 | .nav-trigger { |
Derick Montague | 7f970a1 | 2020-03-02 17:56:09 -0600 | [diff] [blame] | 187 | fill: $light; |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 188 | width: $header-height; |
| 189 | height: $header-height; |
| 190 | transition: none; |
| 191 | |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 192 | svg { |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 193 | margin: 0; |
| 194 | } |
| 195 | |
| 196 | &:hover { |
Derick Montague | 7f970a1 | 2020-03-02 17:56:09 -0600 | [diff] [blame] | 197 | fill: $light; |
| 198 | background-color: $dark; |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | @include media-breakpoint-up($responsive-layout-bp) { |
| 202 | display: none; |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 203 | } |
| 204 | } |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 205 | </style> |