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.

321 lines
12 KiB

5 years ago
5 years ago
  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 {{wikiVersion}}
  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. breeding-rhombus-spinner(
  167. :animation-duration='2000'
  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 {{wikiVersion}} Installation Wizard
  188. </template>
  189. <script>
  190. import axios from 'axios'
  191. import _ from 'lodash'
  192. import { BreedingRhombusSpinner } from 'epic-spinners'
  193. export default {
  194. components: {
  195. BreedingRhombusSpinner
  196. },
  197. props: {
  198. telemetryId: {
  199. type: String,
  200. required: true
  201. },
  202. wikiVersion: {
  203. type: String,
  204. required: true
  205. }
  206. },
  207. data() {
  208. return {
  209. loading: false,
  210. state: 1,
  211. final: {
  212. ok: false,
  213. error: '',
  214. redirectUrl: ''
  215. },
  216. conf: {
  217. adminEmail: '',
  218. adminPassword: '',
  219. adminPasswordConfirm: '',
  220. telemetry: true,
  221. upgrade: false,
  222. upgMongo: 'mongodb://'
  223. },
  224. pwdMode: true,
  225. pwdConfirmMode: true
  226. }
  227. },
  228. methods: {
  229. proceedToWelcome () {
  230. this.state = 1
  231. this.loading = false
  232. },
  233. async proceedToAdmin () {
  234. if (this.state < 2) {
  235. const validationSuccess = await this.$validator.validateAll('general')
  236. if (!validationSuccess) {
  237. this.state = 1
  238. return
  239. }
  240. }
  241. this.state = 2
  242. this.loading = false
  243. _.delay(() => {
  244. this.$refs.adminEmailInput.focus()
  245. }, 400)
  246. },
  247. async proceedToUpgrade () {
  248. if (this.state < 3) {
  249. const validationSuccess = await this.$validator.validateAll('admin')
  250. if (!validationSuccess || this.conf.adminPassword !== this.conf.adminPasswordConfirm) {
  251. this.state = 2
  252. return
  253. }
  254. }
  255. if (this.conf.upgrade) {
  256. this.state = 3
  257. this.loading = false
  258. } else {
  259. this.proceedToFinal()
  260. }
  261. },
  262. async proceedToFinal () {
  263. if (this.conf.upgrade && this.state < 4) {
  264. const validationSuccess = await this.$validator.validateAll('upgrade')
  265. if (!validationSuccess) {
  266. this.state = 3
  267. return
  268. }
  269. }
  270. this.state = this.conf.upgrade ? 4 : 3
  271. this.loading = true
  272. this.final = {
  273. ok: false,
  274. error: '',
  275. redirectUrl: ''
  276. }
  277. this.$forceUpdate()
  278. let self = this
  279. _.delay(() => {
  280. axios.post('/finalize', self.conf).then(resp => {
  281. if (resp.data.ok === true) {
  282. _.delay(() => {
  283. self.final.ok = true
  284. self.loading = false
  285. }, 5000)
  286. } else {
  287. self.final.ok = false
  288. self.final.error = resp.data.error
  289. self.loading = false
  290. }
  291. self.$nextTick()
  292. }).catch(err => {
  293. window.alert(err.message)
  294. })
  295. }, 1000)
  296. },
  297. finish () {
  298. window.location.assign('/login')
  299. }
  300. }
  301. }
  302. </script>
  303. <style lang='scss'>
  304. </style>