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.

185 lines
6.2 KiB

  1. <template lang="pug">
  2. v-app.setup
  3. v-content
  4. v-container
  5. v-layout
  6. v-flex(xs12, lg6, offset-lg3)
  7. v-card.radius-7
  8. .text-center
  9. img.setup-logo(src='/svg/logo-wikijs.svg', alt='Wiki.js Logo')
  10. v-alert(tile, color='indigo lighten-5', :value='true')
  11. v-icon.mr-3(color='indigo') mdi-package-variant
  12. span.indigo--text You are about to install Wiki.js #[strong {{wikiVersion}}].
  13. v-card-text
  14. .overline.pl-3 Create Administrator Account
  15. v-container.pa-3(grid-list-xl)
  16. v-layout(row, wrap)
  17. v-flex(xs12)
  18. v-text-field(
  19. outlined
  20. v-model='conf.adminEmail',
  21. label='Administrator Email',
  22. hint='The email address of the administrator account.',
  23. persistent-hint
  24. v-validate='{ required: true, email: true }',
  25. data-vv-name='adminEmail',
  26. data-vv-as='Administrator Email',
  27. data-vv-scope='admin',
  28. :error-messages='errors.collect(`admin.adminEmail`)'
  29. ref='adminEmailInput'
  30. )
  31. v-flex(xs6)
  32. v-text-field(
  33. outlined
  34. ref='adminPassword',
  35. counter='255'
  36. v-model='conf.adminPassword',
  37. label='Password',
  38. :append-icon="pwdMode ? 'mdi-eye-off' : 'mdi-eye'"
  39. @click:append="() => (pwdMode = !pwdMode)"
  40. :type="pwdMode ? 'password' : 'text'"
  41. hint='At least 8 characters long.',
  42. persistent-hint
  43. v-validate='{ required: true, min: 8 }',
  44. data-vv-name='adminPassword',
  45. data-vv-as='Password',
  46. data-vv-scope='admin',
  47. :error-messages='errors.collect(`admin.adminPassword`)'
  48. )
  49. v-flex(xs6)
  50. v-text-field(
  51. outlined
  52. ref='adminPasswordConfirm',
  53. counter='255'
  54. v-model='conf.adminPasswordConfirm',
  55. label='Confirm Password',
  56. :append-icon="pwdConfirmMode ? 'mdi-eye-off' : 'mdi-eye'"
  57. @click:append="() => (pwdConfirmMode = !pwdConfirmMode)"
  58. :type="pwdConfirmMode ? 'password' : 'text'"
  59. hint='Verify your password again.',
  60. persistent-hint
  61. v-validate='{ required: true, min: 8 }',
  62. data-vv-name='adminPasswordConfirm',
  63. data-vv-as='Confirm Password',
  64. data-vv-scope='admin',
  65. :error-messages='errors.collect(`admin.adminPasswordConfirm`)'
  66. @keyup.enter='install'
  67. )
  68. v-divider.mb-4
  69. v-checkbox.ml-3(
  70. color='primary',
  71. v-model='conf.telemetry',
  72. label='Allow Telemetry',
  73. persistent-hint,
  74. hint='Help Wiki.js developers improve this app with anonymized telemetry.'
  75. )
  76. v-alert(:value='error', type='error', icon='warning') {{ errorMessage }}
  77. v-divider.mt-3(v-if='!error')
  78. v-card-actions
  79. v-btn(color='primary', @click='install', :disabled='loading', x-large, flat, block)
  80. v-icon(left) mdi-check
  81. span Install
  82. v-dialog(v-model='loading', width='450', persistent)
  83. v-card(color='primary', dark).radius-7
  84. v-card-text.text-center.py-5
  85. .py-3(style='width: 64px; display:inline-block;')
  86. breeding-rhombus-spinner(
  87. :animation-duration='2000'
  88. :size='64'
  89. color='#FFF'
  90. )
  91. template(v-if='!success')
  92. .subtitle-1.white--text Finalizing your installation...
  93. .caption Just a moment
  94. template(v-else)
  95. .subtitle-1.white--text Installation complete!
  96. .caption Redirecting...
  97. </template>
  98. <script>
  99. import axios from 'axios'
  100. import _ from 'lodash'
  101. import { BreedingRhombusSpinner } from 'epic-spinners'
  102. export default {
  103. components: {
  104. BreedingRhombusSpinner
  105. },
  106. props: {
  107. wikiVersion: {
  108. type: String,
  109. required: true
  110. }
  111. },
  112. data() {
  113. return {
  114. loading: false,
  115. success: false,
  116. error: false,
  117. errorMessage: '',
  118. conf: {
  119. adminEmail: '',
  120. adminPassword: '',
  121. adminPasswordConfirm: '',
  122. telemetry: true
  123. },
  124. pwdMode: true,
  125. pwdConfirmMode: true
  126. }
  127. },
  128. mounted() {
  129. _.delay(() => {
  130. this.$refs.adminEmailInput.focus()
  131. }, 500)
  132. },
  133. methods: {
  134. async install () {
  135. const validationSuccess = await this.$validator.validateAll('admin')
  136. if (!validationSuccess || this.conf.adminPassword !== this.conf.adminPasswordConfirm) {
  137. return
  138. }
  139. this.loading = true
  140. this.success = false
  141. this.error = false
  142. this.$forceUpdate()
  143. _.delay(async () => {
  144. try {
  145. const resp = await axios.post('/finalize', this.conf)
  146. if (resp.data.ok === true) {
  147. this.success = true
  148. _.delay(() => {
  149. window.location.assign('/login')
  150. }, 3000)
  151. } else {
  152. this.error = true
  153. this.errorMessage = resp.data.error
  154. this.loading = false
  155. }
  156. } catch (err) {
  157. window.alert(err.message)
  158. }
  159. }, 1000)
  160. }
  161. }
  162. }
  163. </script>
  164. <style lang='scss'>
  165. .setup {
  166. .v-application--wrap {
  167. padding-top: 10vh;
  168. background-color: darken(mc('grey', '900'), 5%);
  169. background-image: url(/svg/motif-circuit.svg) !important;
  170. background-repeat: repeat;
  171. }
  172. &-logo {
  173. width: 300px;
  174. margin: 3rem 0 2rem 0;
  175. }
  176. }
  177. </style>