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