Skip to content
Snippets Groups Projects
Links.vue 3.09 KiB
Newer Older
<template>
  <ul class="nav nav-tabs">
    <li role="presentation" v-bind:class="{ active: $route.name === 'home' }">
      <router-link to="/">
        Home
      </router-link>
    </li>
    <li role="presentation" v-bind:class="{ active: $route.name === 'about' }">
      <router-link to="/about">
        About
      </router-link>
    </li>
HongKee Moon's avatar
HongKee Moon committed
    <!--<li role="presentation" v-bind:class="{ active: $route.name === 'condensates' }">-->
      <!--<router-link to="/condensates">-->
        <!--Condensates-->
HongKee Moon's avatar
HongKee Moon committed
      <!--</router-link>-->
    <!--</li>-->
    <!--<li role="presentation" v-bind:class="{ active: $route.name === 'browse' }">-->
      <!--<router-link to="/browse">-->
        <!--Browse-->
      <!--</router-link>-->
    <!--</li>-->
    <li role="presentation" v-bind:class="{ active: $route.name === 'biomolecular' }">
      <router-link to="/biomolecular">
        Biomolecular Condensates
      </router-link>
    </li>
    <li role="presentation" v-bind:class="{ active: $route.name === 'synthetic' }">
      <router-link to="/synthetic">
        Synthetic Condensates
HongKee Moon's avatar
HongKee Moon committed
      </router-link>
    </li>
HongKee Moon's avatar
HongKee Moon committed
    <!--<li role="presentation" v-bind:class="{ active: $route.name === 'condensate_example' }">-->
    <!--<router-link to="/condensate_example">-->
      <!--Condensate Example-->
    <!--</router-link>-->
    <!--</li>-->
    <!--<li role="presentation" v-bind:class="{ active: $route.name === 'protein_example' }">-->
      <!--<router-link to="/protein_example">-->
        <!--Protein Example-->
      <!--</router-link>-->
    <!--</li>-->
    <li role="presentation" v-bind:class="{ active: $route.name === 'statistics' }">
      <router-link to="/statistics">
        Statistics
      </router-link>
    </li>
    <li role="presentation" v-bind:class="{ active: $route.name === 'encyclopedia' }">
      <router-link to="/encyclopedia">
        Encyclopedia
      </router-link>
    </li>
    <li v-show="userData !== null" role="presentation" v-bind:class="{ active: $route.name === 'profile' }">
moon's avatar
moon committed
      <router-link to="/profile">
        Profile
      </router-link>
    </li>
    <li v-show="userData !== null" role="presentation">
moon's avatar
moon committed
      <router-link to="/login" v-on:click.native="signOut">
        <span class="fa fa-sign-out"/>
      </router-link>
    </li>
    <li v-show="userData === null" role="presentation" v-bind:class="{ active: $route.name === 'login' }">
moon's avatar
moon committed
      <router-link to="/login">
        Login
      </router-link>
    </li>
  </ul>
</template>

<script>
export default {
  name: "Links",
moon's avatar
moon committed
  data() {
    return {
      // userData: this.$store.getters['User/userData']
moon's avatar
moon committed
    }
  },
  methods: {
    signOut() {
      const vm = this
      window.localStorage.removeItem('jwt');
      window.localStorage.removeItem('userData');
      vm.$store.dispatch('User/logOut')
      vm.$router.push('/login')
  computed: {
    userData: function () {
      return this.$store.getters['User/userData']
    },
  },
  mounted: function () {
moon's avatar
moon committed
    const vm = this

    // console.log(vm.userData)
    // console.log(this.$route.name)
    if(vm.userData !== null) {
      vm.$router.push('/profile')
    }