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