xref: /openbmc/webui-vue/src/components/AppHeader/AppHeader.vue (revision 057232b85405e8c4a3a6a8c0245e582f26571927)
1a2988f40SDerick Montague<template>
2a2988f40SDerick Montague  <div>
36859203cSDerick Montague    <header id="page-header">
46859203cSDerick Montague      <a role="link" class="link-skip-nav btn btn-light" href="#main-content">
5e0b76c33SYoshie Muranaka        {{ $t('appHeader.skipToContent') }}
6dc04feb5SYoshie Muranaka      </a>
76859203cSDerick Montague
86859203cSDerick Montague      <b-navbar
96859203cSDerick Montague        variant="dark"
106859203cSDerick Montague        type="dark"
116859203cSDerick Montague        :aria-label="$t('appHeader.applicationHeader')"
126859203cSDerick Montague      >
13dc04feb5SYoshie Muranaka        <!-- Left aligned nav items -->
1474f8687dSYoshie Muranaka        <b-button
156859203cSDerick Montague          id="app-header-trigger"
1674f8687dSYoshie Muranaka          class="nav-trigger"
1774f8687dSYoshie Muranaka          aria-hidden="true"
1874f8687dSYoshie Muranaka          title="Open navigation"
1974f8687dSYoshie Muranaka          type="button"
2074f8687dSYoshie Muranaka          variant="link"
21*057232b8SSurenNeware          :class="{ open: isNavigationOpen }"
2274f8687dSYoshie Muranaka          @click="toggleNavigation"
2374f8687dSYoshie Muranaka        >
2474f8687dSYoshie Muranaka          <icon-close v-if="isNavigationOpen" />
2574f8687dSYoshie Muranaka          <icon-menu v-if="!isNavigationOpen" />
2674f8687dSYoshie Muranaka        </b-button>
27dc04feb5SYoshie Muranaka        <b-navbar-nav>
28e0b76c33SYoshie Muranaka          <b-nav-text>{{ $t('appHeader.bmcSystemManagement') }}</b-nav-text>
29b8b6f791SYoshie Muranaka        </b-navbar-nav>
30dc04feb5SYoshie Muranaka        <!-- Right aligned nav items -->
31*057232b8SSurenNeware        <b-navbar-nav class="ml-auto helper-menu">
3213cdbcdaSDixsie Wolmers          <b-nav-item to="/health/event-logs">
331ace1d91SYoshie Muranaka            <status-icon :status="healthStatusIcon" />
34*057232b8SSurenNeware            {{ $t('appHeader.health') }}
35b8b6f791SYoshie Muranaka          </b-nav-item>
3613cdbcdaSDixsie Wolmers          <b-nav-item to="/control/server-power-operations">
37dc04feb5SYoshie Muranaka            <status-icon :status="hostStatusIcon" />
38*057232b8SSurenNeware            {{ $t('appHeader.power') }}
39b8b6f791SYoshie Muranaka          </b-nav-item>
406859203cSDerick Montague          <!-- Using LI elements instead of b-nav-item to support semantic button elements -->
416859203cSDerick Montague          <li class="nav-item">
426859203cSDerick Montague            <b-button id="app-header-refresh" variant="link" @click="refresh">
43dc04feb5SYoshie Muranaka              <icon-renew />
44*057232b8SSurenNeware              <span class="responsive-text">{{ $t('appHeader.refresh') }}</span>
456859203cSDerick Montague            </b-button>
466859203cSDerick Montague          </li>
47b1f559f0SSukanya Pandey          <li class="nav-item">
48b1f559f0SSukanya Pandey            <b-dropdown id="app-header-user" variant="link" right>
49b1f559f0SSukanya Pandey              <template v-slot:button-content>
50dc04feb5SYoshie Muranaka                <icon-avatar />
51*057232b8SSurenNeware                <span class="responsive-text">{{ username }}</span>
52b1f559f0SSukanya Pandey              </template>
53b1f559f0SSukanya Pandey              <b-dropdown-item to="/profile-settings"
54b1f559f0SSukanya Pandey                >{{ $t('appHeader.profileSettings') }}
55b1f559f0SSukanya Pandey              </b-dropdown-item>
56b1f559f0SSukanya Pandey              <b-dropdown-item @click="logout">{{
57b1f559f0SSukanya Pandey                $t('appHeader.logOut')
58b1f559f0SSukanya Pandey              }}</b-dropdown-item>
59b1f559f0SSukanya Pandey            </b-dropdown>
606859203cSDerick Montague          </li>
61b8b6f791SYoshie Muranaka        </b-navbar-nav>
62a2988f40SDerick Montague      </b-navbar>
63a2988f40SDerick Montague    </header>
643be801aaSYoshie Muranaka    <loading-bar />
65a2988f40SDerick Montague  </div>
66a2988f40SDerick Montague</template>
67a2988f40SDerick Montague
68a2988f40SDerick Montague<script>
69e2fd1567SDerick Montagueimport IconAvatar from '@carbon/icons-vue/es/user--avatar/20';
7074f8687dSYoshie Muranakaimport IconClose from '@carbon/icons-vue/es/close/20';
7174f8687dSYoshie Muranakaimport IconMenu from '@carbon/icons-vue/es/menu/20';
72e2fd1567SDerick Montagueimport IconRenew from '@carbon/icons-vue/es/renew/20';
73e2fd1567SDerick Montagueimport StatusIcon from '../Global/StatusIcon';
743be801aaSYoshie Muranakaimport LoadingBar from '../Global/LoadingBar';
7574f8687dSYoshie Muranaka
76a2988f40SDerick Montagueexport default {
77e2fd1567SDerick Montague  name: 'AppHeader',
783be801aaSYoshie Muranaka  components: {
793be801aaSYoshie Muranaka    IconAvatar,
803be801aaSYoshie Muranaka    IconClose,
813be801aaSYoshie Muranaka    IconMenu,
823be801aaSYoshie Muranaka    IconRenew,
833be801aaSYoshie Muranaka    StatusIcon,
843be801aaSYoshie Muranaka    LoadingBar
853be801aaSYoshie Muranaka  },
8674f8687dSYoshie Muranaka  data() {
8774f8687dSYoshie Muranaka    return {
8874f8687dSYoshie Muranaka      isNavigationOpen: false
8974f8687dSYoshie Muranaka    };
9074f8687dSYoshie Muranaka  },
91b8b6f791SYoshie Muranaka  computed: {
92b8b6f791SYoshie Muranaka    hostStatus() {
93e2fd1567SDerick Montague      return this.$store.getters['global/hostStatus'];
94dc04feb5SYoshie Muranaka    },
951ace1d91SYoshie Muranaka    healthStatus() {
961ace1d91SYoshie Muranaka      return this.$store.getters['eventLog/healthStatus'];
971ace1d91SYoshie Muranaka    },
98dc04feb5SYoshie Muranaka    hostStatusIcon() {
99dc04feb5SYoshie Muranaka      switch (this.hostStatus) {
100e2fd1567SDerick Montague        case 'on':
101e2fd1567SDerick Montague          return 'success';
102e2fd1567SDerick Montague        case 'error':
103e2fd1567SDerick Montague          return 'danger';
104a3cbc659SYoshie Muranaka        case 'diagnosticMode':
105a3cbc659SYoshie Muranaka          return 'warning';
106e2fd1567SDerick Montague        case 'off':
107dc04feb5SYoshie Muranaka        default:
108e2fd1567SDerick Montague          return 'secondary';
109dc04feb5SYoshie Muranaka      }
1101ace1d91SYoshie Muranaka    },
1111ace1d91SYoshie Muranaka    healthStatusIcon() {
1121ace1d91SYoshie Muranaka      switch (this.healthStatus) {
113ce9a3ef3SYoshie Muranaka        case 'OK':
1141ace1d91SYoshie Muranaka          return 'success';
115ce9a3ef3SYoshie Muranaka        case 'Warning':
1161ace1d91SYoshie Muranaka          return 'warning';
117ce9a3ef3SYoshie Muranaka        case 'Critical':
1181ace1d91SYoshie Muranaka          return 'danger';
1191ace1d91SYoshie Muranaka        default:
1201ace1d91SYoshie Muranaka          return 'secondary';
1211ace1d91SYoshie Muranaka      }
122b1f559f0SSukanya Pandey    },
123b1f559f0SSukanya Pandey    username() {
124b1f559f0SSukanya Pandey      return this.$store.getters['global/username'];
125b8b6f791SYoshie Muranaka    }
126b8b6f791SYoshie Muranaka  },
12709e45cd4SDerick Montague  created() {
12809e45cd4SDerick Montague    this.getHostInfo();
1291ace1d91SYoshie Muranaka    this.getEvents();
13009e45cd4SDerick Montague  },
13174f8687dSYoshie Muranaka  mounted() {
13274f8687dSYoshie Muranaka    this.$root.$on(
13374f8687dSYoshie Muranaka      'change:isNavigationOpen',
13474f8687dSYoshie Muranaka      isNavigationOpen => (this.isNavigationOpen = isNavigationOpen)
13574f8687dSYoshie Muranaka    );
13674f8687dSYoshie Muranaka  },
137b8b6f791SYoshie Muranaka  methods: {
138b8b6f791SYoshie Muranaka    getHostInfo() {
139e2fd1567SDerick Montague      this.$store.dispatch('global/getHostStatus');
140e080a1a7SDerick Montague    },
1411ace1d91SYoshie Muranaka    getEvents() {
1421ace1d91SYoshie Muranaka      this.$store.dispatch('eventLog/getEventLogData');
1431ace1d91SYoshie Muranaka    },
144eb154bbcSYoshie Muranaka    refresh() {
145eb154bbcSYoshie Muranaka      this.$emit('refresh');
146eb154bbcSYoshie Muranaka    },
147e080a1a7SDerick Montague    logout() {
148c031b698SDerick Montague      this.$store.dispatch('authentication/logout');
14974f8687dSYoshie Muranaka    },
15074f8687dSYoshie Muranaka    toggleNavigation() {
15174f8687dSYoshie Muranaka      this.$root.$emit('toggle:navigation');
152b8b6f791SYoshie Muranaka    }
153a2988f40SDerick Montague  }
154a2988f40SDerick Montague};
155a2988f40SDerick Montague</script>
156a2988f40SDerick Montague
157b1f559f0SSukanya Pandey<style lang="scss">
15840865726SDerick Montague@import 'src/assets/styles/helpers';
15940865726SDerick Montague
160b1f559f0SSukanya Pandey.app-header {
16175b48321SDerick Montague  .link-skip-nav {
16275b48321SDerick Montague    position: absolute;
16375b48321SDerick Montague    top: -60px;
16475b48321SDerick Montague    left: 0.5rem;
16574f8687dSYoshie Muranaka    z-index: $zindex-popover;
16674f8687dSYoshie Muranaka    transition: $duration--moderate-01 $exit-easing--expressive;
16775b48321SDerick Montague    &:focus {
16875b48321SDerick Montague      top: 0.5rem;
16974f8687dSYoshie Muranaka      transition-timing-function: $entrance-easing--expressive;
17075b48321SDerick Montague    }
17175b48321SDerick Montague  }
1721ace1d91SYoshie Muranaka  .navbar-dark {
1731ace1d91SYoshie Muranaka    .navbar-text,
1746859203cSDerick Montague    .nav-link,
1756859203cSDerick Montague    .btn-link {
1761ace1d91SYoshie Muranaka      color: $white !important;
1776859203cSDerick Montague      fill: currentColor;
1781ace1d91SYoshie Muranaka    }
1791ace1d91SYoshie Muranaka  }
1806859203cSDerick Montague
181dc04feb5SYoshie Muranaka  .nav-item {
182dc04feb5SYoshie Muranaka    fill: $light;
183dc04feb5SYoshie Muranaka  }
18474f8687dSYoshie Muranaka
18574f8687dSYoshie Muranaka  .navbar {
18674f8687dSYoshie Muranaka    padding: 0;
187*057232b8SSurenNeware    @include media-breakpoint-up($responsive-layout-bp) {
18874f8687dSYoshie Muranaka      height: $header-height;
189*057232b8SSurenNeware    }
1906859203cSDerick Montague
1916859203cSDerick Montague    .btn-link {
1926859203cSDerick Montague      padding: $spacer / 2;
1936859203cSDerick Montague    }
194*057232b8SSurenNeware
195*057232b8SSurenNeware    .helper-menu {
196*057232b8SSurenNeware      @include media-breakpoint-down(sm) {
197*057232b8SSurenNeware        background-color: $gray-800;
198*057232b8SSurenNeware        width: 100%;
199*057232b8SSurenNeware        justify-content: flex-end;
200*057232b8SSurenNeware
201*057232b8SSurenNeware        .nav-link,
202*057232b8SSurenNeware        .btn {
203*057232b8SSurenNeware          padding: $spacer / 1.125 $spacer / 2;
204*057232b8SSurenNeware        }
205*057232b8SSurenNeware      }
206*057232b8SSurenNeware
207*057232b8SSurenNeware      .responsive-text {
208*057232b8SSurenNeware        @include media-breakpoint-down(xs) {
209*057232b8SSurenNeware          display: none;
210*057232b8SSurenNeware        }
211*057232b8SSurenNeware      }
212*057232b8SSurenNeware    }
21374f8687dSYoshie Muranaka  }
21474f8687dSYoshie Muranaka
21574f8687dSYoshie Muranaka  .navbar-nav {
21674f8687dSYoshie Muranaka    padding: 0 $spacer;
21774f8687dSYoshie Muranaka  }
21874f8687dSYoshie Muranaka
21974f8687dSYoshie Muranaka  .nav-trigger {
2207f970a1fSDerick Montague    fill: $light;
22174f8687dSYoshie Muranaka    width: $header-height;
22274f8687dSYoshie Muranaka    height: $header-height;
22374f8687dSYoshie Muranaka    transition: none;
22474f8687dSYoshie Muranaka
22574f8687dSYoshie Muranaka    svg {
22674f8687dSYoshie Muranaka      margin: 0;
22774f8687dSYoshie Muranaka    }
22874f8687dSYoshie Muranaka
22974f8687dSYoshie Muranaka    &:hover {
2307f970a1fSDerick Montague      fill: $light;
2317f970a1fSDerick Montague      background-color: $dark;
23274f8687dSYoshie Muranaka    }
23374f8687dSYoshie Muranaka
234*057232b8SSurenNeware    &.open {
235*057232b8SSurenNeware      background-color: $gray-800;
236*057232b8SSurenNeware    }
237*057232b8SSurenNeware
23874f8687dSYoshie Muranaka    @include media-breakpoint-up($responsive-layout-bp) {
23974f8687dSYoshie Muranaka      display: none;
24074f8687dSYoshie Muranaka    }
241dc04feb5SYoshie Muranaka  }
242b1f559f0SSukanya Pandey
243b1f559f0SSukanya Pandey  .dropdown {
244b1f559f0SSukanya Pandey    .dropdown-menu {
245*057232b8SSurenNeware      margin-top: 0;
246*057232b8SSurenNeware      @include media-breakpoint-up(md) {
247b1f559f0SSukanya Pandey        margin-top: 7px;
248b1f559f0SSukanya Pandey      }
249b1f559f0SSukanya Pandey    }
250b1f559f0SSukanya Pandey  }
251*057232b8SSurenNeware
252*057232b8SSurenNeware  .navbar-expand {
253*057232b8SSurenNeware    @include media-breakpoint-down(sm) {
254*057232b8SSurenNeware      flex-flow: wrap;
255*057232b8SSurenNeware    }
256*057232b8SSurenNeware  }
257*057232b8SSurenNeware}
258b8b6f791SYoshie Muranaka</style>
259