setup.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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
  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. v-container
  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
  37. | Detailed information about installation and usage can be found on the #[a(href='https://wiki.requarks.io/docs') official documentation site].
  38. br
  39. | 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].
  40. .body-1.pt-3
  41. v-icon.mr-2 system_update
  42. span You are about to install Wiki.js #[strong {{wikiVersion}}].
  43. v-divider.mt-3
  44. v-form
  45. v-checkbox(
  46. color='primary',
  47. v-model='conf.telemetry',
  48. label='Allow Telemetry',
  49. persistent-hint,
  50. hint='Help Wiki.js developers improve this app with anonymized telemetry.'
  51. )
  52. v-checkbox.mt-3(
  53. color='primary',
  54. v-model='conf.upgrade',
  55. label='Upgrade from Wiki.js 1.x',
  56. persistent-hint,
  57. hint='Check this box if you are upgrading from Wiki.js 1.x and wish to migrate your existing data.'
  58. )
  59. v-divider
  60. .pt-3.text-xs-center
  61. v-btn(color='primary', @click='proceedToAdmin', :disabled='loading') Start
  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. 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. )
  86. v-flex.pr-3(xs6)
  87. v-text-field(
  88. outline
  89. background-color='grey lighten-2'
  90. ref='adminPassword',
  91. counter='255'
  92. v-model='conf.adminPassword',
  93. label='Password',
  94. :append-icon="pwdMode ? 'visibility' : 'visibility_off'"
  95. :append-icon-cb="() => (pwdMode = !pwdMode)"
  96. :type="pwdMode ? 'password' : 'text'"
  97. hint='At least 8 characters long.',
  98. v-validate='{ required: true, min: 8 }',
  99. data-vv-name='adminPassword',
  100. data-vv-as='Password',
  101. data-vv-scope='admin',
  102. :error-messages='errors.collect(`adminPassword`)'
  103. )
  104. v-flex(xs6)
  105. v-text-field(
  106. outline
  107. background-color='grey lighten-2'
  108. ref='adminPasswordConfirm',
  109. counter='255'
  110. v-model='conf.adminPasswordConfirm',
  111. label='Confirm Password',
  112. :append-icon="pwdConfirmMode ? 'visibility' : 'visibility_off'"
  113. :append-icon-cb="() => (pwdConfirmMode = !pwdConfirmMode)"
  114. :type="pwdConfirmMode ? 'password' : 'text'"
  115. hint='Verify your password again.',
  116. v-validate='{ required: true, min: 8 }',
  117. data-vv-name='adminPasswordConfirm',
  118. data-vv-as='Confirm Password',
  119. data-vv-scope='admin',
  120. :error-messages='errors.collect(`adminPasswordConfirm`)'
  121. )
  122. .pt-3.text-xs-center
  123. v-btn(@click='proceedToWelcome', :disabled='loading') Back
  124. v-btn(color='primary', @click='proceedToUpgrade', :disabled='loading') Continue
  125. //- ==============================================
  126. //- UPGRADE FROM 1.x
  127. //- ==============================================
  128. v-stepper-content(step='3', v-if='conf.upgrade')
  129. v-card.text-xs-center(flat)
  130. svg.icons.is-64: use(xlink:href='#nc-spaceship')
  131. .subheading Upgrade from Wiki.js 1.x
  132. .body-2 Migrating from a Wiki.js 1.x installation is quick and simple.
  133. v-form
  134. v-container
  135. v-layout(row)
  136. v-flex(xs12)
  137. v-text-field(
  138. outline
  139. background-color='grey lighten-2'
  140. v-model='conf.upgMongo',
  141. placeholder='mongodb://',
  142. label='Connection String to Wiki.js 1.x MongoDB database',
  143. persistent-hint,
  144. hint='A MongoDB database connection string where a Wiki.js 1.x installation is located. No alterations will be made to this database.',
  145. v-validate='{ required: true, min: 2 }',
  146. data-vv-name='upgMongo',
  147. data-vv-as='MongoDB Connection String',
  148. data-vv-scope='upgrade',
  149. :error-messages='errors.collect(`upgMongo`)'
  150. )
  151. .pt-3.text-xs-center
  152. v-btn(@click='proceedToAdmin', :disabled='loading') Back
  153. v-btn(color='primary', @click='proceedToFinal', :disabled='loading') Continue
  154. //- ==============================================
  155. //- FINAL
  156. //- ==============================================
  157. v-stepper-content(:step='conf.upgrade ? 4 : 3')
  158. v-card.text-xs-center(flat)
  159. template(v-if='loading')
  160. .mt-3(style='width: 64px; display:inline-block;')
  161. atom-spinner(
  162. :animation-duration='800'
  163. :size='64'
  164. color='#1976d2'
  165. )
  166. .subheading.primary--text.mt-3 Finalizing your installation...
  167. template(v-else-if='final.ok')
  168. svg.icons.is-64: use(xlink:href='#nc-check-bold')
  169. .subheading.green--text Installation complete!
  170. template(v-else)
  171. svg.icons.is-64: use(xlink:href='#nc-square-remove')
  172. .subheading.red--text Something went wrong...
  173. v-container
  174. v-alert(type='success', outline, :value='!loading && final.ok') Wiki.js was configured successfully and is now ready for use.
  175. v-alert(type='error', outline, :value='!loading && !final.ok') {{ final.error }}
  176. v-divider
  177. .pt-3.text-xs-center
  178. v-btn(@click='!conf.upgrade ? proceedToAdmin() : proceedToUpgrade()', :disabled='loading') Back
  179. v-btn(color='primary', @click='proceedToFinal', v-if='!loading && !final.ok') Try Again
  180. v-btn(color='success', @click='finish', v-if='loading || final.ok', :disabled='loading') Continue
  181. v-footer.pa-3(app, absolute, color='grey darken-3', height='auto')
  182. .caption.grey--text Wiki.js
  183. v-spacer
  184. .caption.grey--text(v-if='conf.telemetry') Telemetry Client ID: {{telemetryId}}
  185. </template>
  186. <script>
  187. /* global siteConfig */
  188. import axios from 'axios'
  189. import _ from 'lodash'
  190. import { AtomSpinner } from 'epic-spinners'
  191. export default {
  192. components: {
  193. AtomSpinner
  194. },
  195. props: {
  196. telemetryId: {
  197. type: String,
  198. required: true
  199. },
  200. wikiVersion: {
  201. type: String,
  202. required: true
  203. }
  204. },
  205. data() {
  206. return {
  207. loading: false,
  208. state: 1,
  209. final: {
  210. ok: false,
  211. error: '',
  212. redirectUrl: ''
  213. },
  214. conf: {
  215. adminEmail: '',
  216. adminPassword: '',
  217. adminPasswordConfirm: '',
  218. telemetry: true,
  219. upgrade: false,
  220. upgMongo: 'mongodb://'
  221. },
  222. pwdMode: true,
  223. pwdConfirmMode: true
  224. }
  225. },
  226. methods: {
  227. proceedToWelcome () {
  228. this.state = 1
  229. this.loading = false
  230. },
  231. async proceedToAdmin () {
  232. if (this.state < 2) {
  233. const validationSuccess = await this.$validator.validateAll('general')
  234. if (!validationSuccess) {
  235. this.state = 1
  236. return
  237. }
  238. }
  239. this.state = 2
  240. this.loading = false
  241. },
  242. async proceedToUpgrade () {
  243. if (this.state < 3) {
  244. const validationSuccess = await this.$validator.validateAll('admin')
  245. if (!validationSuccess || this.conf.adminPassword !== this.conf.adminPasswordConfirm) {
  246. this.state = 2
  247. return
  248. }
  249. }
  250. if (this.conf.upgrade) {
  251. this.state = 3
  252. this.loading = false
  253. } else {
  254. this.proceedToFinal()
  255. }
  256. },
  257. async proceedToFinal () {
  258. if (this.conf.upgrade && this.state < 4) {
  259. const validationSuccess = await this.$validator.validateAll('upgrade')
  260. if (!validationSuccess) {
  261. this.state = 3
  262. return
  263. }
  264. }
  265. this.state = this.conf.upgrade ? 4 : 3
  266. this.loading = true
  267. this.final = {
  268. ok: false,
  269. error: '',
  270. redirectUrl: ''
  271. }
  272. this.$forceUpdate()
  273. let self = this
  274. _.delay(() => {
  275. axios.post('/finalize', self.conf).then(resp => {
  276. if (resp.data.ok === true) {
  277. _.delay(() => {
  278. self.final.ok = true
  279. switch (resp.data.redirectPort) {
  280. case 80:
  281. self.final.redirectUrl = `http://${window.location.hostname}${resp.data.redirectPath}/login`
  282. break
  283. case 443:
  284. self.final.redirectUrl = `https://${window.location.hostname}${resp.data.redirectPath}/login`
  285. break
  286. default:
  287. self.final.redirectUrl = `http://${window.location.hostname}:${resp.data.redirectPort}${resp.data.redirectPath}/login`
  288. break
  289. }
  290. self.loading = false
  291. }, 5000)
  292. } else {
  293. self.final.ok = false
  294. self.final.error = resp.data.error
  295. self.loading = false
  296. }
  297. self.$nextTick()
  298. }).catch(err => {
  299. window.alert(err.message)
  300. })
  301. }, 1000)
  302. },
  303. finish () {
  304. window.location.assign(this.final.redirectUrl)
  305. }
  306. }
  307. }
  308. </script>
  309. <style lang='scss'>
  310. </style>