Navbar.vue 3.48 KB
Newer Older
1
<template>
gj4210's avatar
gj4210 committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  <b-navbar toggleable="lg" fixed="top" :type="$sysinfo.host_oper_mode.is_prod?'light':'dark'"
            :variant="$sysinfo.host_oper_mode.is_prod?'light':'dark'"
            :class="`bg-${$sysinfo.host_oper_mode.mode}` + ' shadow'">
    <!-- Brand and toggle get grouped for better mobile display -->
    <b-navbar-brand to="/">
      <img class="d-inline-block align-top scc-img" alt="SCC" src="@/assets/img/scc_logo_small.png"/>
      <span v-if="!$sysinfo.host_oper_mode.is_prod"> Instanz: {{ $sysinfo.host_oper_mode.mode }}</span>
    </b-navbar-brand>
    <b-navbar-toggle target="navbarNavDropdown">
      <font-awesome-icon icon="bars"/>
    </b-navbar-toggle>
    <!-- Collect the nav links, forms, and other content for toggling -->
    <b-collapse is-nav id="navbarNavDropdown" ref="navdropdown">
      <b-navbar-nav>
        <b-nav-item v-if="$sysinfo_mods_by_name['dnsvs']" to="/dnsvs/"
                    :active="$route.path.startsWith('/dnsvs/')">DNSVS
        </b-nav-item>
        <b-nav-item v-if="$sysinfo_mods_by_name['dhcp_leases']" to="/dhcp-leases/"
                    :active="$route.path.startsWith('/dhcp-leases/')">DHCP-Leases
        </b-nav-item>
        <b-nav-item href="https://www-net.scc.kit.edu/~netadmin/natvs/user/wrapper.cgi/" target="_blank">
          NATVS+
        </b-nav-item>
        <b-nav-item href="https://www-net.scc.kit.edu/~netadmin/netdoc/user/wrapper.cgi/" target="_blank">
          NETDOC
        </b-nav-item>
      </b-navbar-nav>
      <b-navbar-nav class="ml-auto">
        <GlobalSearch/>
        <b-nav-item :active="$store.state.show_sidebar"
                    @click.stop="$store.commit('showSidebar', !$store.state.show_sidebar)">
          <font-awesome-icon :icon="['fas', 'tasks']"/>
          Geplante Aktionen
          <b-badge variant="primary">{{ $store.state.ta_list ? $store.state.ta_list.length : 0 }}</b-badge>
        </b-nav-item>
        <b-nav-item-dropdown v-if="$store.state.user" right
                             :toggle-class="$route.path.startsWith('/user/')?'active':''">
          <template slot="button-content">
            <font-awesome-icon :icon="['fas', 'user']"/>
            <span v-if="$store.state.user"> {{ $store.state.user.login_name }}</span>
          </template>
          <template v-if="$store.state.user">
            <b-dropdown-item to="/user/tokens" :active="$route.path === '/user/tokens'">
              <font-awesome-icon :icon="['fas', 'code']"/>
              Accounts & Tokens
            </b-dropdown-item>
            <b-dropdown-divider/>
            <b-dropdown-item @click="logout">
              <font-awesome-icon :icon="['fas', 'sign-out-alt']"/>
              Abmelden
            </b-dropdown-item>
          </template>
        </b-nav-item-dropdown>
        <b-nav-item v-else to="/login">
          <font-awesome-icon :icon="['fas', 'sign-in-alt']"/>
          <span>Anmelden</span>
        </b-nav-item>
      </b-navbar-nav>
    </b-collapse><!-- /.navbar-collapse -->
  </b-navbar>
62
63
64
</template>

<script>
gj4210's avatar
gj4210 committed
65
66
import LoginService from '@/api-services/login.service'
import GlobalSearch from "@/components/GlobalSearch";
janis.streib's avatar
janis.streib committed
67

gj4210's avatar
gj4210 committed
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
export default {
  name: "Navbar",
  components: {GlobalSearch},
  data() {
    return {}
  },
  methods: {
    async logout() {
      if (this.$store.token == null) {
        await LoginService.logout(null)
      } else {
        await LoginService.logout(this.$store.state.token.pk || null)
      }
      this.$store.commit('logout')
      await this.$router.push('/login')
83
    }
gj4210's avatar
gj4210 committed
84
85
86
  }
}
</script>