Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 1 | <template> |
| 2 | <div> |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 3 | <a class="link-skip-nav btn btn-light" href="#main-content"> |
Yoshie Muranaka | e0b76c3 | 2020-02-28 14:18:20 -0800 | [diff] [blame] | 4 | {{ $t('appHeader.skipToContent') }} |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 5 | </a> |
Derick Montague | 75b4832 | 2019-12-06 01:24:41 -0600 | [diff] [blame] | 6 | <header id="page-header"> |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 7 | <b-navbar variant="dark" type="dark"> |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 8 | <!-- Left aligned nav items --> |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 9 | <b-button |
| 10 | class="nav-trigger" |
| 11 | aria-hidden="true" |
| 12 | title="Open navigation" |
| 13 | type="button" |
| 14 | variant="link" |
| 15 | :aria-expanded="isNavigationOpen" |
| 16 | :class="{ 'nav-open': isNavigationOpen }" |
| 17 | @click="toggleNavigation" |
| 18 | > |
| 19 | <icon-close v-if="isNavigationOpen" /> |
| 20 | <icon-menu v-if="!isNavigationOpen" /> |
| 21 | </b-button> |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 22 | <b-navbar-nav> |
Yoshie Muranaka | e0b76c3 | 2020-02-28 14:18:20 -0800 | [diff] [blame] | 23 | <b-nav-text>{{ $t('appHeader.bmcSystemManagement') }}</b-nav-text> |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 24 | </b-navbar-nav> |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 25 | <!-- Right aligned nav items --> |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 26 | <b-navbar-nav class="ml-auto"> |
| 27 | <b-nav> |
| 28 | <b-nav-item> |
Yoshie Muranaka | e0b76c3 | 2020-02-28 14:18:20 -0800 | [diff] [blame] | 29 | {{ $t('appHeader.health') }} |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 30 | <status-icon :status="healthStatusIcon" /> |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 31 | </b-nav-item> |
| 32 | <b-nav-item> |
Yoshie Muranaka | e0b76c3 | 2020-02-28 14:18:20 -0800 | [diff] [blame] | 33 | {{ $t('appHeader.power') }} |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 34 | <status-icon :status="hostStatusIcon" /> |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 35 | </b-nav-item> |
Yoshie Muranaka | eb154bb | 2020-02-07 12:18:45 -0800 | [diff] [blame] | 36 | <b-nav-item @click="refresh"> |
Yoshie Muranaka | e0b76c3 | 2020-02-28 14:18:20 -0800 | [diff] [blame] | 37 | {{ $t('appHeader.refresh') }} |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 38 | <icon-renew /> |
| 39 | </b-nav-item> |
| 40 | <b-nav-item @click="logout"> |
Yoshie Muranaka | e0b76c3 | 2020-02-28 14:18:20 -0800 | [diff] [blame] | 41 | {{ $t('appHeader.logOut') }} |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 42 | <icon-avatar /> |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 43 | </b-nav-item> |
| 44 | </b-nav> |
| 45 | </b-navbar-nav> |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 46 | </b-navbar> |
| 47 | </header> |
| 48 | </div> |
| 49 | </template> |
| 50 | |
| 51 | <script> |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 52 | import IconAvatar from '@carbon/icons-vue/es/user--avatar/20'; |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 53 | import IconClose from '@carbon/icons-vue/es/close/20'; |
| 54 | import IconMenu from '@carbon/icons-vue/es/menu/20'; |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 55 | import IconRenew from '@carbon/icons-vue/es/renew/20'; |
| 56 | import StatusIcon from '../Global/StatusIcon'; |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 57 | |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 58 | export default { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 59 | name: 'AppHeader', |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 60 | components: { IconAvatar, IconClose, IconMenu, IconRenew, StatusIcon }, |
| 61 | data() { |
| 62 | return { |
| 63 | isNavigationOpen: false |
| 64 | }; |
| 65 | }, |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 66 | computed: { |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 67 | hostStatus() { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 68 | return this.$store.getters['global/hostStatus']; |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 69 | }, |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 70 | healthStatus() { |
| 71 | return this.$store.getters['eventLog/healthStatus']; |
| 72 | }, |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 73 | hostStatusIcon() { |
| 74 | switch (this.hostStatus) { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 75 | case 'on': |
| 76 | return 'success'; |
| 77 | case 'error': |
| 78 | return 'danger'; |
| 79 | case 'off': |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 80 | default: |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 81 | return 'secondary'; |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 82 | } |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 83 | }, |
| 84 | healthStatusIcon() { |
| 85 | switch (this.healthStatus) { |
| 86 | case 'good': |
| 87 | return 'success'; |
| 88 | case 'warning': |
| 89 | return 'warning'; |
| 90 | case 'critical': |
| 91 | return 'danger'; |
| 92 | default: |
| 93 | return 'secondary'; |
| 94 | } |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 95 | } |
| 96 | }, |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 97 | created() { |
| 98 | this.getHostInfo(); |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 99 | this.getEvents(); |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 100 | }, |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 101 | mounted() { |
| 102 | this.$root.$on( |
| 103 | 'change:isNavigationOpen', |
| 104 | isNavigationOpen => (this.isNavigationOpen = isNavigationOpen) |
| 105 | ); |
| 106 | }, |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 107 | methods: { |
| 108 | getHostInfo() { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 109 | this.$store.dispatch('global/getHostStatus'); |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 110 | }, |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 111 | getEvents() { |
| 112 | this.$store.dispatch('eventLog/getEventLogData'); |
| 113 | }, |
Yoshie Muranaka | eb154bb | 2020-02-07 12:18:45 -0800 | [diff] [blame] | 114 | refresh() { |
| 115 | this.$emit('refresh'); |
| 116 | }, |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 117 | logout() { |
Derick Montague | c031b69 | 2020-02-12 15:55:42 -0600 | [diff] [blame] | 118 | this.$store.dispatch('authentication/logout'); |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 119 | }, |
| 120 | toggleNavigation() { |
| 121 | this.$root.$emit('toggle:navigation'); |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 122 | } |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 123 | } |
| 124 | }; |
| 125 | </script> |
| 126 | |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 127 | <style lang="scss" scoped> |
Derick Montague | 75b4832 | 2019-12-06 01:24:41 -0600 | [diff] [blame] | 128 | .link-skip-nav { |
| 129 | position: absolute; |
| 130 | top: -60px; |
| 131 | left: 0.5rem; |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 132 | z-index: $zindex-popover; |
| 133 | transition: $duration--moderate-01 $exit-easing--expressive; |
Derick Montague | 75b4832 | 2019-12-06 01:24:41 -0600 | [diff] [blame] | 134 | &:focus { |
| 135 | top: 0.5rem; |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 136 | transition-timing-function: $entrance-easing--expressive; |
Derick Montague | 75b4832 | 2019-12-06 01:24:41 -0600 | [diff] [blame] | 137 | } |
| 138 | } |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame] | 139 | .navbar-dark { |
| 140 | .navbar-text, |
| 141 | .nav-link { |
| 142 | color: $white !important; |
| 143 | } |
| 144 | } |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 145 | .nav-item { |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 146 | fill: $light; |
| 147 | } |
| 148 | |
| 149 | .navbar { |
| 150 | padding: 0; |
| 151 | height: $header-height; |
| 152 | overflow: hidden; |
| 153 | } |
| 154 | |
| 155 | .navbar-nav { |
| 156 | padding: 0 $spacer; |
| 157 | } |
| 158 | |
| 159 | .nav-trigger { |
Derick Montague | 7f970a1 | 2020-03-02 17:56:09 -0600 | [diff] [blame^] | 160 | fill: $light; |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 161 | width: $header-height; |
| 162 | height: $header-height; |
| 163 | transition: none; |
| 164 | |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 165 | svg { |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 166 | margin: 0; |
| 167 | } |
| 168 | |
| 169 | &:hover { |
Derick Montague | 7f970a1 | 2020-03-02 17:56:09 -0600 | [diff] [blame^] | 170 | fill: $light; |
| 171 | background-color: $dark; |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | @include media-breakpoint-up($responsive-layout-bp) { |
| 175 | display: none; |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 176 | } |
| 177 | } |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 178 | </style> |