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" |
SurenNeware | 057232b | 2020-06-08 20:53:26 +0530 | [diff] [blame] | 21 | :class="{ open: isNavigationOpen }" |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 22 | @click="toggleNavigation" |
| 23 | > |
| 24 | <icon-close v-if="isNavigationOpen" /> |
| 25 | <icon-menu v-if="!isNavigationOpen" /> |
| 26 | </b-button> |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 27 | <b-navbar-nav> |
Yoshie Muranaka | e0b76c3 | 2020-02-28 14:18:20 -0800 | [diff] [blame] | 28 | <b-nav-text>{{ $t('appHeader.bmcSystemManagement') }}</b-nav-text> |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 29 | </b-navbar-nav> |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 30 | <!-- Right aligned nav items --> |
SurenNeware | 057232b | 2020-06-08 20:53:26 +0530 | [diff] [blame] | 31 | <b-navbar-nav class="ml-auto helper-menu"> |
Dixsie Wolmers | 13cdbcd | 2020-06-02 08:22:07 -0500 | [diff] [blame] | 32 | <b-nav-item to="/health/event-logs"> |
Derick Montague | 6859203 | 2020-04-04 14:02:34 -0500 | [diff] [blame] | 33 | <status-icon :status="healthStatusIcon" /> |
SurenNeware | 057232b | 2020-06-08 20:53:26 +0530 | [diff] [blame] | 34 | {{ $t('appHeader.health') }} |
Derick Montague | 6859203 | 2020-04-04 14:02:34 -0500 | [diff] [blame] | 35 | </b-nav-item> |
Dixsie Wolmers | 13cdbcd | 2020-06-02 08:22:07 -0500 | [diff] [blame] | 36 | <b-nav-item to="/control/server-power-operations"> |
Derick Montague | 6859203 | 2020-04-04 14:02:34 -0500 | [diff] [blame] | 37 | <status-icon :status="hostStatusIcon" /> |
SurenNeware | 057232b | 2020-06-08 20:53:26 +0530 | [diff] [blame] | 38 | {{ $t('appHeader.power') }} |
Derick Montague | 6859203 | 2020-04-04 14:02:34 -0500 | [diff] [blame] | 39 | </b-nav-item> |
| 40 | <!-- Using LI elements instead of b-nav-item to support semantic button elements --> |
| 41 | <li class="nav-item"> |
| 42 | <b-button id="app-header-refresh" variant="link" @click="refresh"> |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 43 | <icon-renew /> |
SurenNeware | 057232b | 2020-06-08 20:53:26 +0530 | [diff] [blame] | 44 | <span class="responsive-text">{{ $t('appHeader.refresh') }}</span> |
Derick Montague | 6859203 | 2020-04-04 14:02:34 -0500 | [diff] [blame] | 45 | </b-button> |
| 46 | </li> |
Sukanya Pandey | b1f559f | 2020-04-28 20:18:28 +0530 | [diff] [blame] | 47 | <li class="nav-item"> |
| 48 | <b-dropdown id="app-header-user" variant="link" right> |
| 49 | <template v-slot:button-content> |
| 50 | <icon-avatar /> |
SurenNeware | 057232b | 2020-06-08 20:53:26 +0530 | [diff] [blame] | 51 | <span class="responsive-text">{{ username }}</span> |
Sukanya Pandey | b1f559f | 2020-04-28 20:18:28 +0530 | [diff] [blame] | 52 | </template> |
| 53 | <b-dropdown-item to="/profile-settings" |
| 54 | >{{ $t('appHeader.profileSettings') }} |
| 55 | </b-dropdown-item> |
| 56 | <b-dropdown-item @click="logout">{{ |
| 57 | $t('appHeader.logOut') |
| 58 | }}</b-dropdown-item> |
| 59 | </b-dropdown> |
Derick Montague | 6859203 | 2020-04-04 14:02:34 -0500 | [diff] [blame] | 60 | </li> |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 61 | </b-navbar-nav> |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 62 | </b-navbar> |
| 63 | </header> |
Yoshie Muranaka | 3be801a | 2020-04-21 11:34:56 -0700 | [diff] [blame] | 64 | <loading-bar /> |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 65 | </div> |
| 66 | </template> |
| 67 | |
| 68 | <script> |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 69 | import IconAvatar from '@carbon/icons-vue/es/user--avatar/20'; |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 70 | import IconClose from '@carbon/icons-vue/es/close/20'; |
| 71 | import IconMenu from '@carbon/icons-vue/es/menu/20'; |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 72 | import IconRenew from '@carbon/icons-vue/es/renew/20'; |
| 73 | import StatusIcon from '../Global/StatusIcon'; |
Yoshie Muranaka | 3be801a | 2020-04-21 11:34:56 -0700 | [diff] [blame] | 74 | import LoadingBar from '../Global/LoadingBar'; |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 75 | |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 76 | export default { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 77 | name: 'AppHeader', |
Yoshie Muranaka | 3be801a | 2020-04-21 11:34:56 -0700 | [diff] [blame] | 78 | components: { |
| 79 | IconAvatar, |
| 80 | IconClose, |
| 81 | IconMenu, |
| 82 | IconRenew, |
| 83 | StatusIcon, |
| 84 | LoadingBar |
| 85 | }, |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 86 | data() { |
| 87 | return { |
| 88 | isNavigationOpen: false |
| 89 | }; |
| 90 | }, |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 91 | computed: { |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 92 | hostStatus() { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 93 | return this.$store.getters['global/hostStatus']; |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 94 | }, |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 95 | healthStatus() { |
| 96 | return this.$store.getters['eventLog/healthStatus']; |
| 97 | }, |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 98 | hostStatusIcon() { |
| 99 | switch (this.hostStatus) { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 100 | case 'on': |
| 101 | return 'success'; |
| 102 | case 'error': |
| 103 | return 'danger'; |
Yoshie Muranaka | a3cbc65 | 2020-05-13 12:55:48 -0700 | [diff] [blame] | 104 | case 'diagnosticMode': |
| 105 | return 'warning'; |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 106 | case 'off': |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 107 | default: |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 108 | return 'secondary'; |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 109 | } |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 110 | }, |
| 111 | healthStatusIcon() { |
| 112 | switch (this.healthStatus) { |
Yoshie Muranaka | ce9a3ef | 2020-05-06 14:33:22 -0700 | [diff] [blame] | 113 | case 'OK': |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 114 | return 'success'; |
Yoshie Muranaka | ce9a3ef | 2020-05-06 14:33:22 -0700 | [diff] [blame] | 115 | case 'Warning': |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 116 | return 'warning'; |
Yoshie Muranaka | ce9a3ef | 2020-05-06 14:33:22 -0700 | [diff] [blame] | 117 | case 'Critical': |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 118 | return 'danger'; |
| 119 | default: |
| 120 | return 'secondary'; |
| 121 | } |
Sukanya Pandey | b1f559f | 2020-04-28 20:18:28 +0530 | [diff] [blame] | 122 | }, |
| 123 | username() { |
| 124 | return this.$store.getters['global/username']; |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 125 | } |
| 126 | }, |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 127 | created() { |
| 128 | this.getHostInfo(); |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 129 | this.getEvents(); |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 130 | }, |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 131 | mounted() { |
| 132 | this.$root.$on( |
| 133 | 'change:isNavigationOpen', |
| 134 | isNavigationOpen => (this.isNavigationOpen = isNavigationOpen) |
| 135 | ); |
| 136 | }, |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 137 | methods: { |
| 138 | getHostInfo() { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 139 | this.$store.dispatch('global/getHostStatus'); |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 140 | }, |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 141 | getEvents() { |
| 142 | this.$store.dispatch('eventLog/getEventLogData'); |
| 143 | }, |
Yoshie Muranaka | eb154bb | 2020-02-07 12:18:45 -0800 | [diff] [blame] | 144 | refresh() { |
| 145 | this.$emit('refresh'); |
| 146 | }, |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 147 | logout() { |
Derick Montague | c031b69 | 2020-02-12 15:55:42 -0600 | [diff] [blame] | 148 | this.$store.dispatch('authentication/logout'); |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 149 | }, |
| 150 | toggleNavigation() { |
| 151 | this.$root.$emit('toggle:navigation'); |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 152 | } |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 153 | } |
| 154 | }; |
| 155 | </script> |
| 156 | |
Sukanya Pandey | b1f559f | 2020-04-28 20:18:28 +0530 | [diff] [blame] | 157 | <style lang="scss"> |
Derick Montague | 4086572 | 2020-04-13 17:01:19 -0500 | [diff] [blame] | 158 | @import 'src/assets/styles/helpers'; |
| 159 | |
Sukanya Pandey | b1f559f | 2020-04-28 20:18:28 +0530 | [diff] [blame] | 160 | .app-header { |
| 161 | .link-skip-nav { |
| 162 | position: absolute; |
| 163 | top: -60px; |
| 164 | left: 0.5rem; |
| 165 | z-index: $zindex-popover; |
| 166 | transition: $duration--moderate-01 $exit-easing--expressive; |
| 167 | &:focus { |
| 168 | top: 0.5rem; |
| 169 | transition-timing-function: $entrance-easing--expressive; |
| 170 | } |
Derick Montague | 75b4832 | 2019-12-06 01:24:41 -0600 | [diff] [blame] | 171 | } |
Sukanya Pandey | b1f559f | 2020-04-28 20:18:28 +0530 | [diff] [blame] | 172 | .navbar-dark { |
| 173 | .navbar-text, |
| 174 | .nav-link, |
| 175 | .btn-link { |
| 176 | color: $white !important; |
| 177 | fill: currentColor; |
| 178 | } |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 179 | } |
| 180 | |
Sukanya Pandey | b1f559f | 2020-04-28 20:18:28 +0530 | [diff] [blame] | 181 | .nav-item { |
Yoshie Muranaka | 01da818 | 2020-07-08 15:46:43 -0700 | [diff] [blame] | 182 | fill: theme-color('light'); |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 183 | } |
| 184 | |
Sukanya Pandey | b1f559f | 2020-04-28 20:18:28 +0530 | [diff] [blame] | 185 | .navbar { |
| 186 | padding: 0; |
SurenNeware | 057232b | 2020-06-08 20:53:26 +0530 | [diff] [blame] | 187 | @include media-breakpoint-up($responsive-layout-bp) { |
| 188 | height: $header-height; |
| 189 | } |
Sukanya Pandey | b1f559f | 2020-04-28 20:18:28 +0530 | [diff] [blame] | 190 | |
| 191 | .btn-link { |
| 192 | padding: $spacer / 2; |
| 193 | } |
SurenNeware | 057232b | 2020-06-08 20:53:26 +0530 | [diff] [blame] | 194 | |
| 195 | .helper-menu { |
| 196 | @include media-breakpoint-down(sm) { |
Yoshie Muranaka | 01da818 | 2020-07-08 15:46:43 -0700 | [diff] [blame] | 197 | background-color: gray('800'); |
SurenNeware | 057232b | 2020-06-08 20:53:26 +0530 | [diff] [blame] | 198 | width: 100%; |
| 199 | justify-content: flex-end; |
| 200 | |
| 201 | .nav-link, |
| 202 | .btn { |
| 203 | padding: $spacer / 1.125 $spacer / 2; |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | .responsive-text { |
| 208 | @include media-breakpoint-down(xs) { |
| 209 | display: none; |
| 210 | } |
| 211 | } |
| 212 | } |
Sukanya Pandey | b1f559f | 2020-04-28 20:18:28 +0530 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | .navbar-nav { |
| 216 | padding: 0 $spacer; |
| 217 | } |
| 218 | |
| 219 | .nav-trigger { |
Yoshie Muranaka | 01da818 | 2020-07-08 15:46:43 -0700 | [diff] [blame] | 220 | fill: theme-color('light'); |
Sukanya Pandey | b1f559f | 2020-04-28 20:18:28 +0530 | [diff] [blame] | 221 | width: $header-height; |
| 222 | height: $header-height; |
| 223 | transition: none; |
| 224 | |
| 225 | svg { |
| 226 | margin: 0; |
| 227 | } |
| 228 | |
| 229 | &:hover { |
Yoshie Muranaka | 01da818 | 2020-07-08 15:46:43 -0700 | [diff] [blame] | 230 | fill: theme-color('light'); |
| 231 | background-color: theme-color('dark'); |
Sukanya Pandey | b1f559f | 2020-04-28 20:18:28 +0530 | [diff] [blame] | 232 | } |
| 233 | |
SurenNeware | 057232b | 2020-06-08 20:53:26 +0530 | [diff] [blame] | 234 | &.open { |
Yoshie Muranaka | 01da818 | 2020-07-08 15:46:43 -0700 | [diff] [blame] | 235 | background-color: gray('800'); |
SurenNeware | 057232b | 2020-06-08 20:53:26 +0530 | [diff] [blame] | 236 | } |
| 237 | |
Sukanya Pandey | b1f559f | 2020-04-28 20:18:28 +0530 | [diff] [blame] | 238 | @include media-breakpoint-up($responsive-layout-bp) { |
| 239 | display: none; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | .dropdown { |
| 244 | .dropdown-menu { |
SurenNeware | 057232b | 2020-06-08 20:53:26 +0530 | [diff] [blame] | 245 | margin-top: 0; |
| 246 | @include media-breakpoint-up(md) { |
| 247 | margin-top: 7px; |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | .navbar-expand { |
| 253 | @include media-breakpoint-down(sm) { |
| 254 | flex-flow: wrap; |
Sukanya Pandey | b1f559f | 2020-04-28 20:18:28 +0530 | [diff] [blame] | 255 | } |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 256 | } |
| 257 | } |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 258 | </style> |