You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
3.2 KiB

4 years ago
4 years ago
4 years ago
  1. <template>
  2. <v-app-bar
  3. app
  4. clipped-left
  5. >
  6. <slot name="leftDrawerIcon" />
  7. <nuxt-link
  8. v-if="!isAuthenticated"
  9. to="/"
  10. style="line-height:0;"
  11. >
  12. <img src="~/assets/icon.png" height="48">
  13. </nuxt-link>
  14. <v-toolbar-title
  15. v-if="!isAuthenticated"
  16. class="ml-2 d-none d-sm-flex"
  17. >
  18. doccano
  19. </v-toolbar-title>
  20. <v-btn
  21. v-if="isAuthenticated && isIndividualProject"
  22. text
  23. style="text-transform:none"
  24. >
  25. <v-icon small class="mr-1">
  26. mdi-hexagon-multiple
  27. </v-icon>
  28. <span> {{ currentProject.name }}</span>
  29. </v-btn>
  30. <div class="flex-grow-1" />
  31. <the-color-mode-switcher />
  32. <locale-menu />
  33. <v-btn
  34. v-if="isAuthenticated"
  35. text
  36. @click="$router.push(localePath('/projects'))"
  37. >
  38. {{ $t('header.projects') }}
  39. </v-btn>
  40. <v-menu
  41. v-if="!isAuthenticated"
  42. open-on-hover
  43. offset-y
  44. >
  45. <template v-slot:activator="{ on }">
  46. <v-btn
  47. text
  48. v-on="on"
  49. >
  50. {{ $t('home.demoDropDown') }}
  51. <v-icon>mdi-menu-down</v-icon>
  52. </v-btn>
  53. </template>
  54. <v-list>
  55. <v-list-item
  56. v-for="(item, index) in items"
  57. :key="index"
  58. @click="$router.push('/demo/' + item.link)"
  59. >
  60. <v-list-item-title>{{ item.title }}</v-list-item-title>
  61. </v-list-item>
  62. </v-list>
  63. </v-menu>
  64. <v-btn
  65. v-if="!isAuthenticated"
  66. outlined
  67. @click="$router.push(localePath('/auth'))"
  68. >
  69. {{ $t('user.login') }}
  70. </v-btn>
  71. <v-menu
  72. v-if="isAuthenticated"
  73. offset-y
  74. >
  75. <template v-slot:activator="{ on }">
  76. <v-btn on icon v-on="on">
  77. <v-icon>mdi-dots-vertical</v-icon>
  78. </v-btn>
  79. </template>
  80. <v-list>
  81. <v-subheader>{{ getUsername() }}</v-subheader>
  82. <v-list-item @click="signout">
  83. <v-list-item-icon>
  84. <v-icon>mdi-logout</v-icon>
  85. </v-list-item-icon>
  86. <v-list-item-content>
  87. <v-list-item-title>
  88. {{ $t('user.signOut') }}
  89. </v-list-item-title>
  90. </v-list-item-content>
  91. </v-list-item>
  92. </v-list>
  93. </v-menu>
  94. </v-app-bar>
  95. </template>
  96. <script>
  97. import { mapGetters, mapActions } from 'vuex'
  98. import TheColorModeSwitcher from '@/components/organisms/layout/TheColorModeSwitcher'
  99. import LocaleMenu from '@/components/organisms/layout/LocaleMenu'
  100. export default {
  101. components: {
  102. TheColorModeSwitcher,
  103. LocaleMenu
  104. },
  105. data() {
  106. return {
  107. items: [
  108. { title: this.$t('home.demoNER'), link: 'named-entity-recognition' },
  109. { title: this.$t('home.demoSent'), link: 'sentiment-analysis' },
  110. { title: this.$t('home.demoTranslation'), link: 'translation' },
  111. { title: this.$t('home.demoTextToSQL'), link: 'text-to-sql' }
  112. ]
  113. }
  114. },
  115. computed: {
  116. ...mapGetters('auth', ['isAuthenticated', 'getUsername']),
  117. ...mapGetters('projects', ['currentProject']),
  118. isIndividualProject() {
  119. return this.$route.name && this.$route.name.startsWith('projects-id')
  120. }
  121. },
  122. methods: {
  123. ...mapActions('auth', ['logout']),
  124. signout() {
  125. this.logout()
  126. this.$router.push(this.localePath('/'))
  127. }
  128. }
  129. }
  130. </script>