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
4.1 KiB

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