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 |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame^] | 17 | <status-icon :status="healthStatusIcon" /> |
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 | }, |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame^] | 49 | healthStatus() { |
| 50 | return this.$store.getters['eventLog/healthStatus']; |
| 51 | }, |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 52 | hostStatusIcon() { |
| 53 | switch (this.hostStatus) { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 54 | case 'on': |
| 55 | return 'success'; |
| 56 | case 'error': |
| 57 | return 'danger'; |
| 58 | case 'off': |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 59 | default: |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 60 | return 'secondary'; |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 61 | } |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame^] | 62 | }, |
| 63 | healthStatusIcon() { |
| 64 | switch (this.healthStatus) { |
| 65 | case 'good': |
| 66 | return 'success'; |
| 67 | case 'warning': |
| 68 | return 'warning'; |
| 69 | case 'critical': |
| 70 | return 'danger'; |
| 71 | default: |
| 72 | return 'secondary'; |
| 73 | } |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 74 | } |
| 75 | }, |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 76 | created() { |
| 77 | this.getHostInfo(); |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame^] | 78 | this.getEvents(); |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 79 | }, |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 80 | methods: { |
| 81 | getHostInfo() { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 82 | this.$store.dispatch('global/getHostStatus'); |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 83 | }, |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame^] | 84 | getEvents() { |
| 85 | this.$store.dispatch('eventLog/getEventLogData'); |
| 86 | }, |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 87 | logout() { |
Derick Montague | c031b69 | 2020-02-12 15:55:42 -0600 | [diff] [blame] | 88 | this.$store.dispatch('authentication/logout'); |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 89 | } |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 90 | } |
| 91 | }; |
| 92 | </script> |
| 93 | |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 94 | <style lang="scss" scoped> |
Derick Montague | 75b4832 | 2019-12-06 01:24:41 -0600 | [diff] [blame] | 95 | .link-skip-nav { |
| 96 | position: absolute; |
| 97 | top: -60px; |
| 98 | left: 0.5rem; |
| 99 | z-index: 10; |
| 100 | transition: 150ms cubic-bezier(0.4, 0.14, 1, 1); |
Derick Montague | 75b4832 | 2019-12-06 01:24:41 -0600 | [diff] [blame] | 101 | &:focus { |
| 102 | top: 0.5rem; |
| 103 | transition-timing-function: cubic-bezier(0, 0, 0.3, 1); |
| 104 | } |
| 105 | } |
Yoshie Muranaka | 1ace1d9 | 2020-02-06 13:47:28 -0800 | [diff] [blame^] | 106 | .navbar-dark { |
| 107 | .navbar-text, |
| 108 | .nav-link { |
| 109 | color: $white !important; |
| 110 | } |
| 111 | } |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame] | 112 | .nav-item { |
| 113 | svg { |
| 114 | fill: $light; |
| 115 | } |
| 116 | } |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 117 | </style> |