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.

626 lines
29 KiB

  1. <template lang="pug">
  2. div
  3. .container
  4. .content(v-cloak)
  5. //- ==============================================
  6. //- WELCOME
  7. //- ==============================================
  8. template(v-if='state === "welcome"')
  9. .panel
  10. h2.panel-title.is-featured
  11. span Welcome!
  12. i(v-if='loading')
  13. .panel-content.is-text
  14. .welcome
  15. img(src='svg/logo-wikijs.svg', alt='Wiki.js Logo')
  16. h2 A modern, lightweight and powerful wiki app built on NodeJS, Git and Markdown
  17. p This installation wizard will guide you through the steps needed to get your wiki up and running in no time!
  18. p Detailed information about installation and usage can be found on the #[a(href='https://wiki.requarks.io/docs') official documentation site]. #[br] 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].
  19. .panel-content.form-sections
  20. section
  21. p
  22. svg.icons.is-18.is-outlined.has-right-pad.is-text: use(xlink:href='#nc-cd-reader')
  23. span You are about to install Wiki.js #[strong {{wikiVersion}}].
  24. section
  25. p.control.is-fullwidth
  26. input#ipt-telemetry(type='checkbox', v-model='conf.telemetry', name='ipt-telemetry')
  27. label.label(for='ipt-telemetry') Allow Telemetry
  28. span.desc Help Wiki.js developers improve this app with anonymized #[a(href='https://wiki.requarks.io/docs/telemetry') telemetry].
  29. p.control.is-fullwidth
  30. input#ipt-upgrade(type='checkbox', v-model='conf.upgrade', name='ipt-upgrade')
  31. label.label(for='ipt-upgrade') Upgrade from Wiki.js 1.x
  32. span.desc Check this box if you are upgrading from Wiki.js 1.x and wish to migrate your existing data.
  33. .panel-footer
  34. .progress-bar: div(v-bind:style='{width: currentProgress}')
  35. button.button.is-small.is-light-blue(v-on:click='proceedToSyscheck', v-bind:disabled='loading') Start
  36. //- ==============================================
  37. //- SYSTEM CHECK
  38. //- ==============================================
  39. template(v-else-if='state === "syscheck"')
  40. .panel
  41. h2.panel-title.is-featured
  42. span Wiki.js
  43. i(v-if='loading')
  44. .panel-content.is-text
  45. .is-logo
  46. svg.icons.is-64: use(xlink:href='#nc-metrics')
  47. h4 System Check
  48. p(v-if='loading') #[svg.icons.is-24.is-text: use(xlink:href='#wk-msdots')] Checking your system for compatibility...
  49. p(v-if='!loading && syscheck.ok')
  50. ul
  51. li(v-for='rs in syscheck.results') #[svg.icons.is-18.is-text: use(xlink:href='#nc-check-bold')] {{rs}}
  52. p(v-if='!loading && syscheck.ok')
  53. svg.icons.is-18.is-text: use(xlink:href='#nc-check-bold')
  54. strong Looks good! No issues so far.
  55. p(v-if='!loading && !syscheck.ok') #[svg.icons.is-18.is-text: use(xlink:href='#nc-square-remove-12')] Error: {{ syscheck.error }}
  56. .panel-footer
  57. .progress-bar: div(v-bind:style='{width: currentProgress}')
  58. button.button.is-small.is-light-blue.is-outlined(v-on:click='proceedToWelcome', v-bind:disabled='loading') Back
  59. button.button.is-small.is-teal(v-on:click='proceedToSyscheck', v-if='!loading && !syscheck.ok') Check Again
  60. button.button.is-small.is-red.is-outlined(v-on:click='proceedToGeneral', v-if='!loading && !syscheck.ok') Continue Anyway
  61. button.button.is-small.is-light-blue(v-on:click='proceedToGeneral', v-if='loading || syscheck.ok', v-bind:disabled='loading') Continue
  62. //- ==============================================
  63. //- GENERAL
  64. //- ==============================================
  65. template(v-else-if='state === "general"')
  66. .panel
  67. h2.panel-title.is-featured
  68. span Wiki.js
  69. i(v-if='loading')
  70. .panel-content.form-sections
  71. section
  72. .is-logo
  73. svg.icons.is-64: use(xlink:href='#nc-webpage')
  74. h4 General Information
  75. p.control.is-fullwidth
  76. label.label Site Title
  77. input(type='text', placeholder='e.g. Wiki', v-model='conf.title', data-vv-scope='general', name='ipt-title', v-validate='{ required: true, min: 2 }')
  78. span.desc The site title will appear in the top left corner on every page and within the window title bar.
  79. section.columns
  80. .column.is-half
  81. p.control
  82. label.label Site UI Language
  83. select(v-model='conf.lang')
  84. option(:value='lg.id', v-for='lg in langs') {{lg.name}}
  85. span.desc The language in which navigation, help and other UI elements will be displayed.
  86. .column.is-half
  87. p.control.is-fullwidth
  88. label.label Site Relative URL Path
  89. input(type='text', placeholder='/', v-model='conf.path', data-vv-scope='general', name='ipt-path', v-validate='{ required: true, min: 1 }')
  90. span.desc The relative path to your wiki. Unless you configure a reverse proxy in front of Wiki.js to handle requests made to a sub-directory, #[strong it is recommended to leave the default value].
  91. section.columns
  92. .column.is-half
  93. p.control
  94. label.label Server Port
  95. input(type='text', placeholder='e.g. 80', v-model.number='conf.port', data-vv-scope='general', name='ipt-port', v-validate='{ required: true }')
  96. span.desc 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 #[strong $(PORT)] to use the PORT environment variable.
  97. .column.is-half
  98. p.control.is-fullwidth
  99. input#ipt-public(type='checkbox', v-model='conf.public', data-vv-scope='general', name='ipt-public')
  100. label.label(for='ipt-public') Public Access
  101. span.desc Should the site be accessible (read only) without login.
  102. p.control.is-fullwidth
  103. input#ipt-selfregister(type='checkbox', v-model='conf.selfRegister', data-vv-scope='general', name='ipt-selfregister')
  104. label.label(for='ipt-selfregister') Allow Self-Registration
  105. span.desc Can users create their own account to gain access?
  106. section
  107. p.control.is-fullwidth
  108. label.label Local Server Repository Path
  109. input(type='text', placeholder='e.g. ./repo', v-model='conf.pathRepo', data-vv-scope='general', name='ipt-repopath', v-validate='{ required: true, min: 2 }')
  110. span.desc The path where the local git repository will be created, used to store content in markdown files and uploads.#[br] #[strong It is recommended to leave the default value].
  111. .panel-footer
  112. .progress-bar: div(v-bind:style='{width: currentProgress}')
  113. button.button.is-small.is-light-blue.is-outlined(v-on:click='proceedToSyscheck', v-bind:disabled='loading') Back
  114. button.button.is-small.is-light-blue(v-on:click='proceedToConsiderations', v-bind:disabled='loading || errors.any("general")') Continue
  115. //- ==============================================
  116. //- CONSIDERATIONS
  117. //- ==============================================
  118. template(v-else-if='state === "considerations"')
  119. .panel
  120. h2.panel-title.is-featured
  121. span Wiki.js
  122. i(v-if='loading')
  123. .panel-content.is-text
  124. .is-logo
  125. svg.icons.is-64: use(xlink:href='#nc-radar')
  126. h4 Important Considerations
  127. h3 Is Wiki.js going to be behind a web server (e.g. nginx / apache / IIS) or proxy?
  128. p
  129. ul
  130. li - Make sure the upload limit is sufficient. Most web servers have a low limit (e.g. 2 MB) by default.
  131. li - Do not rewrite URLs after the domain. This can cause unexpected issues in Wiki.js navigation.
  132. li - Do not remove or alter the client IP when proxying the requests. This can cause the authentication brute force protection to engage unexpectedly.
  133. template(v-if='considerations.https')
  134. h3 The site will not be using HTTPS? #[svg.icons.is-20.is-outlined.animated.fadeOut.infinite: use(xlink:href='#nc-alert')]
  135. p The host URL you specified is not HTTPS. It is highly recommended to use HTTPS. You must use a web server / proxy (e.g. nginx / apache / IIS) in front of Wiki.js to use HTTPS. Wiki.js does not provide HTTPS handling by itself.
  136. template(v-if='considerations.port')
  137. h3 You are using a non-standard port.
  138. p If you are not planning on using a web server / proxy in front of Wiki.js, be aware that users will need to specify the port when accessing the wiki. Make sure this is the intended behavior. Otherwise set a standard HTTP port such as 80.
  139. .panel-footer
  140. .progress-bar: div(v-bind:style='{width: currentProgress}')
  141. button.button.is-small.is-light-blue.is-outlined(v-on:click='proceedToGeneral', v-bind:disabled='loading') Back
  142. button.button.is-small.is-light-blue(v-on:click='proceedToGit', v-bind:disabled='loading') Continue
  143. //- ==============================================
  144. //- GIT
  145. //- ==============================================
  146. template(v-else-if='state === "git"')
  147. .panel
  148. h2.panel-title.is-featured
  149. span Wiki.js
  150. i(v-if='loading')
  151. .panel-content.is-text
  152. .is-logo
  153. img(src='svg/logo-git.svg', alt='Git Logo')
  154. h4 Git Repository
  155. p Wiki.js stores article content and uploads locally on disk. All content is then regularly kept in sync with a remote git repository. This acts a backup protection and provides history / revert features. While optional, it is <strong>HIGHLY</strong> recommended to setup the remote git repository connection.
  156. .panel-content.form-sections
  157. section.columns
  158. .column.is-two-thirds
  159. p.control.is-fullwidth
  160. label.label Repository URL
  161. input(type='text', placeholder='e.g. git@github.com/org/repo.git or https://github.com/org/repo', v-model='conf.gitUrl', data-vv-scope='git', name='ipt-giturl', v-validate='{ required: true, min: 5 }')
  162. span.desc The full git repository URL to connect to.
  163. .column
  164. p.control.is-fullwidth
  165. label.label Branch
  166. input(type='text', placeholder='e.g. master', v-model='conf.gitBranch', data-vv-scope='git', name='ipt-gitbranch', v-validate='{ required: true, min: 2 }')
  167. span.desc The git branch to use when synchronizing changes.
  168. section.columns
  169. .column.is-one-third
  170. p.control.is-fullwidth
  171. label.label Authentication
  172. select(v-model='conf.gitAuthType')
  173. option(value='ssh') SSH using Private Key file (recommended)
  174. option(value='sshenv') SSH using Private Key in environment variable
  175. option(value='sshdb') SSH using Private Key in database
  176. option(value='basic') Basic Credentials
  177. span.desc The authentication method used to connect to your remote Git repository.
  178. p.control.is-fullwidth
  179. input#ipt-git-verify-ssl(type='checkbox', v-model='conf.gitAuthSSL')
  180. label.label(for='ipt-git-verify-ssl') Verify SSL
  181. .column(v-show='conf.gitAuthType === "basic"')
  182. p.control.is-fullwidth
  183. label.label Username
  184. input(type='text', v-model='conf.gitAuthUser')
  185. span.desc The username for the remote git connection.
  186. .column(v-show='conf.gitAuthType === "basic"')
  187. p.control.is-fullwidth
  188. label.label Password
  189. input(type='password', v-model='conf.gitAuthPass')
  190. span.desc The password for the remote git connection.
  191. .column(v-show='conf.gitAuthType === "ssh"')
  192. p.control.is-fullwidth
  193. label.label Private Key location
  194. input(type='text', placeholder='e.g. /etc/wiki/keys/git.pem', v-model='conf.gitAuthSSHKey')
  195. span.desc The full path to the #[strong unencrypted] private key on disk.
  196. .column(v-show='conf.gitAuthType === "sshenv"')
  197. p.control.is-fullwidth
  198. label.label Private Key Environment Variable
  199. input(type='text', placeholder='e.g. GIT_PRIVATE_KEY', v-model='conf.gitAuthSSHKeyEnv')
  200. span.desc The environment variable containing the private key.
  201. .column(v-show='conf.gitAuthType === "sshdb"')
  202. p.control.is-fullwidth
  203. label.label Private Key Contents
  204. textarea(v-model='conf.gitAuthSSHKeyDB')
  205. span.desc Paste the contents of the private key in the above field
  206. section.columns
  207. .column.is-one-third
  208. p.control.is-fullwidth
  209. input#ipt-git-show-user-email(type='checkbox', v-model='conf.gitShowUserEmail')
  210. label.label(for='ipt-git-show-user-email') Commit using User Email
  211. span.desc When enabled, commits are made as the current user name and email. If unchecked, the current user name will still be used but the default commit author email will be used instead.
  212. .column
  213. p.control.is-fullwidth
  214. label.label Default Commit Author Email
  215. input(type='text', placeholder='e.g. user@example.com', v-model.number='conf.gitServerEmail', data-vv-scope='git', name='ipt-gitsrvemail', v-validate='{ required: true, email: true }')
  216. span.desc The default/fallback email to use when creating commits to the git repository.
  217. .panel-footer
  218. .progress-bar: div(v-bind:style='{width: currentProgress}')
  219. button.button.is-small.is-light-blue.is-outlined(v-on:click='proceedToGeneral', v-bind:disabled='loading') Back
  220. button.button.is-small.is-light-blue.is-outlined(v-on:click='conf.gitUseRemote = false; proceedToGitCheck()', v-bind:disabled='loading') Skip this step
  221. button.button.is-small.is-light-blue(v-on:click='conf.gitUseRemote = true; proceedToGitCheck()', v-bind:disabled='loading || errors.any("git")') Continue
  222. //- ==============================================
  223. //- GIT CHECK
  224. //- ==============================================
  225. template(v-else-if='state === "gitcheck"')
  226. .panel
  227. h2.panel-title.is-featured
  228. span Wiki.js
  229. i(v-if='loading')
  230. .panel-content.is-text
  231. .is-logo
  232. img(src='svg/logo-git.svg', alt='Git Logo')
  233. h4 Git Repository Check
  234. p(v-if='loading') #[svg.icons.is-24.is-text: use(xlink:href='#wk-msdots')] Verifying Git repository settings...
  235. p(v-if='!loading && gitcheck.ok')
  236. ul
  237. li(v-for='rs in gitcheck.results') #[svg.icons.is-18.is-text: use(xlink:href='#nc-check-bold')] {{rs}}
  238. p(v-if='!loading && gitcheck.ok')
  239. svg.icons.is-18.is-text: use(xlink:href='#nc-check-bold')
  240. strong Git settings are correct!
  241. p(v-if='!loading && !gitcheck.ok') #[svg.icons.is-18.is-text: use(xlink:href='#nc-square-remove')] Error: {{ gitcheck.error }}
  242. .panel-footer
  243. .progress-bar: div(v-bind:style='{width: currentProgress}')
  244. button.button.is-small.is-light-blue.is-outlined(v-on:click='proceedToGit', v-bind:disabled='loading') Back
  245. button.button.is-small.is-teal(v-on:click='proceedToGitCheck', v-if='!loading && !gitcheck.ok') Try Again
  246. button.button.is-small.is-light-blue(v-on:click='proceedToAdmin', v-if='loading || gitcheck.ok', v-bind:disabled='loading') Continue
  247. //- ==============================================
  248. //- ADMINISTRATOR ACCOUNT
  249. //- ==============================================
  250. template(v-else-if='state === "admin"')
  251. .panel
  252. h2.panel-title.is-featured
  253. span Wiki.js
  254. i(v-if='loading')
  255. .panel-content.is-text
  256. .is-logo
  257. svg.icons.is-64: use(xlink:href='#nc-man-black')
  258. h4 Administrator Account
  259. p A root administrator account will be created for local authentication. From this account, you can create or authorize more users.
  260. .panel-content.form-sections
  261. section
  262. p.control.is-fullwidth
  263. label.label Administrator Email
  264. input(type='text', placeholder='e.g. admin@example.com', v-model='conf.adminEmail', data-vv-scope='admin', name='ipt-adminemail', v-validate='{ required: true, email: true }')
  265. span.desc The email address of the administrator account
  266. section.columns
  267. .column
  268. p.control.is-fullwidth
  269. label.label Password
  270. input(type='password', v-model='conf.adminPassword', data-vv-scope='admin', name='ipt-adminpwd', v-validate='{ required: true, min: 8 }')
  271. span.desc At least 8 characters long.
  272. .column
  273. p.control.is-fullwidth
  274. label.label Confirm Password
  275. input(type='password', v-model='conf.adminPasswordConfirm', data-vv-scope='admin', name='ipt-adminpwd2', v-validate='{ required: true, confirmed: "ipt-adminpwd" }')
  276. span.desc Verify your password again.
  277. .panel-footer
  278. .progress-bar: div(v-bind:style='{width: currentProgress}')
  279. button.button.is-small.is-light-blue.is-outlined(v-on:click='proceedToGit', v-bind:disabled='loading') Back
  280. button.button.is-small.is-light-blue(v-on:click='proceedToUpgrade', v-bind:disabled='loading || errors.any("admin")') Continue
  281. //- ==============================================
  282. //- UPGRADE FROM 1.x
  283. //- ==============================================
  284. template(v-else-if='state === "upgrade"')
  285. .panel
  286. h2.panel-title.is-featured
  287. span Wiki.js
  288. i(v-if='loading')
  289. .panel-content.is-text
  290. .is-logo
  291. svg.icons.is-64: use(xlink:href='#nc-spaceship')
  292. h4 Upgrade from Wiki.js 1.x
  293. p Migrating from a Wiki.js 1.x installation is quick and simple.
  294. .panel-content.form-sections
  295. section
  296. p.control.is-fullwidth
  297. label.label Connection String to Wiki.js 1.x MongoDB database
  298. input(type='text', placeholder='mongodb://', v-model='conf.upgMongo', data-vv-scope='upgrade', name='ipt-mongo', v-validate='{ required: true, min: 2 }')
  299. span.desc A MongoDB database connection string where a Wiki.js 1.x installation is located. #[strong No alterations will be made to this database. ]
  300. .panel-footer
  301. .progress-bar: div(v-bind:style='{width: currentProgress}')
  302. button.button.is-small.is-light-blue.is-outlined(v-on:click='proceedToAdmin', v-bind:disabled='loading') Back
  303. button.button.is-small.is-light-blue(v-on:click='proceedToFinal', v-bind:disabled='loading || errors.any("general")') Continue
  304. //- ==============================================
  305. //- FINAL
  306. //- ==============================================
  307. template(v-else-if='state === "final"')
  308. .panel
  309. h2.panel-title.is-featured
  310. span Wiki.js
  311. i(v-if='loading')
  312. .panel-content.is-text
  313. .is-logo(v-if='loading')
  314. svg.icons.is-64: use(xlink:href='#wk-msdots')
  315. h4 Finalizing your installation...
  316. .is-logo(v-if='!loading && final.ok')
  317. svg.icons.is-64: use(xlink:href='#nc-check-bold')
  318. h4 Installation complete!
  319. p(v-if='!loading && final.ok'): strong Wiki.js was configured successfully and is now ready for use.
  320. p(v-if='!loading && final.ok') Click the #[strong Start] button below to access your newly configured wiki.
  321. p(v-if='!loading && !final.ok') #[svg.icons.is-18.is-text: use(xlink:href='#nc-square-remove')] Error: {{ final.error }}
  322. .panel-footer
  323. .progress-bar: div(v-bind:style='{width: currentProgress}')
  324. button.button.is-small.is-light-blue.is-outlined(v-on:click='proceedToAdmin', v-if='!loading && !final.ok', v-bind:disabled='loading') Back
  325. button.button.is-small.is-teal(v-on:click='proceedToFinal', v-if='!loading && !final.ok') Try Again
  326. button.button.is-small.is-green(v-on:click='finish', v-if='loading || final.ok', v-bind:disabled='loading') Start
  327. footer
  328. small Wiki.js Installation Wizard
  329. small(v-if='conf.telemetry') Telemetry Client ID: {{telemetryId}}
  330. </template>
  331. <script>
  332. /* global siteConfig */
  333. import axios from 'axios'
  334. import _ from 'lodash'
  335. export default {
  336. props: {
  337. telemetryId: {
  338. type: String,
  339. required: true
  340. },
  341. wikiVersion: {
  342. type: String,
  343. required: true
  344. },
  345. langs: {
  346. type: Array,
  347. required: true
  348. }
  349. },
  350. data() {
  351. return {
  352. loading: false,
  353. state: 'welcome',
  354. syscheck: {
  355. ok: false,
  356. error: '',
  357. results: []
  358. },
  359. dbcheck: {
  360. ok: false,
  361. error: ''
  362. },
  363. gitcheck: {
  364. ok: false,
  365. error: ''
  366. },
  367. final: {
  368. ok: false,
  369. error: '',
  370. redirectUrl: ''
  371. },
  372. conf: {
  373. adminEmail: '',
  374. adminPassword: '',
  375. adminPasswordConfirm: '',
  376. gitAuthPass: '',
  377. gitAuthSSHKey: '',
  378. gitAuthSSHKeyEnv: '',
  379. gitAuthSSHKeyDB: '',
  380. gitAuthSSL: true,
  381. gitAuthType: 'ssh',
  382. gitAuthUser: '',
  383. gitBranch: 'master',
  384. gitServerEmail: '',
  385. gitShowUserEmail: true,
  386. gitUrl: '',
  387. gitUseRemote: (siteConfig.git !== false),
  388. lang: siteConfig.lang || 'en',
  389. path: siteConfig.path || '/',
  390. pathRepo: './repo',
  391. port: siteConfig.port || 80,
  392. public: (siteConfig.public === true),
  393. selfRegister: (siteConfig.selfRegister === true),
  394. telemetry: true,
  395. title: siteConfig.title || 'Wiki',
  396. upgrade: false,
  397. upgMongo: 'mongodb://'
  398. },
  399. considerations: {
  400. https: false,
  401. port: false,
  402. localhost: false
  403. }
  404. }
  405. },
  406. computed: {
  407. currentProgress: function () {
  408. let perc = '0%'
  409. switch (this.state) {
  410. case 'welcome':
  411. perc = '0%'
  412. break
  413. case 'syscheck':
  414. perc = (this.syscheck.ok) ? '15%' : '5%'
  415. break
  416. case 'general':
  417. perc = '25%'
  418. break
  419. case 'considerations':
  420. perc = '30%'
  421. break
  422. case 'git':
  423. perc = '50%'
  424. break
  425. case 'gitcheck':
  426. perc = (this.gitcheck.ok) ? '70%' : '55%'
  427. break
  428. case 'admin':
  429. perc = '75%'
  430. break
  431. case 'upgrade':
  432. perc = '85%'
  433. break
  434. }
  435. return perc
  436. }
  437. },
  438. mounted: function () {
  439. /* if (appconfig.paths) {
  440. this.conf.pathData = appconfig.paths.data || './data'
  441. this.conf.pathRepo = appconfig.paths.repo || './repo'
  442. }
  443. if (appconfig.git !== false && _.isPlainObject(appconfig.git)) {
  444. this.conf.gitUrl = appconfig.git.url || ''
  445. this.conf.gitBranch = appconfig.git.branch || 'master'
  446. this.conf.gitShowUserEmail = (appconfig.git.showUserEmail !== false)
  447. this.conf.gitServerEmail = appconfig.git.serverEmail || ''
  448. if (_.isPlainObject(appconfig.git.auth)) {
  449. this.conf.gitAuthType = appconfig.git.auth.type || 'ssh'
  450. this.conf.gitAuthSSHKey = appconfig.git.auth.privateKey || ''
  451. this.conf.gitAuthUser = appconfig.git.auth.username || ''
  452. this.conf.gitAuthPass = appconfig.git.auth.password || ''
  453. this.conf.gitAuthSSL = (appconfig.git.auth.sslVerify !== false)
  454. }
  455. } */
  456. },
  457. methods: {
  458. proceedToWelcome: function (ev) {
  459. this.state = 'welcome'
  460. this.loading = false
  461. },
  462. proceedToSyscheck: function (ev) {
  463. let self = this
  464. this.state = 'syscheck'
  465. this.loading = true
  466. self.syscheck = {
  467. ok: false,
  468. error: '',
  469. results: []
  470. }
  471. _.delay(() => {
  472. axios.post('/syscheck', self.conf).then(resp => {
  473. if (resp.data.ok === true) {
  474. self.syscheck.ok = true
  475. self.syscheck.results = resp.data.results
  476. } else {
  477. self.syscheck.ok = false
  478. self.syscheck.error = resp.data.error
  479. }
  480. self.loading = false
  481. self.$nextTick()
  482. }).catch(err => {
  483. window.alert(err.message)
  484. })
  485. }, 1000)
  486. },
  487. proceedToGeneral: function (ev) {
  488. let self = this
  489. self.state = 'general'
  490. self.loading = false
  491. self.$nextTick(() => {
  492. self.$validator.validateAll('general')
  493. })
  494. },
  495. proceedToConsiderations: function (ev) {
  496. this.considerations = {
  497. https: false,
  498. port: false, // TODO
  499. localhost: false
  500. }
  501. this.state = 'considerations'
  502. this.loading = false
  503. },
  504. proceedToGit: function (ev) {
  505. let self = this
  506. self.state = 'git'
  507. self.loading = false
  508. self.$nextTick(() => {
  509. self.$validator.validateAll('git')
  510. })
  511. },
  512. proceedToGitCheck: function (ev) {
  513. let self = this
  514. this.state = 'gitcheck'
  515. this.loading = true
  516. self.gitcheck = {
  517. ok: false,
  518. results: [],
  519. error: ''
  520. }
  521. _.delay(() => {
  522. axios.post('/gitcheck', self.conf).then(resp => {
  523. if (resp.data.ok === true) {
  524. self.gitcheck.ok = true
  525. self.gitcheck.results = resp.data.results
  526. } else {
  527. self.gitcheck.ok = false
  528. self.gitcheck.error = resp.data.error
  529. }
  530. self.loading = false
  531. self.$nextTick()
  532. }).catch(err => {
  533. window.alert(err.message)
  534. })
  535. }, 1000)
  536. },
  537. proceedToAdmin: function (ev) {
  538. let self = this
  539. self.state = 'admin'
  540. self.loading = false
  541. self.$nextTick(() => {
  542. self.$validator.validateAll('admin')
  543. })
  544. },
  545. proceedToUpgrade: function (ev) {
  546. if (this.conf.upgrade) {
  547. this.state = 'upgrade'
  548. this.loading = false
  549. this.$nextTick(() => {
  550. this.$validator.validateAll('upgrade')
  551. })
  552. } else {
  553. this.proceedToFinal()
  554. }
  555. },
  556. proceedToFinal: function (ev) {
  557. let self = this
  558. self.state = 'final'
  559. self.loading = true
  560. self.final = {
  561. ok: false,
  562. error: '',
  563. redirectUrl: ''
  564. }
  565. _.delay(() => {
  566. axios.post('/finalize', self.conf).then(resp => {
  567. if (resp.data.ok === true) {
  568. self.$helpers._.delay(() => {
  569. self.final.ok = true
  570. switch (resp.data.redirectPort) {
  571. case 80:
  572. self.final.redirectUrl = `http://${window.location.hostname}${resp.data.redirectPath}/login`
  573. break
  574. case 443:
  575. self.final.redirectUrl = `https://${window.location.hostname}${resp.data.redirectPath}/login`
  576. break
  577. default:
  578. self.final.redirectUrl = `http://${window.location.hostname}:${resp.data.redirectPort}${resp.data.redirectPath}/login`
  579. break
  580. }
  581. self.loading = false
  582. }, 5000)
  583. } else {
  584. self.final.ok = false
  585. self.final.error = resp.data.error
  586. self.loading = false
  587. }
  588. self.$nextTick()
  589. }).catch(err => {
  590. window.alert(err.message)
  591. })
  592. }, 1000)
  593. },
  594. finish: function (ev) {
  595. window.location.assign(this.final.redirectUrl)
  596. }
  597. }
  598. }
  599. </script>