Navbar.vue 6.42 KB
Newer Older
1
<template>
gj4210's avatar
gj4210 committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  <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>
16
        <b-nav-item v-if="$sysinfo_js_mods.includes('dnsvs')" to="/dnsvs/"
gj4210's avatar
gj4210 committed
17
18
                    :active="$route.path.startsWith('/dnsvs/')">DNSVS
        </b-nav-item>
19
        <b-nav-item v-if="$sysinfo_js_mods.includes('macauth')" to="/macauth/"
20
                    :active="$route.path.startsWith('/macauth')">MACAuth
21
        </b-nav-item>
gj4210's avatar
gj4210 committed
22
23
24
        <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>
25
26
        <b-nav-item v-if="$sysinfo_js_mods.includes('usr_netdoc')" to="/usr_netdoc/"
                    :active="$route.path.startsWith('/usr_netdoc/')">
gj4210's avatar
gj4210 committed
27
28
          NETDOC
        </b-nav-item>
janis.streib's avatar
FMT    
janis.streib committed
29
30
31
        <b-nav-item
          :href="$sysinfo.host_oper_mode.is_prod?'https://www-net.scc.kit.edu/~netadmin/natvs/user/wrapper.cgi/':`https://www-net-${$sysinfo.host_oper_mode.mode}.scc.kit.edu/~netadmin/natvs/user/wrapper.cgi/`"
          target="_blank">
32
33
          NATVS+
        </b-nav-item>
janis.streib's avatar
janis.streib committed
34
35
36
37
38
        <b-nav-item
          :href="$sysinfo.host_oper_mode.is_prod?'https://www-net.scc.kit.edu/~netadmin/netdoc/user/wrapper.cgi/':`https://www-net-${$sysinfo.host_oper_mode.mode}.scc.kit.edu/~netadmin/netdoc/user/wrapper.cgi/`"
          target="_blank">
          Netdoc
        </b-nav-item>
gj4210's avatar
gj4210 committed
39
40
      </b-navbar-nav>
      <b-navbar-nav class="ml-auto">
41
        <GlobalSearch v-if="$store.state.user"/>
gj4210's avatar
gj4210 committed
42
43
44
45
46
47
        <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>
janis.streib's avatar
janis.streib committed
48
49
50
51
52
53
54
55
56
57
        <b-nav-item-dropdown v-if="$store.state.user" right
                             :toggle-class="$route.path.startsWith('/tools/')?'active':''">
          <template slot="button-content">
            <font-awesome-icon icon="tools"/>
            Werkzeuge
          </template>
          <b-dropdown-item to="/tools/macfinder" :active="$route.path === '/tools/macfinder'">
            <font-awesome-icon fixed-width icon="ethernet"/>
            Macfinder
          </b-dropdown-item>
janis.streib's avatar
janis.streib committed
58
59
60
61
          <b-dropdown-item to="/tools/oui_lookup" :active="$route.path === '/tools/oui_lookup'">
            <font-awesome-icon fixed-width icon="question"/>
            MAC-Vendor-Suche
          </b-dropdown-item>
janis.streib's avatar
janis.streib committed
62
        </b-nav-item-dropdown>
janis.streib's avatar
janis.streib committed
63
64
65
        <b-nav-item-dropdown v-if="$store.state.user" right
                             :toggle-class="$route.path.startsWith('/cntl/')?'active':''">
          <template slot="button-content">
janis.streib's avatar
FMT    
janis.streib committed
66
67
            <font-awesome-icon :icon="['fas', 'users-cog']"></font-awesome-icon>
            Organisation
janis.streib's avatar
janis.streib committed
68
69
70
71
72
73
74
75
76
77
          </template>
          <b-dropdown-item to="/cntl/ou" :active="$route.path === '/cntl/ou'">
            <font-awesome-icon fixed-width :icon="['fas', 'building']"/>
            Organisationseinheiten
          </b-dropdown-item>
          <b-dropdown-item to="/cntl/groups" :active="$route.path === '/cntl/groups'">
            <font-awesome-icon fixed-width :icon="['fas', 'users']"/>
            Gruppen
          </b-dropdown-item>
        </b-nav-item-dropdown>
gj4210's avatar
gj4210 committed
78
79
80
        <b-nav-item-dropdown v-if="$store.state.user" right
                             :toggle-class="$route.path.startsWith('/user/')?'active':''">
          <template slot="button-content">
janis.streib's avatar
FMT    
janis.streib committed
81
            <font-awesome-icon :icon="['fas', usr_ico]"/>
gj4210's avatar
gj4210 committed
82
83
84
85
            <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'">
janis.streib's avatar
janis.streib committed
86
              <font-awesome-icon dixed-width :icon="['fas', 'code']"/>
janis.streib's avatar
janis.streib committed
87
              Unterkonten & API-Tokens
gj4210's avatar
gj4210 committed
88
89
90
            </b-dropdown-item>
            <b-dropdown-divider/>
            <b-dropdown-item @click="logout">
janis.streib's avatar
janis.streib committed
91
              <font-awesome-icon fixed-width :icon="['fas', 'sign-out-alt']"/>
gj4210's avatar
gj4210 committed
92
93
94
95
96
97
              Abmelden
            </b-dropdown-item>
          </template>
        </b-nav-item-dropdown>
        <b-nav-item v-else to="/login">
          <font-awesome-icon :icon="['fas', 'sign-in-alt']"/>
janis.streib's avatar
janis.streib committed
98
          <span> Anmelden</span>
gj4210's avatar
gj4210 committed
99
100
101
102
        </b-nav-item>
      </b-navbar-nav>
    </b-collapse><!-- /.navbar-collapse -->
  </b-navbar>
103
104
105
</template>

<script>
gj4210's avatar
gj4210 committed
106
import LoginService from '@/api-services/login.service'
janis.streib's avatar
janis.streib committed
107
import GlobalSearch from '@/components/GlobalSearch'
janis.streib's avatar
janis.streib committed
108

gj4210's avatar
gj4210 committed
109
export default {
janis.streib's avatar
janis.streib committed
110
  name: 'Navbar',
janis.streib's avatar
FMT    
janis.streib committed
111
112
113
114
115
116
117
118
  components: {GlobalSearch},
  data() {
    return {
      usr_ico: 'user',
      ms: 0,
      pev: null,
      cuv: null
    }
gj4210's avatar
gj4210 committed
119
120
  },
  methods: {
janis.streib's avatar
FMT    
janis.streib committed
121
    async logout() {
gj4210's avatar
gj4210 committed
122
123
124
125
126
127
128
      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')
129
    }
janis.streib's avatar
FMT    
janis.streib committed
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
  },
  mounted() {
    const self = this
    document.documentElement.onmousemove = function (event) {
      self.cuv = event
    }
    const intv = setInterval(function () {
      if (self.pev && self.cuv) {
        const movementX = Math.abs(self.cuv.screenX - self.pev.screenX)
        const movementY = Math.abs(self.cuv.screenY - self.pev.screenY)
        const movement = Math.sqrt(movementX * movementX + movementY * movementY)
        const speed = 10 * movement
        if (speed > self.ms) {
          self.ms = speed
        }
      }
      self.pev = self.cuv
janis.streib's avatar
janis.streib committed
147
      if (self.ms > 10000) {
janis.streib's avatar
FMT    
janis.streib committed
148
149
150
151
        self.usr_ico = 'user-ninja'
        clearInterval(intv)
      }
    }, 100)
gj4210's avatar
gj4210 committed
152
153
  }
}
154
</script>