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