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