Home.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <!-- Copyright (C) 2012-2021 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. <p v-on:click="refetchConfig">refetchConfig</p>
  12. <br />
  13. <p v-on:click="fetchCurrentUser">fetchCurrentUser</p>
  14. <br /><br />
  15. <h1 class="text-lg mb-4">Configs:</h1>
  16. <template v-if="config.value">
  17. <p v-for="(value, key) in config.value" v-bind:key="(key as string)">
  18. Key: {{ key }}<br />
  19. Value: {{ value }} <br /><br />
  20. </p>
  21. </template>
  22. </div>
  23. </template>
  24. <script setup lang="ts">
  25. import useNotifications from '@common/composables/useNotifications'
  26. import useAuthenticatedStore from '@common/stores/authenticated'
  27. import useSessionUserStore from '@common/stores/session/user'
  28. import { storeToRefs } from 'pinia'
  29. import { useRouter } from 'vue-router'
  30. import useApplicationConfigStore from '@common/stores/application/config'
  31. import { useCurrentUserQuery } from '@common/graphql/api'
  32. import { NotificationTypes } from '@common/types/notification'
  33. // TODO: Only testing for the notifications...
  34. const { notify, clearAllNotifications } = useNotifications()
  35. notify({
  36. message: __('Hello Home!!!'),
  37. type: NotificationTypes.WARN,
  38. })
  39. const sessionUser = useSessionUserStore()
  40. const { value: userData } = storeToRefs(sessionUser)
  41. const authenticated = useAuthenticatedStore()
  42. const router = useRouter()
  43. const logout = (): void => {
  44. clearAllNotifications()
  45. authenticated.logout().then(() => {
  46. router.push('/login')
  47. })
  48. }
  49. const config = useApplicationConfigStore()
  50. const refetchConfig = async (): Promise<void> => {
  51. await config.getConfig()
  52. }
  53. const fetchCurrentUser = () => {
  54. const { result } = useCurrentUserQuery({ fetchPolicy: 'no-cache' })
  55. console.log('result', result)
  56. }
  57. const goToTickets = () => {
  58. router.push('/tickets')
  59. }
  60. </script>