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.

79 lines
1.9 KiB

  1. 'use strict'
  2. /* global jQuery, _, Vue, axios */
  3. jQuery(document).ready(function ($) {
  4. new Vue({ // eslint-disable-line no-new
  5. el: 'main',
  6. data: {
  7. loading: false,
  8. state: 'considerations',
  9. syscheck: {
  10. ok: false,
  11. error: '',
  12. results: []
  13. },
  14. conf: {
  15. title: 'Wiki',
  16. host: '',
  17. port: 80,
  18. lang: 'en',
  19. db: 'mongodb://localhost:27017/wiki'
  20. },
  21. considerations: {
  22. https: false,
  23. port: false,
  24. localhost: false
  25. }
  26. },
  27. methods: {
  28. proceedToWelcome: function (ev) {
  29. this.state = 'welcome'
  30. this.loading = false
  31. },
  32. proceedToSyscheck: function (ev) {
  33. let self = this
  34. this.state = 'syscheck'
  35. this.loading = true
  36. self.syscheck = {
  37. ok: false,
  38. error: '',
  39. results: []
  40. }
  41. _.delay(() => {
  42. axios.post('/syscheck').then(resp => {
  43. if (resp.data.ok === true) {
  44. self.syscheck.ok = true
  45. self.syscheck.results = resp.data.results
  46. } else {
  47. self.syscheck.ok = false
  48. self.syscheck.error = resp.data.error
  49. }
  50. self.loading = false
  51. self.$nextTick()
  52. }).catch(err => {
  53. window.alert(err.message)
  54. })
  55. }, 1000)
  56. },
  57. proceedToGeneral: function (ev) {
  58. this.state = 'general'
  59. this.loading = false
  60. },
  61. proceedToConsiderations: function (ev) {
  62. this.considerations = {
  63. https: !_.startsWith(this.conf.host, 'https'),
  64. port: false, // TODO
  65. localhost: _.includes(this.conf.host, 'localhost')
  66. }
  67. this.state = 'considerations'
  68. this.loading = false
  69. },
  70. proceedToDb: function (ev) {
  71. this.state = 'db'
  72. this.loading = false
  73. }
  74. }
  75. })
  76. })