UserNav.vue 2.11 KB
Newer Older
Anton's avatar
Anton committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
<template lang="pug">
  q-toolbar(color="dark")
    // q-btn.hide-on-drawer-visible(flat, icon="menu", @click='$refs.drawer.open()')
    q-toolbar-title(:padding='2')
      //q-btn(:class="{ 'text-primary': currentApp === null }", big, flat,
        @click="currentApp = null; $router.push({ name: 'site.welcome' })") Motionbank
      q-btn(
        :class="{ 'text-primary': currentApp === 'piecemaker' }",
        @click="executeApp('piecemaker', 'piecemaker.timelines.list')",
        big, flat
        ) Piecemaker
      q-btn(
        :color="currentApp === 'mosys' ? 'primary' : ''",
        @click="executeApp('mosys', 'mosys.grids.list')",
        big, flat
        ) Mosys
Anton's avatar
Anton committed
17 18 19
      q-btn(v-if="userHasDocuments",
        :color="currentApp === 'documents' ? 'primary' : ''",
        @click="executeApp('documents', 'documents.list')",
Anton's avatar
Anton committed
20
        big, flat
Anton's avatar
Anton committed
21
        ) Documents
Anton's avatar
Anton committed
22 23

    q-btn(color="primary", flat, icon="settings",
Anton's avatar
Anton committed
24
    v-if="user && !isElectron", @click="$router.push({ name: 'users.manage' })") {{ user.profile ? user.profile.name : '' }}
Anton's avatar
Anton committed
25 26

    q-btn(color="primary", flat, icon="eject",
27
      v-if="user && !isElectron", @click="logout") {{ $t('navigation.logout') }}
Anton's avatar
Anton committed
28 29

    q-btn(color="primary", flat, icon="arrow_forward",
30
      v-if="!user && !isElectron", @click="login") {{ $t('navigation.login') }}
Anton's avatar
Anton committed
31 32 33 34
</template>

<script>
  import { mapGetters } from 'vuex'
Anton's avatar
Anton committed
35
  import { userHasFeature } from 'mbjs-quasar/src/lib'
Anton's avatar
Anton committed
36 37 38 39 40 41 42 43 44 45 46 47

  export default {
    data () {
      return {
        currentApp: null,
        env: process.env
      }
    },
    computed: {
      ...mapGetters({
        user: 'auth/getUserState'
      }),
Anton's avatar
Anton committed
48 49
      userHasDocuments () {
        return userHasFeature(this.user, 'documents')
50 51 52
      },
      isElectron () {
        return process.env.IS_ELECTRON || false
Anton's avatar
Anton committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
      }
    },
    methods: {
      executeApp (appName, routeName) {
        this.currentApp = appName
        this.$router.push({ name: routeName })
      },
      login () {
        this.$auth.authenticate()
      },
      logout () {
        this.$store.commit('auth/setUser', undefined)
        this.$auth.logout()
      }
    }
  }
</script>

<style></style>