GuidedSetupManualSystemInformation.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { shallowRef, computed, reactive } from 'vue'
  4. import { useRouter } from 'vue-router'
  5. import Form from '#shared/components/Form/Form.vue'
  6. import type {
  7. FormSubmitData,
  8. FormValues,
  9. } from '#shared/components/Form/types.ts'
  10. import { useBaseUrl } from '#shared/composables/useBaseUrl.ts'
  11. import { useLogoUrl } from '#shared/composables/useLogoUrl.ts'
  12. import { MutationHandler } from '#shared/server/apollo/handler/index.ts'
  13. import { useApplicationStore } from '#shared/stores/application.ts'
  14. import GuidedSetupActionFooter from '../../components/GuidedSetupActionFooter.vue'
  15. import { useSystemSetup } from '../../composables/useSystemSetup.ts'
  16. import { useGuidedSetupSetSystemInformationMutation } from '../../graphql/mutations/setSystemInformation.api.ts'
  17. import type { SystemInformationData } from '../../types/setup-manual.ts'
  18. const router = useRouter()
  19. const application = useApplicationStore()
  20. const { logoUrl } = useLogoUrl()
  21. const { setTitle } = useSystemSetup()
  22. setTitle(__('System Information'))
  23. const systemInformationSchema = [
  24. {
  25. isLayout: true,
  26. element: 'div',
  27. attrs: {
  28. class: 'grid gap-y-2.5',
  29. },
  30. children: [
  31. {
  32. name: 'organization',
  33. label: __('Organization name'),
  34. type: 'text',
  35. required: true,
  36. placeholder: __('Company Inc.'),
  37. },
  38. {
  39. name: 'logo',
  40. label: __('Organization logo'),
  41. type: 'imageUpload',
  42. props: {
  43. placeholderImagePath: logoUrl,
  44. },
  45. },
  46. {
  47. if: '$isSystemOnlineService !== true',
  48. name: 'url',
  49. label: __('System URL'),
  50. type: 'text',
  51. required: true,
  52. validation: 'url',
  53. help: __('The URL of this installation of Zammad.'),
  54. },
  55. ],
  56. },
  57. ]
  58. const { baseUrl } = useBaseUrl()
  59. const initialValues: FormValues = {
  60. organization: application.config.organization,
  61. url: baseUrl.value,
  62. }
  63. const form = shallowRef()
  64. const isSystemOnlineService = computed(
  65. () => application.config.system_online_service,
  66. )
  67. const schemaData = reactive({
  68. isSystemOnlineService,
  69. })
  70. const dateTimeFormatOptions = Intl?.DateTimeFormat
  71. ? new Intl.DateTimeFormat().resolvedOptions()
  72. : null
  73. const locale = dateTimeFormatOptions?.locale
  74. const timezone = dateTimeFormatOptions?.timeZone
  75. const setSystemInformation = async (formData: SystemInformationData) => {
  76. const setSystemInformationMutation = new MutationHandler(
  77. useGuidedSetupSetSystemInformationMutation({}),
  78. )
  79. return setSystemInformationMutation
  80. .send({
  81. input: {
  82. organization: formData.organization,
  83. logo: formData.logo,
  84. url: formData.url,
  85. localeDefault: locale,
  86. timezoneDefault: timezone,
  87. },
  88. })
  89. .then(() => {
  90. if (application.config.system_online_service) {
  91. router.push('/guided-setup/manual/channels/email-pre-configured')
  92. return
  93. }
  94. router.push('/guided-setup/manual/email-notification')
  95. })
  96. }
  97. </script>
  98. <template>
  99. <Form
  100. id="set-system-manual"
  101. ref="form"
  102. form-class="mb-2.5"
  103. :schema="systemInformationSchema"
  104. :schema-data="schemaData"
  105. :initial-values="initialValues"
  106. @submit="
  107. setSystemInformation($event as FormSubmitData<SystemInformationData>)
  108. "
  109. />
  110. <GuidedSetupActionFooter
  111. :form="form"
  112. :submit-button-text="__('Save and Continue')"
  113. />
  114. </template>