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.

118 lines
2.6 KiB

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