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.

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