xref: /openbmc/webui-vue/src/components/AppHeader/AppHeader.vue (revision 74f8687d4ab358c071bd081b0b7709eba5a521c2)
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">
7*74f8687dSYoshie Muranaka      <b-navbar variant="dark" type="dark">
8dc04feb5SYoshie Muranaka        <!-- Left aligned nav items -->
9*74f8687dSYoshie Muranaka        <b-button
10*74f8687dSYoshie Muranaka          class="nav-trigger"
11*74f8687dSYoshie Muranaka          aria-hidden="true"
12*74f8687dSYoshie Muranaka          title="Open navigation"
13*74f8687dSYoshie Muranaka          type="button"
14*74f8687dSYoshie Muranaka          variant="link"
15*74f8687dSYoshie Muranaka          :aria-expanded="isNavigationOpen"
16*74f8687dSYoshie Muranaka          :class="{ 'nav-open': isNavigationOpen }"
17*74f8687dSYoshie Muranaka          @click="toggleNavigation"
18*74f8687dSYoshie Muranaka        >
19*74f8687dSYoshie Muranaka          <icon-close v-if="isNavigationOpen" />
20*74f8687dSYoshie Muranaka          <icon-menu v-if="!isNavigationOpen" />
21*74f8687dSYoshie Muranaka        </b-button>
22dc04feb5SYoshie Muranaka        <b-navbar-nav>
23b8b6f791SYoshie Muranaka          <b-nav-text>BMC System Management</b-nav-text>
24b8b6f791SYoshie Muranaka        </b-navbar-nav>
25dc04feb5SYoshie Muranaka        <!-- Right aligned nav items -->
26b8b6f791SYoshie Muranaka        <b-navbar-nav class="ml-auto">
27b8b6f791SYoshie Muranaka          <b-nav>
28b8b6f791SYoshie Muranaka            <b-nav-item>
29dc04feb5SYoshie Muranaka              Health
301ace1d91SYoshie Muranaka              <status-icon :status="healthStatusIcon" />
31b8b6f791SYoshie Muranaka            </b-nav-item>
32b8b6f791SYoshie Muranaka            <b-nav-item>
33dc04feb5SYoshie Muranaka              Power
34dc04feb5SYoshie Muranaka              <status-icon :status="hostStatusIcon" />
35b8b6f791SYoshie Muranaka            </b-nav-item>
36eb154bbcSYoshie Muranaka            <b-nav-item @click="refresh">
37dc04feb5SYoshie Muranaka              Refresh
38dc04feb5SYoshie Muranaka              <icon-renew />
39dc04feb5SYoshie Muranaka            </b-nav-item>
40dc04feb5SYoshie Muranaka            <b-nav-item @click="logout">
41dc04feb5SYoshie Muranaka              Logout
42dc04feb5SYoshie Muranaka              <icon-avatar />
43b8b6f791SYoshie Muranaka            </b-nav-item>
44b8b6f791SYoshie Muranaka          </b-nav>
45b8b6f791SYoshie Muranaka        </b-navbar-nav>
46a2988f40SDerick Montague      </b-navbar>
47a2988f40SDerick Montague    </header>
48a2988f40SDerick Montague  </div>
49a2988f40SDerick Montague</template>
50a2988f40SDerick Montague
51a2988f40SDerick Montague<script>
52e2fd1567SDerick Montagueimport IconAvatar from '@carbon/icons-vue/es/user--avatar/20';
53*74f8687dSYoshie Muranakaimport IconClose from '@carbon/icons-vue/es/close/20';
54*74f8687dSYoshie Muranakaimport IconMenu from '@carbon/icons-vue/es/menu/20';
55e2fd1567SDerick Montagueimport IconRenew from '@carbon/icons-vue/es/renew/20';
56e2fd1567SDerick Montagueimport StatusIcon from '../Global/StatusIcon';
57*74f8687dSYoshie Muranaka
58a2988f40SDerick Montagueexport default {
59e2fd1567SDerick Montague  name: 'AppHeader',
60*74f8687dSYoshie Muranaka  components: { IconAvatar, IconClose, IconMenu, IconRenew, StatusIcon },
61*74f8687dSYoshie Muranaka  data() {
62*74f8687dSYoshie Muranaka    return {
63*74f8687dSYoshie Muranaka      isNavigationOpen: false
64*74f8687dSYoshie Muranaka    };
65*74f8687dSYoshie Muranaka  },
66b8b6f791SYoshie Muranaka  computed: {
67b8b6f791SYoshie Muranaka    hostStatus() {
68e2fd1567SDerick Montague      return this.$store.getters['global/hostStatus'];
69dc04feb5SYoshie Muranaka    },
701ace1d91SYoshie Muranaka    healthStatus() {
711ace1d91SYoshie Muranaka      return this.$store.getters['eventLog/healthStatus'];
721ace1d91SYoshie Muranaka    },
73dc04feb5SYoshie Muranaka    hostStatusIcon() {
74dc04feb5SYoshie Muranaka      switch (this.hostStatus) {
75e2fd1567SDerick Montague        case 'on':
76e2fd1567SDerick Montague          return 'success';
77e2fd1567SDerick Montague        case 'error':
78e2fd1567SDerick Montague          return 'danger';
79e2fd1567SDerick Montague        case 'off':
80dc04feb5SYoshie Muranaka        default:
81e2fd1567SDerick Montague          return 'secondary';
82dc04feb5SYoshie Muranaka      }
831ace1d91SYoshie Muranaka    },
841ace1d91SYoshie Muranaka    healthStatusIcon() {
851ace1d91SYoshie Muranaka      switch (this.healthStatus) {
861ace1d91SYoshie Muranaka        case 'good':
871ace1d91SYoshie Muranaka          return 'success';
881ace1d91SYoshie Muranaka        case 'warning':
891ace1d91SYoshie Muranaka          return 'warning';
901ace1d91SYoshie Muranaka        case 'critical':
911ace1d91SYoshie Muranaka          return 'danger';
921ace1d91SYoshie Muranaka        default:
931ace1d91SYoshie Muranaka          return 'secondary';
941ace1d91SYoshie Muranaka      }
95b8b6f791SYoshie Muranaka    }
96b8b6f791SYoshie Muranaka  },
9709e45cd4SDerick Montague  created() {
9809e45cd4SDerick Montague    this.getHostInfo();
991ace1d91SYoshie Muranaka    this.getEvents();
10009e45cd4SDerick Montague  },
101*74f8687dSYoshie Muranaka  mounted() {
102*74f8687dSYoshie Muranaka    this.$root.$on(
103*74f8687dSYoshie Muranaka      'change:isNavigationOpen',
104*74f8687dSYoshie Muranaka      isNavigationOpen => (this.isNavigationOpen = isNavigationOpen)
105*74f8687dSYoshie Muranaka    );
106*74f8687dSYoshie Muranaka  },
107b8b6f791SYoshie Muranaka  methods: {
108b8b6f791SYoshie Muranaka    getHostInfo() {
109e2fd1567SDerick Montague      this.$store.dispatch('global/getHostStatus');
110e080a1a7SDerick Montague    },
1111ace1d91SYoshie Muranaka    getEvents() {
1121ace1d91SYoshie Muranaka      this.$store.dispatch('eventLog/getEventLogData');
1131ace1d91SYoshie Muranaka    },
114eb154bbcSYoshie Muranaka    refresh() {
115eb154bbcSYoshie Muranaka      this.$emit('refresh');
116eb154bbcSYoshie Muranaka    },
117e080a1a7SDerick Montague    logout() {
118c031b698SDerick Montague      this.$store.dispatch('authentication/logout');
119*74f8687dSYoshie Muranaka    },
120*74f8687dSYoshie Muranaka    toggleNavigation() {
121*74f8687dSYoshie Muranaka      this.$root.$emit('toggle:navigation');
122b8b6f791SYoshie Muranaka    }
123a2988f40SDerick Montague  }
124a2988f40SDerick Montague};
125a2988f40SDerick Montague</script>
126a2988f40SDerick Montague
127b8b6f791SYoshie Muranaka<style lang="scss" scoped>
12875b48321SDerick Montague.link-skip-nav {
12975b48321SDerick Montague  position: absolute;
13075b48321SDerick Montague  top: -60px;
13175b48321SDerick Montague  left: 0.5rem;
132*74f8687dSYoshie Muranaka  z-index: $zindex-popover;
133*74f8687dSYoshie Muranaka  transition: $duration--moderate-01 $exit-easing--expressive;
13475b48321SDerick Montague  &:focus {
13575b48321SDerick Montague    top: 0.5rem;
136*74f8687dSYoshie Muranaka    transition-timing-function: $entrance-easing--expressive;
13775b48321SDerick Montague  }
13875b48321SDerick Montague}
1391ace1d91SYoshie Muranaka.navbar-dark {
1401ace1d91SYoshie Muranaka  .navbar-text,
1411ace1d91SYoshie Muranaka  .nav-link {
1421ace1d91SYoshie Muranaka    color: $white !important;
1431ace1d91SYoshie Muranaka  }
1441ace1d91SYoshie Muranaka}
145dc04feb5SYoshie Muranaka.nav-item {
146dc04feb5SYoshie Muranaka  fill: $light;
147dc04feb5SYoshie Muranaka}
148*74f8687dSYoshie Muranaka
149*74f8687dSYoshie Muranaka.navbar {
150*74f8687dSYoshie Muranaka  padding: 0;
151*74f8687dSYoshie Muranaka  height: $header-height;
152*74f8687dSYoshie Muranaka  overflow: hidden;
153*74f8687dSYoshie Muranaka}
154*74f8687dSYoshie Muranaka
155*74f8687dSYoshie Muranaka.navbar-nav {
156*74f8687dSYoshie Muranaka  padding: 0 $spacer;
157*74f8687dSYoshie Muranaka}
158*74f8687dSYoshie Muranaka
159*74f8687dSYoshie Muranaka.nav-trigger {
160*74f8687dSYoshie Muranaka  fill: $white;
161*74f8687dSYoshie Muranaka  width: $header-height;
162*74f8687dSYoshie Muranaka  height: $header-height;
163*74f8687dSYoshie Muranaka  transition: none;
164*74f8687dSYoshie Muranaka
165*74f8687dSYoshie Muranaka  svg {
166*74f8687dSYoshie Muranaka    margin: 0;
167*74f8687dSYoshie Muranaka  }
168*74f8687dSYoshie Muranaka
169*74f8687dSYoshie Muranaka  &:hover {
170*74f8687dSYoshie Muranaka    fill: $white;
171*74f8687dSYoshie Muranaka    background-color: $gray-900;
172*74f8687dSYoshie Muranaka  }
173*74f8687dSYoshie Muranaka
174*74f8687dSYoshie Muranaka  @include media-breakpoint-up($responsive-layout-bp) {
175*74f8687dSYoshie Muranaka    display: none;
176*74f8687dSYoshie Muranaka  }
177dc04feb5SYoshie Muranaka}
178b8b6f791SYoshie Muranaka</style>
179