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.

133 lines
3.0 KiB

4 years ago
4 years ago
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-btn
  33. v-if="isAuthenticated"
  34. text
  35. @click="$router.push('/projects')"
  36. >
  37. Projects
  38. </v-btn>
  39. <v-menu
  40. v-if="!isAuthenticated"
  41. open-on-hover
  42. offset-y
  43. >
  44. <template v-slot:activator="{ on }">
  45. <v-btn
  46. text
  47. v-on="on"
  48. >
  49. Demo
  50. <v-icon>mdi-menu-down</v-icon>
  51. </v-btn>
  52. </template>
  53. <v-list>
  54. <v-list-item
  55. v-for="(item, index) in items"
  56. :key="index"
  57. @click="$router.push('/demo/' + item.link)"
  58. >
  59. <v-list-item-title>{{ item.title }}</v-list-item-title>
  60. </v-list-item>
  61. </v-list>
  62. </v-menu>
  63. <v-btn
  64. v-if="!isAuthenticated"
  65. outlined
  66. @click="$router.push('/auth')"
  67. >
  68. Sign in
  69. </v-btn>
  70. <v-menu
  71. v-if="isAuthenticated"
  72. offset-y
  73. >
  74. <template v-slot:activator="{ on }">
  75. <v-btn on icon v-on="on">
  76. <v-icon>mdi-dots-vertical</v-icon>
  77. </v-btn>
  78. </template>
  79. <v-list>
  80. <v-subheader>{{ getUsername() }}</v-subheader>
  81. <v-list-item @click="signout">
  82. <v-list-item-icon>
  83. <v-icon>mdi-logout</v-icon>
  84. </v-list-item-icon>
  85. <v-list-item-content>
  86. <v-list-item-title>
  87. Sign out
  88. </v-list-item-title>
  89. </v-list-item-content>
  90. </v-list-item>
  91. </v-list>
  92. </v-menu>
  93. </v-app-bar>
  94. </template>
  95. <script>
  96. import { mapGetters, mapActions } from 'vuex'
  97. import TheColorModeSwitcher from '@/components/organisms/layout/TheColorModeSwitcher'
  98. export default {
  99. components: {
  100. TheColorModeSwitcher
  101. },
  102. data() {
  103. return {
  104. items: [
  105. { title: 'Named Entity Recognition', link: 'named-entity-recognition' },
  106. { title: 'Sentiment Analysis', link: 'sentiment-analysis' },
  107. { title: 'Translation', link: 'translation' },
  108. { title: 'Text to SQL', link: 'text-to-sql' }
  109. ]
  110. }
  111. },
  112. computed: {
  113. ...mapGetters('auth', ['isAuthenticated', 'getUsername']),
  114. ...mapGetters('projects', ['currentProject']),
  115. isIndividualProject() {
  116. return this.$route.name && this.$route.name.startsWith('projects-id')
  117. }
  118. },
  119. methods: {
  120. ...mapActions('auth', ['logout']),
  121. signout() {
  122. this.logout()
  123. this.$router.push('/')
  124. }
  125. }
  126. }
  127. </script>