xref: /openbmc/webui-vue/src/components/AppHeader/AppHeader.vue (revision dc04feb5596a85619e98d2d594b065e92c8b8fa4)
1a2988f40SDerick Montague<template>
2a2988f40SDerick Montague  <div>
3*dc04feb5SYoshie Muranaka    <a class="link-skip-nav btn btn-light" href="#main-content">
4*dc04feb5SYoshie Muranaka      Skip to content
5*dc04feb5SYoshie Muranaka    </a>
675b48321SDerick Montague    <header id="page-header">
7b8b6f791SYoshie Muranaka      <b-navbar toggleable="lg" variant="dark" type="dark">
8*dc04feb5SYoshie Muranaka        <!-- Left aligned nav items -->
9*dc04feb5SYoshie Muranaka        <b-navbar-nav>
10b8b6f791SYoshie Muranaka          <b-nav-text>BMC System Management</b-nav-text>
11b8b6f791SYoshie Muranaka        </b-navbar-nav>
12*dc04feb5SYoshie Muranaka        <!-- Right aligned nav items -->
13b8b6f791SYoshie Muranaka        <b-navbar-nav class="ml-auto">
14b8b6f791SYoshie Muranaka          <b-nav>
15b8b6f791SYoshie Muranaka            <b-nav-item>
16*dc04feb5SYoshie Muranaka              Health
17*dc04feb5SYoshie Muranaka              <status-icon :status="'danger'" />
18b8b6f791SYoshie Muranaka            </b-nav-item>
19b8b6f791SYoshie Muranaka            <b-nav-item>
20*dc04feb5SYoshie Muranaka              Power
21*dc04feb5SYoshie Muranaka              <status-icon :status="hostStatusIcon" />
22b8b6f791SYoshie Muranaka            </b-nav-item>
23b8b6f791SYoshie Muranaka            <b-nav-item>
24*dc04feb5SYoshie Muranaka              Refresh
25*dc04feb5SYoshie Muranaka              <icon-renew />
26*dc04feb5SYoshie Muranaka            </b-nav-item>
27*dc04feb5SYoshie Muranaka            <b-nav-item @click="logout">
28*dc04feb5SYoshie Muranaka              Logout
29*dc04feb5SYoshie 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*dc04feb5SYoshie Muranakaimport IconAvatar from "@carbon/icons-vue/es/user--avatar/20";
40*dc04feb5SYoshie Muranakaimport IconRenew from "@carbon/icons-vue/es/renew/20";
41*dc04feb5SYoshie Muranakaimport StatusIcon from "../Global/StatusIcon";
42a2988f40SDerick Montagueexport default {
43a2988f40SDerick Montague  name: "AppHeader",
44*dc04feb5SYoshie Muranaka  components: { IconAvatar, IconRenew, StatusIcon },
45b8b6f791SYoshie Muranaka  created() {
46b8b6f791SYoshie Muranaka    this.getHostInfo();
47b8b6f791SYoshie Muranaka  },
48b8b6f791SYoshie Muranaka  computed: {
49b8b6f791SYoshie Muranaka    hostStatus() {
50b8b6f791SYoshie Muranaka      return this.$store.getters["global/hostStatus"];
51*dc04feb5SYoshie Muranaka    },
52*dc04feb5SYoshie Muranaka    hostStatusIcon() {
53*dc04feb5SYoshie Muranaka      switch (this.hostStatus) {
54*dc04feb5SYoshie Muranaka        case "on":
55*dc04feb5SYoshie Muranaka          return "success";
56*dc04feb5SYoshie Muranaka        case "error":
57*dc04feb5SYoshie Muranaka          return "danger";
58*dc04feb5SYoshie Muranaka        case "off":
59*dc04feb5SYoshie Muranaka        default:
60*dc04feb5SYoshie Muranaka          return "secondary";
61*dc04feb5SYoshie Muranaka      }
62b8b6f791SYoshie Muranaka    }
63b8b6f791SYoshie Muranaka  },
64b8b6f791SYoshie Muranaka  methods: {
65b8b6f791SYoshie Muranaka    getHostInfo() {
66*dc04feb5SYoshie Muranaka      this.$store.dispatch("global/getHostStatus");
67e080a1a7SDerick Montague    },
68e080a1a7SDerick Montague    logout() {
69e080a1a7SDerick Montague      this.$store.dispatch("authentication/logout").then(() => {
70e080a1a7SDerick 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}
89*dc04feb5SYoshie Muranaka.nav-item {
90*dc04feb5SYoshie Muranaka  svg {
91*dc04feb5SYoshie Muranaka    fill: $light;
92*dc04feb5SYoshie Muranaka  }
93*dc04feb5SYoshie Muranaka}
94b8b6f791SYoshie Muranaka</style>
95