wikijs-fork/client/js/configure.js

80 lines
1.9 KiB
JavaScript
Raw Normal View History

2017-03-05 04:20:22 +00:00
'use strict'
/* global jQuery, _, Vue, axios */
jQuery(document).ready(function ($) {
new Vue({ // eslint-disable-line no-new
el: 'main',
data: {
loading: false,
state: 'considerations',
2017-03-05 04:20:22 +00:00
syscheck: {
ok: false,
error: '',
results: []
2017-03-05 04:20:22 +00:00
},
conf: {
title: 'Wiki',
2017-03-06 03:22:21 +00:00
host: '',
port: 80,
lang: 'en',
db: 'mongodb://localhost:27017/wiki'
},
considerations: {
https: false,
port: false,
localhost: false
2017-03-05 04:20:22 +00:00
}
},
methods: {
2017-03-06 03:22:21 +00:00
proceedToWelcome: function (ev) {
this.state = 'welcome'
this.loading = false
},
2017-03-05 04:20:22 +00:00
proceedToSyscheck: function (ev) {
let self = this
this.state = 'syscheck'
this.loading = true
self.syscheck = {
ok: false,
error: '',
results: []
}
2017-03-05 04:20:22 +00:00
_.delay(() => {
axios.post('/syscheck').then(resp => {
if (resp.data.ok === true) {
self.syscheck.ok = true
self.syscheck.results = resp.data.results
2017-03-05 04:20:22 +00:00
} else {
self.syscheck.ok = false
self.syscheck.error = resp.data.error
}
self.loading = false
self.$nextTick()
2017-03-05 04:20:22 +00:00
}).catch(err => {
window.alert(err.message)
})
}, 1000)
},
proceedToGeneral: function (ev) {
this.state = 'general'
2017-03-06 03:22:21 +00:00
this.loading = false
},
proceedToConsiderations: function (ev) {
this.considerations = {
https: !_.startsWith(this.conf.host, 'https'),
port: false, // TODO
localhost: _.includes(this.conf.host, 'localhost')
}
this.state = 'considerations'
this.loading = false
},
2017-03-06 03:22:21 +00:00
proceedToDb: function (ev) {
this.state = 'db'
this.loading = false
2017-03-05 04:20:22 +00:00
}
}
})
})