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"> |
| 4 | Skip to content |
| 5 | </a> |
Derick Montague | 75b4832 | 2019-12-06 01:24:41 -0600 | [diff] [blame] | 6 | <header id="page-header"> |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 7 | <b-navbar toggleable="lg" variant="dark" type="dark"> |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 8 | <!-- Left aligned nav items --> |
| 9 | <b-navbar-nav> |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 10 | <b-nav-text>BMC System Management</b-nav-text> |
| 11 | </b-navbar-nav> |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 12 | <!-- Right aligned nav items --> |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 13 | <b-navbar-nav class="ml-auto"> |
| 14 | <b-nav> |
| 15 | <b-nav-item> |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 16 | Health |
| 17 | <status-icon :status="'danger'" /> |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 18 | </b-nav-item> |
| 19 | <b-nav-item> |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 20 | Power |
| 21 | <status-icon :status="hostStatusIcon" /> |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 22 | </b-nav-item> |
| 23 | <b-nav-item> |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 24 | Refresh |
| 25 | <icon-renew /> |
| 26 | </b-nav-item> |
| 27 | <b-nav-item @click="logout"> |
| 28 | Logout |
| 29 | <icon-avatar /> |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 30 | </b-nav-item> |
| 31 | </b-nav> |
| 32 | </b-navbar-nav> |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 33 | </b-navbar> |
| 34 | </header> |
| 35 | </div> |
| 36 | </template> |
| 37 | |
| 38 | <script> |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 39 | import IconAvatar from '@carbon/icons-vue/es/user--avatar/20'; |
| 40 | import IconRenew from '@carbon/icons-vue/es/renew/20'; |
| 41 | import StatusIcon from '../Global/StatusIcon'; |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 42 | export default { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 43 | name: 'AppHeader', |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 44 | components: { IconAvatar, IconRenew, StatusIcon }, |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 45 | computed: { |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 46 | hostStatus() { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 47 | return this.$store.getters['global/hostStatus']; |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 48 | }, |
| 49 | hostStatusIcon() { |
| 50 | switch (this.hostStatus) { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 51 | case 'on': |
| 52 | return 'success'; |
| 53 | case 'error': |
| 54 | return 'danger'; |
| 55 | case 'off': |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 56 | default: |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 57 | return 'secondary'; |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 58 | } |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 59 | } |
| 60 | }, |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame^] | 61 | created() { |
| 62 | this.getHostInfo(); |
| 63 | }, |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 64 | methods: { |
| 65 | getHostInfo() { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 66 | this.$store.dispatch('global/getHostStatus'); |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 67 | }, |
| 68 | logout() { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 69 | this.$store.dispatch('authentication/logout').then(() => { |
| 70 | this.$router.push('/login'); |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 71 | }); |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 72 | } |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 73 | } |
| 74 | }; |
| 75 | </script> |
| 76 | |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 77 | <style lang="scss" scoped> |
Derick Montague | 75b4832 | 2019-12-06 01:24:41 -0600 | [diff] [blame] | 78 | .link-skip-nav { |
| 79 | position: absolute; |
| 80 | top: -60px; |
| 81 | left: 0.5rem; |
| 82 | z-index: 10; |
| 83 | transition: 150ms cubic-bezier(0.4, 0.14, 1, 1); |
Derick Montague | 75b4832 | 2019-12-06 01:24:41 -0600 | [diff] [blame] | 84 | &:focus { |
| 85 | top: 0.5rem; |
| 86 | transition-timing-function: cubic-bezier(0, 0, 0.3, 1); |
| 87 | } |
| 88 | } |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 89 | .nav-item { |
| 90 | svg { |
| 91 | fill: $light; |
| 92 | } |
| 93 | } |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 94 | </style> |