setup.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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. | System Check
  18. small Checking your system for compatibility
  19. v-divider
  20. v-stepper-step(step='3' :complete='state > 3')
  21. | General Information
  22. small Site Title, Language and Access
  23. v-divider
  24. v-stepper-step(step='4' :complete='state > 4')
  25. | Administration Account
  26. small Create the admin account
  27. v-divider(v-if='this.conf.upgrade')
  28. v-stepper-step(step='5' :complete='state > 5', v-if='this.conf.upgrade')
  29. | Upgrade from Wiki.js 1.x
  30. small Migrate your existing installation
  31. v-divider
  32. v-stepper-step(:step='this.conf.upgrade ? 6 : 5' :complete='this.conf.upgrade ? state > 5 : state > 6')
  33. | Final Steps
  34. small Finalizing your installation
  35. v-stepper-items
  36. //- ==============================================
  37. //- WELCOME
  38. //- ==============================================
  39. v-stepper-content(step='1')
  40. v-card.text-xs-center.pa-3(flat)
  41. img(src='svg/logo-wikijs.svg', alt='Wiki.js Logo', style='width: 300px;')
  42. v-container
  43. .body-2.py-2 This installation wizard will guide you through the steps needed to get your wiki up and running in no time!
  44. .body-1
  45. | Detailed information about installation and usage can be found on the #[a(href='https://wiki.requarks.io/docs') official documentation site].
  46. br
  47. | 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].
  48. .body-1.pt-3
  49. svg.icons.is-18.is-outlined.has-right-pad.is-text: use(xlink:href='#nc-cd-reader')
  50. span You are about to install Wiki.js #[strong {{wikiVersion}}].
  51. v-divider
  52. v-form
  53. v-checkbox(
  54. color='primary',
  55. v-model='conf.telemetry',
  56. label='Allow Telemetry',
  57. persistent-hint,
  58. hint='Help Wiki.js developers improve this app with anonymized telemetry.'
  59. )
  60. v-checkbox.mt-3(
  61. color='primary',
  62. v-model='conf.upgrade',
  63. label='Upgrade from Wiki.js 1.x',
  64. persistent-hint,
  65. hint='Check this box if you are upgrading from Wiki.js 1.x and wish to migrate your existing data.'
  66. )
  67. v-divider
  68. .text-xs-center
  69. v-btn(color='primary', @click='proceedToSyscheck', :disabled='loading') Start
  70. //- ==============================================
  71. //- SYSTEM CHECK
  72. //- ==============================================
  73. v-stepper-content(step='2')
  74. v-card.text-xs-center(flat)
  75. svg.icons.is-64: use(xlink:href='#nc-metrics')
  76. .subheading System Check
  77. v-container
  78. v-layout(row, align-center, v-if='loading')
  79. v-progress-circular(v-if='loading', indeterminate, color='blue')
  80. .body-2.blue--text.ml-3 Checking your system for compatibility...
  81. v-alert(type='success', outline, :value='!loading && syscheck.ok') Looks good! No issues so far.
  82. v-alert(type='error', outline, :value='!loading && !syscheck.ok') {{ syscheck.error }}
  83. v-list.mt-3(two-line, v-if='!loading && syscheck.ok', dense)
  84. template(v-for='(rs, n) in syscheck.results')
  85. v-divider(v-if='n > 0', inset)
  86. v-list-tile
  87. v-list-tile-avatar(color='green lighten-5')
  88. v-icon(color='green') check
  89. v-list-tile-content
  90. v-list-tile-title {{rs.title}}
  91. v-list-tile-sub-title {{rs.subtitle}}
  92. v-divider
  93. .text-xs-center
  94. v-btn(@click='proceedToWelcome', :disabled='loading') Back
  95. v-btn(color='primary', @click='proceedToSyscheck', v-if='!loading && !syscheck.ok') Check Again
  96. v-btn(color='red', dark, @click='proceedToGeneral', v-if='!loading && !syscheck.ok') Continue Anyway
  97. v-btn(color='primary', @click='proceedToGeneral', v-if='loading || syscheck.ok', :disabled='loading') Continue
  98. //- ==============================================
  99. //- GENERAL
  100. //- ==============================================
  101. v-stepper-content(step='3')
  102. v-card.text-xs-center(flat)
  103. svg.icons.is-64: use(xlink:href='#nc-webpage')
  104. .subheading General Information
  105. v-form
  106. v-container
  107. v-layout(row, wrap)
  108. v-flex(xs12)
  109. v-text-field(
  110. v-model='conf.title',
  111. label='Site Title',
  112. :counter='255',
  113. persistent-hint,
  114. hint='The site title will appear in the top left corner on every page and within the window title bar.',
  115. v-validate='{ required: true, min: 2 }',
  116. data-vv-name='siteTitle',
  117. data-vv-as='Site Title',
  118. data-vv-scope='general',
  119. :error-messages='errors.collect(`siteTitle`)'
  120. )
  121. v-layout(row, wrap).mt-3
  122. v-flex.pr-3(xs12, sm4)
  123. v-select(
  124. v-model='conf.lang',
  125. :items='langs',
  126. label='Site UI Language',
  127. item-value='id',
  128. item-text='name',
  129. persistent-hint,
  130. hint='The language in which navigation, help and other UI elements will be displayed.'
  131. )
  132. template(slot='item', slot-scope='data')
  133. v-list-tile-avatar
  134. v-avatar.blue.white--text(tile, size='40', v-html='data.item.id.toUpperCase()')
  135. v-list-tile-content
  136. v-list-tile-title(v-html='data.item.name')
  137. v-list-tile-sub-title(v-html='data.item.original')
  138. v-flex(xs12, sm8)
  139. v-text-field(
  140. v-model='conf.pathContent',
  141. label='Content Data Path',
  142. persistent-hint,
  143. hint='The path where content is stored (markdown files, uploads, etc.)',
  144. v-validate='{ required: true, min: 2 }',
  145. data-vv-name='pathContent',
  146. data-vv-as='Content Data Path',
  147. data-vv-scope='general',
  148. :error-messages='errors.collect(`pathContent`)'
  149. )
  150. v-layout(row, wrap).mt-3
  151. v-flex.pr-3(xs12, sm4)
  152. v-text-field(
  153. v-model='conf.port',
  154. label='Server Port',
  155. persistent-hint,
  156. hint='The port on which Wiki.js will listen to. Usually port 80 if connecting directly, or a random port (e.g. 3000) if using a web server in front of it. Set $(PORT) to use the PORT environment variable.',
  157. v-validate='{ required: true }',
  158. data-vv-name='port',
  159. data-vv-as='Port',
  160. data-vv-scope='general',
  161. :error-messages='errors.collect(`port`)'
  162. )
  163. v-flex(xs12, sm8)
  164. v-text-field(
  165. v-model='conf.pathData',
  166. label='Temporary Data Path',
  167. persistent-hint,
  168. hint='The path where temporary data is stored (cache, thumbnails, temporary upload files, etc.)',
  169. v-validate='{ required: true, min: 2 }',
  170. data-vv-name='pathData',
  171. data-vv-as='Temporary Data Path',
  172. data-vv-scope='general',
  173. :error-messages='errors.collect(`pathData`)'
  174. )
  175. v-layout(row, wrap).mt-3
  176. v-flex(xs12)
  177. v-checkbox(
  178. color='primary',
  179. v-model='conf.public',
  180. label='Public Access',
  181. persistent-hint,
  182. hint='Should the site be accessible (read only) without login.'
  183. )
  184. v-checkbox.mt-2(
  185. color='primary',
  186. v-model='conf.selfRegister',
  187. label='Allow Self-Registration',
  188. persistent-hint,
  189. hint='Can users create their own account to gain access?'
  190. )
  191. v-divider
  192. .text-xs-center
  193. v-btn(@click='proceedToSyscheck', :disabled='loading') Back
  194. v-btn(color='primary', @click='proceedToAdmin', :disabled='loading') Continue
  195. //- ==============================================
  196. //- ADMINISTRATOR ACCOUNT
  197. //- ==============================================
  198. v-stepper-content(step='4')
  199. v-card.text-xs-center(flat)
  200. svg.icons.is-64: use(xlink:href='#nc-man-black')
  201. .subheading Administrator Account
  202. .body-2 A root administrator account will be created for local authentication. From this account, you can create or authorize more users.
  203. v-form
  204. v-container
  205. v-layout(row, wrap)
  206. v-flex(xs12)
  207. v-text-field(
  208. autofocus
  209. v-model='conf.adminEmail',
  210. label='Administrator Email',
  211. hint='The email address of the administrator account',
  212. v-validate='{ required: true, email: true }',
  213. data-vv-name='adminEmail',
  214. data-vv-as='Administrator Email',
  215. data-vv-scope='admin',
  216. :error-messages='errors.collect(`adminEmail`)'
  217. )
  218. v-flex.pr-3(xs6)
  219. v-text-field(
  220. ref='adminPassword',
  221. v-model='conf.adminPassword',
  222. label='Password',
  223. hint='At least 8 characters long.',
  224. v-validate='{ required: true, min: 8 }',
  225. data-vv-name='adminPassword',
  226. data-vv-as='Password',
  227. data-vv-scope='admin',
  228. :error-messages='errors.collect(`adminPassword`)'
  229. )
  230. v-flex(xs6)
  231. v-text-field(
  232. v-model='conf.adminPasswordConfirm',
  233. label='Confirm Password',
  234. hint='Verify your password again.',
  235. v-validate='{ required: true, confirmed: `$adminPassword` }',
  236. data-vv-name='adminPasswordConfirm',
  237. data-vv-as='Confirm Password',
  238. data-vv-scope='admin',
  239. :error-messages='errors.collect(`adminPasswordConfirm`)'
  240. )
  241. .text-xs-center
  242. v-btn(@click='proceedToGeneral', :disabled='loading') Back
  243. v-btn(color='primary', @click='proceedToUpgrade', :disabled='loading') Continue
  244. //- ==============================================
  245. //- UPGRADE FROM 1.x
  246. //- ==============================================
  247. v-stepper-content(step='5', v-if='conf.upgrade')
  248. v-card.text-xs-center(flat)
  249. svg.icons.is-64: use(xlink:href='#nc-spaceship')
  250. .subheading Upgrade from Wiki.js 1.x
  251. .body-2 Migrating from a Wiki.js 1.x installation is quick and simple.
  252. v-form
  253. v-container
  254. v-layout(row)
  255. v-flex(xs12)
  256. v-text-field(
  257. v-model='conf.upgMongo',
  258. placeholder='mongodb://',
  259. label='Connection String to Wiki.js 1.x MongoDB database',
  260. persistent-hint,
  261. hint='A MongoDB database connection string where a Wiki.js 1.x installation is located. No alterations will be made to this database.',
  262. v-validate='{ required: true, min: 2 }',
  263. data-vv-name='upgMongo',
  264. data-vv-as='MongoDB Connection String',
  265. data-vv-scope='upgrade',
  266. :error-messages='errors.collect(`upgMongo`)'
  267. )
  268. .text-xs-center
  269. v-btn(@click='proceedToAdmin', :disabled='loading') Back
  270. v-btn(color='primary', @click='proceedToFinal', :disabled='loading') Continue
  271. //- ==============================================
  272. //- FINAL
  273. //- ==============================================
  274. v-stepper-content(:step='conf.upgrade ? 6 : 5')
  275. v-card.text-xs-center(flat)
  276. template(v-if='loading')
  277. v-progress-circular(size='64', indeterminate, color='blue')
  278. .subheading Finalizing your installation...
  279. template(v-else-if='final.ok')
  280. svg.icons.is-64: use(xlink:href='#nc-check-bold')
  281. .subheading Installation complete!
  282. template(v-else)
  283. svg.icons.is-64: use(xlink:href='#nc-square-remove')
  284. .subheading Something went wrong...
  285. v-container
  286. v-alert(type='success', outline, :value='!loading && final.ok') Wiki.js was configured successfully and is now ready for use.
  287. v-alert(type='error', outline, :value='!loading && !final.ok') {{ final.error }}
  288. v-divider
  289. .text-xs-center
  290. v-btn(@click='!conf.upgrade ? proceedToAdmin() : proceedToUpgrade()', :disabled='loading') Back
  291. v-btn(color='primary', @click='proceedToFinal', v-if='!loading && !final.ok') Try Again
  292. v-btn(color='success', @click='finish', v-if='loading || final.ok', :disabled='loading') Continue
  293. v-footer.pa-3(app, absolute, color='grey darken-3', height='auto')
  294. .caption.grey--text Wiki.js
  295. v-spacer
  296. .caption.grey--text(v-if='conf.telemetry') Telemetry Client ID: {{telemetryId}}
  297. </template>
  298. <script>
  299. /* global siteConfig */
  300. import axios from 'axios'
  301. import _ from 'lodash'
  302. export default {
  303. props: {
  304. telemetryId: {
  305. type: String,
  306. required: true
  307. },
  308. wikiVersion: {
  309. type: String,
  310. required: true
  311. },
  312. langs: {
  313. type: Array,
  314. required: true
  315. }
  316. },
  317. data() {
  318. return {
  319. loading: false,
  320. state: 1,
  321. syscheck: {
  322. ok: false,
  323. error: '',
  324. results: []
  325. },
  326. final: {
  327. ok: false,
  328. error: '',
  329. redirectUrl: ''
  330. },
  331. conf: {
  332. adminEmail: '',
  333. adminPassword: '',
  334. adminPasswordConfirm: '',
  335. lang: siteConfig.lang || 'en',
  336. pathData: './data',
  337. pathContent: './content',
  338. port: siteConfig.port || 80,
  339. public: (siteConfig.public === true),
  340. selfRegister: (siteConfig.selfRegister === true),
  341. telemetry: true,
  342. title: siteConfig.title || 'Wiki',
  343. upgrade: false,
  344. upgMongo: 'mongodb://'
  345. }
  346. }
  347. },
  348. methods: {
  349. proceedToWelcome () {
  350. this.state = 1
  351. this.loading = false
  352. },
  353. proceedToSyscheck () {
  354. let self = this
  355. this.state = 2
  356. this.loading = true
  357. this.syscheck = {
  358. ok: false,
  359. error: '',
  360. results: []
  361. }
  362. _.delay(() => {
  363. axios.post('/syscheck', self.conf).then(resp => {
  364. if (resp.data.ok === true) {
  365. self.syscheck.ok = true
  366. self.syscheck.results = resp.data.results
  367. } else {
  368. self.syscheck.ok = false
  369. self.syscheck.error = resp.data.error
  370. }
  371. self.loading = false
  372. self.$nextTick()
  373. }).catch(err => {
  374. window.alert(err.message)
  375. })
  376. }, 1000)
  377. },
  378. proceedToGeneral () {
  379. this.state = 3
  380. this.loading = false
  381. },
  382. async proceedToAdmin () {
  383. if (this.state < 4) {
  384. const validationSuccess = await this.$validator.validateAll('general')
  385. if (!validationSuccess) {
  386. this.state = 3
  387. return
  388. }
  389. }
  390. this.state = 4
  391. this.loading = false
  392. },
  393. async proceedToUpgrade () {
  394. if (this.state < 5) {
  395. const validationSuccess = await this.$validator.validateAll('admin')
  396. if (!validationSuccess) {
  397. this.state = 4
  398. return
  399. }
  400. }
  401. if (this.conf.upgrade) {
  402. this.state = 5
  403. this.loading = false
  404. } else {
  405. this.proceedToFinal()
  406. }
  407. },
  408. async proceedToFinal () {
  409. if (this.conf.upgrade && this.state < 6) {
  410. const validationSuccess = await this.$validator.validateAll('upgrade')
  411. if (!validationSuccess) {
  412. this.state = 5
  413. return
  414. }
  415. }
  416. this.state = this.conf.upgrade ? 6 : 5
  417. this.loading = true
  418. this.final = {
  419. ok: false,
  420. error: '',
  421. redirectUrl: ''
  422. }
  423. this.$forceUpdate()
  424. let self = this
  425. _.delay(() => {
  426. axios.post('/finalize', self.conf).then(resp => {
  427. if (resp.data.ok === true) {
  428. _.delay(() => {
  429. self.final.ok = true
  430. switch (resp.data.redirectPort) {
  431. case 80:
  432. self.final.redirectUrl = `http://${window.location.hostname}${resp.data.redirectPath}/login`
  433. break
  434. case 443:
  435. self.final.redirectUrl = `https://${window.location.hostname}${resp.data.redirectPath}/login`
  436. break
  437. default:
  438. self.final.redirectUrl = `http://${window.location.hostname}:${resp.data.redirectPort}${resp.data.redirectPath}/login`
  439. break
  440. }
  441. self.loading = false
  442. }, 5000)
  443. } else {
  444. self.final.ok = false
  445. self.final.error = resp.data.error
  446. self.loading = false
  447. }
  448. self.$nextTick()
  449. }).catch(err => {
  450. window.alert(err.message)
  451. })
  452. }, 1000)
  453. },
  454. finish () {
  455. window.location.assign(this.final.redirectUrl)
  456. }
  457. }
  458. }
  459. </script>
  460. <style lang='scss'>
  461. </style>