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.

162 lines
4.1 KiB

3 years ago
4 years ago
3 years ago
4 years ago
3 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. {{ mdiHexagonMultiple }}
  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 #activator="{ on }">
  48. <v-btn
  49. text
  50. v-on="on"
  51. >
  52. {{ $t('home.demoDropDown') }}
  53. <v-icon>{{ mdiMenuDown }}</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 #activator="{ on }">
  78. <v-btn on icon v-on="on">
  79. <v-icon>{{ mdiDotsVertical }}</v-icon>
  80. </v-btn>
  81. </template>
  82. <v-list>
  83. <v-subheader>{{ getUsername }}</v-subheader>
  84. <v-list-item>
  85. <v-list-item-content>
  86. <v-switch
  87. :input-value="isRTL"
  88. :label="direction"
  89. class="ms-1"
  90. @change="toggleRTL"
  91. />
  92. </v-list-item-content>
  93. </v-list-item>
  94. <v-list-item @click="signout">
  95. <v-list-item-icon>
  96. <v-icon>{{ mdiLogout }}</v-icon>
  97. </v-list-item-icon>
  98. <v-list-item-content>
  99. <v-list-item-title>
  100. {{ $t('user.signOut') }}
  101. </v-list-item-title>
  102. </v-list-item-content>
  103. </v-list-item>
  104. </v-list>
  105. </v-menu>
  106. </v-app-bar>
  107. </template>
  108. <script>
  109. import { mdiLogout, mdiDotsVertical, mdiMenuDown, mdiHexagonMultiple } from '@mdi/js'
  110. import { mapGetters, mapActions } from 'vuex'
  111. import TheColorModeSwitcher from './TheColorModeSwitcher'
  112. import LocaleMenu from './LocaleMenu'
  113. export default {
  114. components: {
  115. TheColorModeSwitcher,
  116. LocaleMenu
  117. },
  118. data() {
  119. return {
  120. items: [
  121. { title: this.$t('home.demoNER'), link: 'named-entity-recognition' },
  122. { title: this.$t('home.demoSent'), link: 'sentiment-analysis' },
  123. { title: this.$t('home.demoTranslation'), link: 'translation' },
  124. { title: 'Intent Detection and Slot Filling', link: 'intent-detection-and-slot-filling' },
  125. { title: this.$t('home.demoTextToSQL'), link: 'text-to-sql' },
  126. { title: 'Image Classification', link: 'image-classification' },
  127. { title: 'Speech to Text', link: 'speech-to-text' },
  128. ],
  129. mdiLogout,
  130. mdiDotsVertical,
  131. mdiMenuDown,
  132. mdiHexagonMultiple
  133. }
  134. },
  135. computed: {
  136. ...mapGetters('auth', ['isAuthenticated', 'getUsername']),
  137. ...mapGetters('projects', ['currentProject']),
  138. ...mapGetters('config', ['isRTL']),
  139. isIndividualProject() {
  140. return this.$route.name && this.$route.name.startsWith('projects-id')
  141. },
  142. direction() {
  143. return this.isRTL ? 'RTL' : 'LTR'
  144. }
  145. },
  146. methods: {
  147. ...mapActions('auth', ['logout']),
  148. ...mapActions('config', ['toggleRTL']),
  149. signout() {
  150. this.logout()
  151. this.$router.push(this.localePath('/'))
  152. }
  153. }
  154. }
  155. </script>