Home.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!-- Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <template>
  3. <div>
  4. <h1>{{ i18n.t('Home') }}</h1>
  5. <p>{{ userData?.firstname }} {{ userData?.lastname }}</p>
  6. <br />
  7. <p v-on:click="logout">{{ i18n.t('Logout') }}</p>
  8. <br />
  9. <p v-on:click="goToTickets">Go to Tickets</p>
  10. <br />
  11. <CommonLink v-bind:link="{ name: 'TicketOverview' }">
  12. <span>Test Route Link</span>
  13. </CommonLink>
  14. <br />
  15. <CommonLink v-bind:link="{ name: 'Login' }" v-bind:disabled="true">
  16. <span>DisabledTest Route Link</span>
  17. </CommonLink>
  18. <br />
  19. <CommonLink link="https://www.google.com"> Test External Link </CommonLink>
  20. <br />
  21. <p v-on:click="refetchConfig">refetchConfig</p>
  22. <br />
  23. <p v-on:click="fetchCurrentUser">fetchCurrentUser</p>
  24. <br /><br />
  25. <h1 class="mb-4 text-lg">Configs:</h1>
  26. <template v-if="config.value">
  27. <p v-for="(value, key) in config.value" v-bind:key="(key as string)">
  28. Key: {{ key }}<br />
  29. Value: {{ value }} <br /><br />
  30. </p>
  31. </template>
  32. </div>
  33. </template>
  34. <script setup lang="ts">
  35. import useNotifications from '@common/composables/useNotifications'
  36. import useAuthenticatedStore from '@common/stores/authenticated'
  37. import useSessionUserStore from '@common/stores/session/user'
  38. import { storeToRefs } from 'pinia'
  39. import { useRouter } from 'vue-router'
  40. import useApplicationConfigStore from '@common/stores/application/config'
  41. import { useCurrentUserQuery } from '@common/graphql/api'
  42. import { NotificationTypes } from '@common/types/notification'
  43. import useViewTransition from '@mobile/composables/useViewTransition'
  44. import ViewTransitions from '@mobile/types/transition'
  45. // TODO: Only testing for the notifications...
  46. const { notify, clearAllNotifications } = useNotifications()
  47. notify({
  48. message: __('Hello Home!!!'),
  49. type: NotificationTypes.WARN,
  50. durationMS: 10000,
  51. })
  52. const sessionUser = useSessionUserStore()
  53. const { value: userData } = storeToRefs(sessionUser)
  54. const authenticated = useAuthenticatedStore()
  55. const router = useRouter()
  56. const logout = (): void => {
  57. clearAllNotifications()
  58. authenticated.logout().then(() => {
  59. router.push('/login')
  60. })
  61. }
  62. const config = useApplicationConfigStore()
  63. const refetchConfig = async (): Promise<void> => {
  64. await config.getConfig()
  65. }
  66. const fetchCurrentUser = () => {
  67. useCurrentUserQuery({ fetchPolicy: 'no-cache' })
  68. }
  69. const goToTickets = () => {
  70. const { setViewTransition } = useViewTransition()
  71. setViewTransition(ViewTransitions.NEXT)
  72. router.push('/tickets')
  73. }
  74. </script>