xref: /openbmc/webui-vue/src/components/AppHeader/AppHeader.vue (revision e2fd156773dbc2e919c912673de092d707e8ef69)
1a2988f40SDerick Montague<template>
2a2988f40SDerick Montague  <div>
3dc04feb5SYoshie Muranaka    <a class="link-skip-nav btn btn-light" href="#main-content">
4dc04feb5SYoshie Muranaka      Skip to content
5dc04feb5SYoshie Muranaka    </a>
675b48321SDerick Montague    <header id="page-header">
7b8b6f791SYoshie Muranaka      <b-navbar toggleable="lg" variant="dark" type="dark">
8dc04feb5SYoshie Muranaka        <!-- Left aligned nav items -->
9dc04feb5SYoshie Muranaka        <b-navbar-nav>
10b8b6f791SYoshie Muranaka          <b-nav-text>BMC System Management</b-nav-text>
11b8b6f791SYoshie Muranaka        </b-navbar-nav>
12dc04feb5SYoshie Muranaka        <!-- Right aligned nav items -->
13b8b6f791SYoshie Muranaka        <b-navbar-nav class="ml-auto">
14b8b6f791SYoshie Muranaka          <b-nav>
15b8b6f791SYoshie Muranaka            <b-nav-item>
16dc04feb5SYoshie Muranaka              Health
17dc04feb5SYoshie Muranaka              <status-icon :status="'danger'" />
18b8b6f791SYoshie Muranaka            </b-nav-item>
19b8b6f791SYoshie Muranaka            <b-nav-item>
20dc04feb5SYoshie Muranaka              Power
21dc04feb5SYoshie Muranaka              <status-icon :status="hostStatusIcon" />
22b8b6f791SYoshie Muranaka            </b-nav-item>
23b8b6f791SYoshie Muranaka            <b-nav-item>
24dc04feb5SYoshie Muranaka              Refresh
25dc04feb5SYoshie Muranaka              <icon-renew />
26dc04feb5SYoshie Muranaka            </b-nav-item>
27dc04feb5SYoshie Muranaka            <b-nav-item @click="logout">
28dc04feb5SYoshie Muranaka              Logout
29dc04feb5SYoshie Muranaka              <icon-avatar />
30b8b6f791SYoshie Muranaka            </b-nav-item>
31b8b6f791SYoshie Muranaka          </b-nav>
32b8b6f791SYoshie Muranaka        </b-navbar-nav>
33a2988f40SDerick Montague      </b-navbar>
34a2988f40SDerick Montague    </header>
35a2988f40SDerick Montague  </div>
36a2988f40SDerick Montague</template>
37a2988f40SDerick Montague
38a2988f40SDerick Montague<script>
39*e2fd1567SDerick Montagueimport IconAvatar from '@carbon/icons-vue/es/user--avatar/20';
40*e2fd1567SDerick Montagueimport IconRenew from '@carbon/icons-vue/es/renew/20';
41*e2fd1567SDerick Montagueimport StatusIcon from '../Global/StatusIcon';
42a2988f40SDerick Montagueexport default {
43*e2fd1567SDerick Montague  name: 'AppHeader',
44dc04feb5SYoshie Muranaka  components: { IconAvatar, IconRenew, StatusIcon },
45b8b6f791SYoshie Muranaka  created() {
46b8b6f791SYoshie Muranaka    this.getHostInfo();
47b8b6f791SYoshie Muranaka  },
48b8b6f791SYoshie Muranaka  computed: {
49b8b6f791SYoshie Muranaka    hostStatus() {
50*e2fd1567SDerick Montague      return this.$store.getters['global/hostStatus'];
51dc04feb5SYoshie Muranaka    },
52dc04feb5SYoshie Muranaka    hostStatusIcon() {
53dc04feb5SYoshie Muranaka      switch (this.hostStatus) {
54*e2fd1567SDerick Montague        case 'on':
55*e2fd1567SDerick Montague          return 'success';
56*e2fd1567SDerick Montague        case 'error':
57*e2fd1567SDerick Montague          return 'danger';
58*e2fd1567SDerick Montague        case 'off':
59dc04feb5SYoshie Muranaka        default:
60*e2fd1567SDerick Montague          return 'secondary';
61dc04feb5SYoshie Muranaka      }
62b8b6f791SYoshie Muranaka    }
63b8b6f791SYoshie Muranaka  },
64b8b6f791SYoshie Muranaka  methods: {
65b8b6f791SYoshie Muranaka    getHostInfo() {
66*e2fd1567SDerick Montague      this.$store.dispatch('global/getHostStatus');
67e080a1a7SDerick Montague    },
68e080a1a7SDerick Montague    logout() {
69*e2fd1567SDerick Montague      this.$store.dispatch('authentication/logout').then(() => {
70*e2fd1567SDerick Montague        this.$router.push('/login');
71e080a1a7SDerick Montague      });
72b8b6f791SYoshie Muranaka    }
73a2988f40SDerick Montague  }
74a2988f40SDerick Montague};
75a2988f40SDerick Montague</script>
76a2988f40SDerick Montague
77b8b6f791SYoshie Muranaka<style lang="scss" scoped>
7875b48321SDerick Montague.link-skip-nav {
7975b48321SDerick Montague  position: absolute;
8075b48321SDerick Montague  top: -60px;
8175b48321SDerick Montague  left: 0.5rem;
8275b48321SDerick Montague  z-index: 10;
8375b48321SDerick Montague  transition: 150ms cubic-bezier(0.4, 0.14, 1, 1);
8475b48321SDerick Montague  &:focus {
8575b48321SDerick Montague    top: 0.5rem;
8675b48321SDerick Montague    transition-timing-function: cubic-bezier(0, 0, 0.3, 1);
8775b48321SDerick Montague  }
8875b48321SDerick Montague}
89dc04feb5SYoshie Muranaka.nav-item {
90dc04feb5SYoshie Muranaka  svg {
91dc04feb5SYoshie Muranaka    fill: $light;
92dc04feb5SYoshie Muranaka  }
93dc04feb5SYoshie Muranaka}
94b8b6f791SYoshie Muranaka</style>
95