2017-10-08 21:21:36 +00:00
|
|
|
/* global siteConfig */
|
|
|
|
|
|
|
|
import axios from 'axios'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'configManager',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: false,
|
|
|
|
state: 'welcome',
|
|
|
|
syscheck: {
|
|
|
|
ok: false,
|
|
|
|
error: '',
|
|
|
|
results: []
|
|
|
|
},
|
|
|
|
dbcheck: {
|
|
|
|
ok: false,
|
|
|
|
error: ''
|
|
|
|
},
|
|
|
|
gitcheck: {
|
|
|
|
ok: false,
|
|
|
|
error: ''
|
|
|
|
},
|
|
|
|
final: {
|
|
|
|
ok: false,
|
|
|
|
error: '',
|
|
|
|
results: []
|
|
|
|
},
|
|
|
|
conf: {
|
2017-10-30 01:36:05 +00:00
|
|
|
adminEmail: '',
|
|
|
|
adminPassword: '',
|
|
|
|
adminPasswordConfirm: '',
|
2017-10-08 21:21:36 +00:00
|
|
|
gitAuthPass: '',
|
2017-10-30 01:36:05 +00:00
|
|
|
gitAuthSSHKey: '',
|
2017-11-13 04:48:19 +00:00
|
|
|
gitAuthSSHKeyEnv: '',
|
|
|
|
gitAuthSSHKeyDB: '',
|
2017-10-08 21:21:36 +00:00
|
|
|
gitAuthSSL: true,
|
2017-10-30 01:36:05 +00:00
|
|
|
gitAuthType: 'ssh',
|
|
|
|
gitAuthUser: '',
|
|
|
|
gitBranch: 'master',
|
2017-10-08 21:21:36 +00:00
|
|
|
gitServerEmail: '',
|
2017-10-30 01:36:05 +00:00
|
|
|
gitShowUserEmail: true,
|
|
|
|
gitUrl: '',
|
|
|
|
gitUseRemote: (siteConfig.git !== false),
|
|
|
|
lang: siteConfig.lang || 'en',
|
|
|
|
path: siteConfig.path || '/',
|
|
|
|
pathRepo: './repo',
|
|
|
|
port: siteConfig.port || 80,
|
|
|
|
public: (siteConfig.public === true),
|
2017-11-13 04:48:19 +00:00
|
|
|
selfregister: (siteConfig.selfregister === true),
|
2017-10-30 01:36:05 +00:00
|
|
|
telemetry: true,
|
|
|
|
title: siteConfig.title || 'Wiki',
|
2017-11-19 22:08:23 +00:00
|
|
|
upgrade: false,
|
2017-11-21 04:08:30 +00:00
|
|
|
upgMongo: 'mongodb://'
|
2017-10-08 21:21:36 +00:00
|
|
|
},
|
|
|
|
considerations: {
|
|
|
|
https: false,
|
|
|
|
port: false,
|
|
|
|
localhost: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
currentProgress: function () {
|
|
|
|
let perc = '0%'
|
|
|
|
switch (this.state) {
|
|
|
|
case 'welcome':
|
|
|
|
perc = '0%'
|
|
|
|
break
|
|
|
|
case 'syscheck':
|
|
|
|
perc = (this.syscheck.ok) ? '15%' : '5%'
|
|
|
|
break
|
|
|
|
case 'general':
|
2017-10-09 04:16:08 +00:00
|
|
|
perc = '25%'
|
2017-10-08 21:21:36 +00:00
|
|
|
break
|
|
|
|
case 'considerations':
|
|
|
|
perc = '30%'
|
|
|
|
break
|
|
|
|
case 'git':
|
2017-10-09 04:16:08 +00:00
|
|
|
perc = '50%'
|
2017-10-08 21:21:36 +00:00
|
|
|
break
|
|
|
|
case 'gitcheck':
|
2017-10-09 04:16:08 +00:00
|
|
|
perc = (this.gitcheck.ok) ? '70%' : '55%'
|
2017-10-08 21:21:36 +00:00
|
|
|
break
|
|
|
|
case 'admin':
|
2017-10-09 04:16:08 +00:00
|
|
|
perc = '75%'
|
2017-10-08 21:21:36 +00:00
|
|
|
break
|
2017-10-29 05:30:46 +00:00
|
|
|
case 'upgrade':
|
|
|
|
perc = '85%'
|
|
|
|
break
|
2017-10-08 21:21:36 +00:00
|
|
|
}
|
|
|
|
return perc
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted: function () {
|
|
|
|
/* if (appconfig.paths) {
|
|
|
|
this.conf.pathData = appconfig.paths.data || './data'
|
|
|
|
this.conf.pathRepo = appconfig.paths.repo || './repo'
|
|
|
|
}
|
|
|
|
if (appconfig.git !== false && _.isPlainObject(appconfig.git)) {
|
|
|
|
this.conf.gitUrl = appconfig.git.url || ''
|
|
|
|
this.conf.gitBranch = appconfig.git.branch || 'master'
|
|
|
|
this.conf.gitShowUserEmail = (appconfig.git.showUserEmail !== false)
|
|
|
|
this.conf.gitServerEmail = appconfig.git.serverEmail || ''
|
|
|
|
if (_.isPlainObject(appconfig.git.auth)) {
|
|
|
|
this.conf.gitAuthType = appconfig.git.auth.type || 'ssh'
|
|
|
|
this.conf.gitAuthSSHKey = appconfig.git.auth.privateKey || ''
|
|
|
|
this.conf.gitAuthUser = appconfig.git.auth.username || ''
|
|
|
|
this.conf.gitAuthPass = appconfig.git.auth.password || ''
|
|
|
|
this.conf.gitAuthSSL = (appconfig.git.auth.sslVerify !== false)
|
|
|
|
}
|
|
|
|
} */
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
proceedToWelcome: function (ev) {
|
|
|
|
this.state = 'welcome'
|
|
|
|
this.loading = false
|
|
|
|
},
|
|
|
|
proceedToSyscheck: function (ev) {
|
|
|
|
let self = this
|
|
|
|
this.state = 'syscheck'
|
|
|
|
this.loading = true
|
|
|
|
self.syscheck = {
|
|
|
|
ok: false,
|
|
|
|
error: '',
|
|
|
|
results: []
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$helpers._.delay(() => {
|
2017-10-23 01:58:07 +00:00
|
|
|
axios.post('/syscheck', self.conf).then(resp => {
|
2017-10-08 21:21:36 +00:00
|
|
|
if (resp.data.ok === true) {
|
|
|
|
self.syscheck.ok = true
|
|
|
|
self.syscheck.results = resp.data.results
|
|
|
|
} else {
|
|
|
|
self.syscheck.ok = false
|
|
|
|
self.syscheck.error = resp.data.error
|
|
|
|
}
|
|
|
|
self.loading = false
|
|
|
|
self.$nextTick()
|
|
|
|
}).catch(err => {
|
|
|
|
window.alert(err.message)
|
|
|
|
})
|
|
|
|
}, 1000)
|
|
|
|
},
|
|
|
|
proceedToGeneral: function (ev) {
|
|
|
|
let self = this
|
|
|
|
self.state = 'general'
|
|
|
|
self.loading = false
|
|
|
|
self.$nextTick(() => {
|
|
|
|
self.$validator.validateAll('general')
|
|
|
|
})
|
|
|
|
},
|
|
|
|
proceedToConsiderations: function (ev) {
|
|
|
|
this.considerations = {
|
|
|
|
https: !this.$helpers._.startsWith(this.conf.host, 'https'),
|
|
|
|
port: false, // TODO
|
|
|
|
localhost: this.$helpers._.includes(this.conf.host, 'localhost')
|
|
|
|
}
|
|
|
|
this.state = 'considerations'
|
|
|
|
this.loading = false
|
|
|
|
},
|
|
|
|
proceedToGit: function (ev) {
|
|
|
|
let self = this
|
|
|
|
self.state = 'git'
|
|
|
|
self.loading = false
|
|
|
|
self.$nextTick(() => {
|
|
|
|
self.$validator.validateAll('git')
|
|
|
|
})
|
|
|
|
},
|
|
|
|
proceedToGitCheck: function (ev) {
|
|
|
|
let self = this
|
|
|
|
this.state = 'gitcheck'
|
|
|
|
this.loading = true
|
|
|
|
self.gitcheck = {
|
|
|
|
ok: false,
|
|
|
|
results: [],
|
|
|
|
error: ''
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$helpers._.delay(() => {
|
|
|
|
axios.post('/gitcheck', self.conf).then(resp => {
|
|
|
|
if (resp.data.ok === true) {
|
|
|
|
self.gitcheck.ok = true
|
|
|
|
self.gitcheck.results = resp.data.results
|
|
|
|
} else {
|
|
|
|
self.gitcheck.ok = false
|
|
|
|
self.gitcheck.error = resp.data.error
|
|
|
|
}
|
|
|
|
self.loading = false
|
|
|
|
self.$nextTick()
|
|
|
|
}).catch(err => {
|
|
|
|
window.alert(err.message)
|
|
|
|
})
|
|
|
|
}, 1000)
|
|
|
|
},
|
|
|
|
proceedToAdmin: function (ev) {
|
|
|
|
let self = this
|
|
|
|
self.state = 'admin'
|
|
|
|
self.loading = false
|
|
|
|
self.$nextTick(() => {
|
|
|
|
self.$validator.validateAll('admin')
|
|
|
|
})
|
|
|
|
},
|
2017-10-29 05:30:46 +00:00
|
|
|
proceedToUpgrade: function (ev) {
|
|
|
|
if (this.conf.upgrade) {
|
|
|
|
this.state = 'upgrade'
|
|
|
|
this.loading = false
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.$validator.validateAll('upgrade')
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.proceedToFinal()
|
|
|
|
}
|
|
|
|
},
|
2017-10-08 21:21:36 +00:00
|
|
|
proceedToFinal: function (ev) {
|
|
|
|
let self = this
|
|
|
|
self.state = 'final'
|
|
|
|
self.loading = true
|
|
|
|
self.final = {
|
|
|
|
ok: false,
|
|
|
|
error: '',
|
|
|
|
results: []
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$helpers._.delay(() => {
|
|
|
|
axios.post('/finalize', self.conf).then(resp => {
|
|
|
|
if (resp.data.ok === true) {
|
|
|
|
self.final.ok = true
|
|
|
|
self.final.results = resp.data.results
|
|
|
|
} else {
|
|
|
|
self.final.ok = false
|
|
|
|
self.final.error = resp.data.error
|
|
|
|
}
|
|
|
|
self.loading = false
|
|
|
|
self.$nextTick()
|
|
|
|
}).catch(err => {
|
|
|
|
window.alert(err.message)
|
|
|
|
})
|
|
|
|
}, 1000)
|
|
|
|
},
|
|
|
|
finish: function (ev) {
|
|
|
|
let self = this
|
|
|
|
self.state = 'restart'
|
|
|
|
|
|
|
|
this.$helpers._.delay(() => {
|
|
|
|
axios.post('/restart', {}).then(resp => {
|
|
|
|
this.$helpers._.delay(() => {
|
|
|
|
window.location.assign(self.conf.host)
|
|
|
|
}, 30000)
|
|
|
|
}).catch(err => {
|
|
|
|
window.alert(err.message)
|
|
|
|
})
|
|
|
|
}, 1000)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|