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.

323 lines
12 KiB

  1. <template lang="pug">
  2. v-app.setup
  3. v-toolbar(color='blue darken-2', dark, app, clipped-left, fixed, flat)
  4. v-spacer
  5. v-toolbar-title
  6. span.subheading Wiki.js Setup
  7. v-spacer
  8. v-content.white
  9. v-progress-linear.ma-0(indeterminate, height='4', :active='loading')
  10. v-stepper.elevation-0(v-model='state')
  11. v-stepper-header
  12. v-stepper-step(step='1' :complete='state > 1')
  13. | Welcome
  14. small Wiki.js Installation Wizard
  15. v-divider
  16. v-stepper-step(step='2' :complete='state > 2')
  17. | Administration Account
  18. small Create the admin account
  19. v-divider(v-if='this.conf.upgrade')
  20. v-stepper-step(step='3' :complete='state > 3', v-if='this.conf.upgrade')
  21. | Upgrade from Wiki.js 1.x
  22. small Migrate your existing installation
  23. v-divider
  24. v-stepper-step(:step='this.conf.upgrade ? 4 : 3' :complete='this.conf.upgrade ? state > 3 : state > 4')
  25. | Final Steps
  26. small Finalizing your installation
  27. v-stepper-items
  28. //- ==============================================
  29. //- WELCOME
  30. //- ==============================================
  31. v-stepper-content(step='1')
  32. v-card.text-xs-center.pa-3(flat)
  33. img(src='/svg/logo-wikijs.svg', alt='Wiki.js Logo', style='width: 300px;')
  34. .text-xs-center
  35. .body-2.py-2 This installation wizard will guide you through the steps needed to get your wiki up and running in no time!
  36. .body-1 Detailed information about installation and usage can be found on the #[a(href='https://wiki.requarks.io/docs') official documentation site].
  37. .body-1 Should you have any question or would like to report something that doesn't look right, feel free to create a new issue on the #[a(href='https://github.com/Requarks/wiki/issues') GitHub project].
  38. .body-1.py-3
  39. v-icon.mr-2(color='indigo') open_in_browser
  40. span.indigo--text You are about to install Wiki.js #[strong {{wikiVersion}}].
  41. v-btn.mt-4(color='primary', @click='proceedToAdmin', :disabled='loading', large)
  42. span Start
  43. v-icon(right) arrow_forward
  44. v-divider.my-5
  45. .body-2 Additional Setup Options
  46. div(style='display:inline-block;')
  47. v-checkbox(
  48. color='primary',
  49. v-model='conf.telemetry',
  50. label='Allow Telemetry',
  51. persistent-hint,
  52. hint='Help Wiki.js developers improve this app with anonymized telemetry.'
  53. )
  54. v-checkbox.mt-3(
  55. color='primary',
  56. v-model='conf.upgrade',
  57. label='Upgrade from Wiki.js 1.x',
  58. disabled
  59. persistent-hint,
  60. hint='Check this box if you are upgrading from Wiki.js 1.x and wish to migrate your existing data.'
  61. )
  62. //- ==============================================
  63. //- ADMINISTRATOR ACCOUNT
  64. //- ==============================================
  65. v-stepper-content(step='2')
  66. v-card.text-xs-center(flat)
  67. svg.icons.is-64: use(xlink:href='#nc-man-black')
  68. .subheading Administrator Account
  69. .body-2 A root administrator account will be created for local authentication. From this account, you can create or authorize more users.
  70. v-form
  71. v-container
  72. v-layout(row, wrap)
  73. v-flex(xs12)
  74. v-text-field(
  75. outline
  76. background-color='grey lighten-2'
  77. v-model='conf.adminEmail',
  78. label='Administrator Email',
  79. hint='The email address of the administrator account',
  80. persistent-hint
  81. v-validate='{ required: true, email: true }',
  82. data-vv-name='adminEmail',
  83. data-vv-as='Administrator Email',
  84. data-vv-scope='admin',
  85. :error-messages='errors.collect(`adminEmail`)'
  86. ref='adminEmailInput'
  87. )
  88. v-flex.pr-3(xs6)
  89. v-text-field(
  90. outline
  91. background-color='grey lighten-2'
  92. ref='adminPassword',
  93. counter='255'
  94. v-model='conf.adminPassword',
  95. label='Password',
  96. :append-icon="pwdMode ? 'visibility' : 'visibility_off'"
  97. @click:append="() => (pwdMode = !pwdMode)"
  98. :type="pwdMode ? 'password' : 'text'"
  99. hint='At least 8 characters long.',
  100. persistent-hint
  101. v-validate='{ required: true, min: 8 }',
  102. data-vv-name='adminPassword',
  103. data-vv-as='Password',
  104. data-vv-scope='admin',
  105. :error-messages='errors.collect(`adminPassword`)'
  106. )
  107. v-flex(xs6)
  108. v-text-field(
  109. outline
  110. background-color='grey lighten-2'
  111. ref='adminPasswordConfirm',
  112. counter='255'
  113. v-model='conf.adminPasswordConfirm',
  114. label='Confirm Password',
  115. :append-icon="pwdConfirmMode ? 'visibility' : 'visibility_off'"
  116. @click:append="() => (pwdConfirmMode = !pwdConfirmMode)"
  117. :type="pwdConfirmMode ? 'password' : 'text'"
  118. hint='Verify your password again.',
  119. persistent-hint
  120. v-validate='{ required: true, min: 8 }',
  121. data-vv-name='adminPasswordConfirm',
  122. data-vv-as='Confirm Password',
  123. data-vv-scope='admin',
  124. :error-messages='errors.collect(`adminPasswordConfirm`)'
  125. @keyup.enter='proceedToUpgrade'
  126. )
  127. .pt-3.text-xs-center
  128. v-btn(@click='proceedToWelcome', :disabled='loading') Back
  129. v-btn(color='primary', @click='proceedToUpgrade', :disabled='loading') Continue
  130. //- ==============================================
  131. //- UPGRADE FROM 1.x
  132. //- ==============================================
  133. v-stepper-content(step='3', v-if='conf.upgrade')
  134. v-card.text-xs-center(flat)
  135. svg.icons.is-64: use(xlink:href='#nc-spaceship')
  136. .subheading Upgrade from Wiki.js 1.x
  137. .body-2 Migrating from a Wiki.js 1.x installation is quick and simple.
  138. v-form
  139. v-container
  140. v-layout(row)
  141. v-flex(xs12)
  142. v-text-field(
  143. outline
  144. background-color='grey lighten-2'
  145. v-model='conf.upgMongo',
  146. placeholder='mongodb://',
  147. label='Connection String to Wiki.js 1.x MongoDB database',
  148. persistent-hint,
  149. hint='A MongoDB database connection string where a Wiki.js 1.x installation is located. No alterations will be made to this database.',
  150. v-validate='{ required: true, min: 2 }',
  151. data-vv-name='upgMongo',
  152. data-vv-as='MongoDB Connection String',
  153. data-vv-scope='upgrade',
  154. :error-messages='errors.collect(`upgMongo`)'
  155. )
  156. .pt-3.text-xs-center
  157. v-btn(@click='proceedToAdmin', :disabled='loading') Back
  158. v-btn(color='primary', @click='proceedToFinal', :disabled='loading') Continue
  159. //- ==============================================
  160. //- FINAL
  161. //- ==============================================
  162. v-stepper-content(:step='conf.upgrade ? 4 : 3')
  163. v-card.text-xs-center(flat)
  164. template(v-if='loading')
  165. .mt-3(style='width: 64px; display:inline-block;')
  166. atom-spinner(
  167. :animation-duration='800'
  168. :size='64'
  169. color='#1976d2'
  170. )
  171. .subheading.primary--text.mt-3 Finalizing your installation...
  172. template(v-else-if='final.ok')
  173. svg.icons.is-64: use(xlink:href='#nc-check-bold')
  174. .subheading.green--text Installation complete!
  175. template(v-else)
  176. svg.icons.is-64: use(xlink:href='#nc-square-remove')
  177. .subheading.red--text Something went wrong...
  178. v-container
  179. v-alert(type='success', outline, :value='!loading && final.ok') Wiki.js was configured successfully and is now ready for use.
  180. v-alert(type='error', outline, :value='!loading && !final.ok') {{ final.error }}
  181. v-divider
  182. .pt-3.text-xs-center
  183. v-btn(@click='!conf.upgrade ? proceedToAdmin() : proceedToUpgrade()', :disabled='loading') Back
  184. v-btn(color='primary', @click='proceedToFinal', v-if='!loading && !final.ok') Try Again
  185. v-btn(color='success', @click='finish', v-if='loading || final.ok', :disabled='loading') Continue
  186. v-footer.pa-3(app, absolute, color='grey darken-3', height='auto')
  187. .caption.grey--text Wiki.js
  188. v-spacer
  189. .caption.grey--text(v-if='conf.telemetry') Telemetry Client ID: {{telemetryId}}
  190. </template>
  191. <script>
  192. import axios from 'axios'
  193. import _ from 'lodash'
  194. import { AtomSpinner } from 'epic-spinners'
  195. export default {
  196. components: {
  197. AtomSpinner
  198. },
  199. props: {
  200. telemetryId: {
  201. type: String,
  202. required: true
  203. },
  204. wikiVersion: {
  205. type: String,
  206. required: true
  207. }
  208. },
  209. data() {
  210. return {
  211. loading: false,
  212. state: 1,
  213. final: {
  214. ok: false,
  215. error: '',
  216. redirectUrl: ''
  217. },
  218. conf: {
  219. adminEmail: '',
  220. adminPassword: '',
  221. adminPasswordConfirm: '',
  222. telemetry: true,
  223. upgrade: false,
  224. upgMongo: 'mongodb://'
  225. },
  226. pwdMode: true,
  227. pwdConfirmMode: true
  228. }
  229. },
  230. methods: {
  231. proceedToWelcome () {
  232. this.state = 1
  233. this.loading = false
  234. },
  235. async proceedToAdmin () {
  236. if (this.state < 2) {
  237. const validationSuccess = await this.$validator.validateAll('general')
  238. if (!validationSuccess) {
  239. this.state = 1
  240. return
  241. }
  242. }
  243. this.state = 2
  244. this.loading = false
  245. _.delay(() => {
  246. this.$refs.adminEmailInput.focus()
  247. }, 400)
  248. },
  249. async proceedToUpgrade () {
  250. if (this.state < 3) {
  251. const validationSuccess = await this.$validator.validateAll('admin')
  252. if (!validationSuccess || this.conf.adminPassword !== this.conf.adminPasswordConfirm) {
  253. this.state = 2
  254. return
  255. }
  256. }
  257. if (this.conf.upgrade) {
  258. this.state = 3
  259. this.loading = false
  260. } else {
  261. this.proceedToFinal()
  262. }
  263. },
  264. async proceedToFinal () {
  265. if (this.conf.upgrade && this.state < 4) {
  266. const validationSuccess = await this.$validator.validateAll('upgrade')
  267. if (!validationSuccess) {
  268. this.state = 3
  269. return
  270. }
  271. }
  272. this.state = this.conf.upgrade ? 4 : 3
  273. this.loading = true
  274. this.final = {
  275. ok: false,
  276. error: '',
  277. redirectUrl: ''
  278. }
  279. this.$forceUpdate()
  280. let self = this
  281. _.delay(() => {
  282. axios.post('/finalize', self.conf).then(resp => {
  283. if (resp.data.ok === true) {
  284. _.delay(() => {
  285. self.final.ok = true
  286. self.loading = false
  287. }, 5000)
  288. } else {
  289. self.final.ok = false
  290. self.final.error = resp.data.error
  291. self.loading = false
  292. }
  293. self.$nextTick()
  294. }).catch(err => {
  295. window.alert(err.message)
  296. })
  297. }, 1000)
  298. },
  299. finish () {
  300. window.location.assign('/login')
  301. }
  302. }
  303. }
  304. </script>
  305. <style lang='scss'>
  306. </style>