GuidedSetupStart.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { useRouter } from 'vue-router'
  4. import {
  5. EnumSystemSetupInfoStatus,
  6. EnumSystemSetupInfoType,
  7. } from '#shared/graphql/types.ts'
  8. import MutationHandler from '#shared/server/apollo/handler/MutationHandler.ts'
  9. import CommonButton from '#desktop/components/CommonButton/CommonButton.vue'
  10. import LayoutPublicPage from '#desktop/components/layout/LayoutPublicPage/LayoutPublicPage.vue'
  11. import { useSystemSetupLockMutation } from '../graphql/mutations/systemSetupLock.api.ts'
  12. import { systemSetupBeforeRouteEnterGuard } from '../router/guards/systemSetupBeforeRouteEnterGuard.ts'
  13. import { useSystemSetupInfoStore } from '../stores/systemSetupInfo.ts'
  14. defineOptions({
  15. beforeRouteEnter: systemSetupBeforeRouteEnterGuard,
  16. })
  17. const router = useRouter()
  18. const systemSetupInfoStore = useSystemSetupInfoStore()
  19. const startSetup = (type: EnumSystemSetupInfoType) => {
  20. const lockMutation = new MutationHandler(useSystemSetupLockMutation())
  21. lockMutation
  22. .send()
  23. .then((data) => {
  24. systemSetupInfoStore.systemSetupInfo = {
  25. lockValue: data?.systemSetupLock?.value || '',
  26. type,
  27. status: EnumSystemSetupInfoStatus.InProgress,
  28. }
  29. router.push(`/guided-setup/${type}`)
  30. })
  31. .catch(() => {})
  32. }
  33. </script>
  34. <template>
  35. <LayoutPublicPage box-size="medium" :title="__('Welcome!')" show-logo>
  36. <CommonAlert
  37. v-if="systemSetupInfoStore.systemSetupAlreadyStarted"
  38. variant="warning"
  39. >{{
  40. $t(
  41. 'The setup has already been started. Please wait until it is finished.',
  42. )
  43. }}</CommonAlert
  44. >
  45. <template v-if="!systemSetupInfoStore.systemSetupAlreadyStarted">
  46. <div class="mb-14 mt-10 text-center">
  47. <CommonButton
  48. type="submit"
  49. variant="primary"
  50. size="large"
  51. @click="startSetup(EnumSystemSetupInfoType.Manual)"
  52. >
  53. {{ $t('Set up a new system') }}
  54. </CommonButton>
  55. </div>
  56. <div class="text-center">
  57. <CommonButton
  58. type="submit"
  59. variant="secondary"
  60. size="large"
  61. @click="startSetup(EnumSystemSetupInfoType.Import)"
  62. >
  63. {{ $t('Or migrate from another system') }}
  64. </CommonButton>
  65. </div>
  66. </template>
  67. </LayoutPublicPage>
  68. </template>