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.

322 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. persistent-hint,
  59. hint='Check this box if you are upgrading from Wiki.js 1.x and wish to migrate your existing data.'
  60. )
  61. //- ==============================================
  62. //- ADMINISTRATOR ACCOUNT
  63. //- ==============================================
  64. v-stepper-content(step='2')
  65. v-card.text-xs-center(flat)
  66. svg.icons.is-64: use(xlink:href='#nc-man-black')
  67. .subheading Administrator Account
  68. .body-2 A root administrator account will be created for local authentication. From this account, you can create or authorize more users.
  69. v-form
  70. v-container
  71. v-layout(row, wrap)
  72. v-flex(xs12)
  73. v-text-field(
  74. outline
  75. background-color='grey lighten-2'
  76. v-model='conf.adminEmail',
  77. label='Administrator Email',
  78. hint='The email address of the administrator account',
  79. persistent-hint
  80. v-validate='{ required: true, email: true }',
  81. data-vv-name='adminEmail',
  82. data-vv-as='Administrator Email',
  83. data-vv-scope='admin',
  84. :error-messages='errors.collect(`adminEmail`)'
  85. ref='adminEmailInput'
  86. )
  87. v-flex.pr-3(xs6)
  88. v-text-field(
  89. outline
  90. background-color='grey lighten-2'
  91. ref='adminPassword',
  92. counter='255'
  93. v-model='conf.adminPassword',
  94. label='Password',
  95. :append-icon="pwdMode ? 'visibility' : 'visibility_off'"
  96. @click:append="() => (pwdMode = !pwdMode)"
  97. :type="pwdMode ? 'password' : 'text'"
  98. hint='At least 8 characters long.',
  99. persistent-hint
  100. v-validate='{ required: true, min: 8 }',
  101. data-vv-name='adminPassword',
  102. data-vv-as='Password',
  103. data-vv-scope='admin',
  104. :error-messages='errors.collect(`adminPassword`)'
  105. )
  106. v-flex(xs6)
  107. v-text-field(
  108. outline
  109. background-color='grey lighten-2'
  110. ref='adminPasswordConfirm',
  111. counter='255'
  112. v-model='conf.adminPasswordConfirm',
  113. label='Confirm Password',
  114. :append-icon="pwdConfirmMode ? 'visibility' : 'visibility_off'"
  115. @click:append="() => (pwdConfirmMode = !pwdConfirmMode)"
  116. :type="pwdConfirmMode ? 'password' : 'text'"
  117. hint='Verify your password again.',
  118. persistent-hint
  119. v-validate='{ required: true, min: 8 }',
  120. data-vv-name='adminPasswordConfirm',
  121. data-vv-as='Confirm Password',
  122. data-vv-scope='admin',
  123. :error-messages='errors.collect(`adminPasswordConfirm`)'
  124. @keyup.enter='proceedToUpgrade'
  125. )
  126. .pt-3.text-xs-center
  127. v-btn(@click='proceedToWelcome', :disabled='loading') Back
  128. v-btn(color='primary', @click='proceedToUpgrade', :disabled='loading') Continue
  129. //- ==============================================
  130. //- UPGRADE FROM 1.x
  131. //- ==============================================
  132. v-stepper-content(step='3', v-if='conf.upgrade')
  133. v-card.text-xs-center(flat)
  134. svg.icons.is-64: use(xlink:href='#nc-spaceship')
  135. .subheading Upgrade from Wiki.js 1.x
  136. .body-2 Migrating from a Wiki.js 1.x installation is quick and simple.
  137. v-form
  138. v-container
  139. v-layout(row)
  140. v-flex(xs12)
  141. v-text-field(
  142. outline
  143. background-color='grey lighten-2'
  144. v-model='conf.upgMongo',
  145. placeholder='mongodb://',
  146. label='Connection String to Wiki.js 1.x MongoDB database',
  147. persistent-hint,
  148. hint='A MongoDB database connection string where a Wiki.js 1.x installation is located. No alterations will be made to this database.',
  149. v-validate='{ required: true, min: 2 }',
  150. data-vv-name='upgMongo',
  151. data-vv-as='MongoDB Connection String',
  152. data-vv-scope='upgrade',
  153. :error-messages='errors.collect(`upgMongo`)'
  154. )
  155. .pt-3.text-xs-center
  156. v-btn(@click='proceedToAdmin', :disabled='loading') Back
  157. v-btn(color='primary', @click='proceedToFinal', :disabled='loading') Continue
  158. //- ==============================================
  159. //- FINAL
  160. //- ==============================================
  161. v-stepper-content(:step='conf.upgrade ? 4 : 3')
  162. v-card.text-xs-center(flat)
  163. template(v-if='loading')
  164. .mt-3(style='width: 64px; display:inline-block;')
  165. atom-spinner(
  166. :animation-duration='800'
  167. :size='64'
  168. color='#1976d2'
  169. )
  170. .subheading.primary--text.mt-3 Finalizing your installation...
  171. template(v-else-if='final.ok')
  172. svg.icons.is-64: use(xlink:href='#nc-check-bold')
  173. .subheading.green--text Installation complete!
  174. template(v-else)
  175. svg.icons.is-64: use(xlink:href='#nc-square-remove')
  176. .subheading.red--text Something went wrong...
  177. v-container
  178. v-alert(type='success', outline, :value='!loading && final.ok') Wiki.js was configured successfully and is now ready for use.
  179. v-alert(type='error', outline, :value='!loading && !final.ok') {{ final.error }}
  180. v-divider
  181. .pt-3.text-xs-center
  182. v-btn(@click='!conf.upgrade ? proceedToAdmin() : proceedToUpgrade()', :disabled='loading') Back
  183. v-btn(color='primary', @click='proceedToFinal', v-if='!loading && !final.ok') Try Again
  184. v-btn(color='success', @click='finish', v-if='loading || final.ok', :disabled='loading') Continue
  185. v-footer.pa-3(app, absolute, color='grey darken-3', height='auto')
  186. .caption.grey--text Wiki.js
  187. v-spacer
  188. .caption.grey--text(v-if='conf.telemetry') Telemetry Client ID: {{telemetryId}}
  189. </template>
  190. <script>
  191. import axios from 'axios'
  192. import _ from 'lodash'
  193. import { AtomSpinner } from 'epic-spinners'
  194. export default {
  195. components: {
  196. AtomSpinner
  197. },
  198. props: {
  199. telemetryId: {
  200. type: String,
  201. required: true
  202. },
  203. wikiVersion: {
  204. type: String,
  205. required: true
  206. }
  207. },
  208. data() {
  209. return {
  210. loading: false,
  211. state: 1,
  212. final: {
  213. ok: false,
  214. error: '',
  215. redirectUrl: ''
  216. },
  217. conf: {
  218. adminEmail: '',
  219. adminPassword: '',
  220. adminPasswordConfirm: '',
  221. telemetry: true,
  222. upgrade: false,
  223. upgMongo: 'mongodb://'
  224. },
  225. pwdMode: true,
  226. pwdConfirmMode: true
  227. }
  228. },
  229. methods: {
  230. proceedToWelcome () {
  231. this.state = 1
  232. this.loading = false
  233. },
  234. async proceedToAdmin () {
  235. if (this.state < 2) {
  236. const validationSuccess = await this.$validator.validateAll('general')
  237. if (!validationSuccess) {
  238. this.state = 1
  239. return
  240. }
  241. }
  242. this.state = 2
  243. this.loading = false
  244. _.delay(() => {
  245. this.$refs.adminEmailInput.focus()
  246. }, 400)
  247. },
  248. async proceedToUpgrade () {
  249. if (this.state < 3) {
  250. const validationSuccess = await this.$validator.validateAll('admin')
  251. if (!validationSuccess || this.conf.adminPassword !== this.conf.adminPasswordConfirm) {
  252. this.state = 2
  253. return
  254. }
  255. }
  256. if (this.conf.upgrade) {
  257. this.state = 3
  258. this.loading = false
  259. } else {
  260. this.proceedToFinal()
  261. }
  262. },
  263. async proceedToFinal () {
  264. if (this.conf.upgrade && this.state < 4) {
  265. const validationSuccess = await this.$validator.validateAll('upgrade')
  266. if (!validationSuccess) {
  267. this.state = 3
  268. return
  269. }
  270. }
  271. this.state = this.conf.upgrade ? 4 : 3
  272. this.loading = true
  273. this.final = {
  274. ok: false,
  275. error: '',
  276. redirectUrl: ''
  277. }
  278. this.$forceUpdate()
  279. let self = this
  280. _.delay(() => {
  281. axios.post('/finalize', self.conf).then(resp => {
  282. if (resp.data.ok === true) {
  283. _.delay(() => {
  284. self.final.ok = true
  285. self.loading = false
  286. }, 5000)
  287. } else {
  288. self.final.ok = false
  289. self.final.error = resp.data.error
  290. self.loading = false
  291. }
  292. self.$nextTick()
  293. }).catch(err => {
  294. window.alert(err.message)
  295. })
  296. }, 1000)
  297. },
  298. finish () {
  299. window.location.assign('/login')
  300. }
  301. }
  302. }
  303. </script>
  304. <style lang='scss'>
  305. </style>