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> |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [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 { |
| 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 | created() { |
| 46 | this.getHostInfo(); |
| 47 | }, |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 48 | computed: { |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 49 | hostStatus() { |
| 50 | return this.$store.getters["global/hostStatus"]; |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame^] | 51 | }, |
| 52 | hostStatusIcon() { |
| 53 | switch (this.hostStatus) { |
| 54 | case "on": |
| 55 | return "success"; |
| 56 | case "error": |
| 57 | return "danger"; |
| 58 | case "off": |
| 59 | default: |
| 60 | return "secondary"; |
| 61 | } |
Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame] | 62 | } |
| 63 | }, |
| 64 | methods: { |
| 65 | getHostInfo() { |
Yoshie Muranaka | dc04feb | 2019-12-04 08:41:22 -0800 | [diff] [blame^] | 66 | this.$store.dispatch("global/getHostStatus"); |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 67 | }, |
| 68 | logout() { |
| 69 | this.$store.dispatch("authentication/logout").then(() => { |
| 70 | this.$router.push("/login"); |
| 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> |