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.

158 lines
3.7 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. <v-menu
  33. open-on-hover
  34. offset-y
  35. >
  36. <template v-slot:activator="{ on }">
  37. <v-btn
  38. text
  39. v-on="on"
  40. >
  41. {{ $i18n.locale }}
  42. <v-icon>mdi-menu-down</v-icon>
  43. </v-btn>
  44. </template>
  45. <v-list
  46. v-for="locale in $i18n.locales"
  47. :key="locale.code"
  48. >
  49. <nuxt-link
  50. class="v-list-item v-list-item--link theme--dark"
  51. :to="switchLocalePath(locale.code)"
  52. >
  53. {{ locale.name }}
  54. </nuxt-link>
  55. </v-list>
  56. </v-menu>
  57. <v-btn
  58. v-if="isAuthenticated"
  59. text
  60. @click="$router.push(localePath('/projects'))"
  61. >
  62. {{ $t('header.projects') }}
  63. </v-btn>
  64. <v-menu
  65. v-if="!isAuthenticated"
  66. open-on-hover
  67. offset-y
  68. >
  69. <template v-slot:activator="{ on }">
  70. <v-btn
  71. text
  72. v-on="on"
  73. >
  74. {{ $t('home.demoDropDown') }}
  75. <v-icon>mdi-menu-down</v-icon>
  76. </v-btn>
  77. </template>
  78. <v-list>
  79. <v-list-item
  80. v-for="(item, index) in items"
  81. :key="index"
  82. @click="$router.push('/demo/' + item.link)"
  83. >
  84. <v-list-item-title>{{ item.title }}</v-list-item-title>
  85. </v-list-item>
  86. </v-list>
  87. </v-menu>
  88. <v-btn
  89. v-if="!isAuthenticated"
  90. outlined
  91. @click="$router.push(localePath('/auth'))"
  92. >
  93. {{ $t('user.login') }}
  94. </v-btn>
  95. <v-menu
  96. v-if="isAuthenticated"
  97. offset-y
  98. >
  99. <template v-slot:activator="{ on }">
  100. <v-btn on icon v-on="on">
  101. <v-icon>mdi-dots-vertical</v-icon>
  102. </v-btn>
  103. </template>
  104. <v-list>
  105. <v-subheader>{{ getUsername() }}</v-subheader>
  106. <v-list-item @click="signout">
  107. <v-list-item-icon>
  108. <v-icon>mdi-logout</v-icon>
  109. </v-list-item-icon>
  110. <v-list-item-content>
  111. <v-list-item-title>
  112. {{ $t('user.signOut') }}
  113. </v-list-item-title>
  114. </v-list-item-content>
  115. </v-list-item>
  116. </v-list>
  117. </v-menu>
  118. </v-app-bar>
  119. </template>
  120. <script>
  121. import { mapGetters, mapActions } from 'vuex'
  122. import TheColorModeSwitcher from '@/components/organisms/layout/TheColorModeSwitcher'
  123. export default {
  124. components: {
  125. TheColorModeSwitcher
  126. },
  127. data() {
  128. return {
  129. items: [
  130. { title: this.$t('home.demoNER'), link: 'named-entity-recognition' },
  131. { title: this.$t('home.demoSent'), link: 'sentiment-analysis' },
  132. { title: this.$t('home.demoTranslation'), link: 'translation' },
  133. { title: this.$t('home.demoTextToSQL'), link: 'text-to-sql' }
  134. ]
  135. }
  136. },
  137. computed: {
  138. ...mapGetters('auth', ['isAuthenticated', 'getUsername']),
  139. ...mapGetters('projects', ['currentProject']),
  140. isIndividualProject() {
  141. return this.$route.name && this.$route.name.startsWith('projects-id')
  142. }
  143. },
  144. methods: {
  145. ...mapActions('auth', ['logout']),
  146. signout() {
  147. this.logout()
  148. this.$router.push('/')
  149. }
  150. }
  151. }
  152. </script>