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.

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