Commit 8d74c48b authored by NGPixel's avatar NGPixel

refactor: move setup view to vue component

parent 7b269414
......@@ -154,7 +154,7 @@ Vue.component('modalUpgradeSystem', modalUpgradeSystemComponent)
Vue.component('navigator', navigatorComponent)
Vue.component('pageLoader', pageLoaderComponent)
Vue.component('search', searchComponent)
Vue.component('setup', () => import(/* webpackChunkName: "setup" */ './components/setup.component.js'))
Vue.component('setup', () => import(/* webpackChunkName: "setup" */ './components/setup.vue'))
Vue.component('sourceView', sourceViewComponent)
Vue.component('toggle', toggleComponent)
Vue.component('tree', treeComponent)
......@@ -174,20 +174,17 @@ document.addEventListener('DOMContentLoaded', ev => {
const i18n = localization.init()
window.wiki = new Vue({
mixins: [helpers],
el: '#app',
components: {},
mixins: [helpers],
store,
i18n,
el: '#app',
methods: {
changeTheme(opts) {
this.$el.className = `has-stickynav is-primary-${opts.primary} is-alternate-${opts.alt}`
this.$refs.header.className = `nav is-${opts.primary}`
this.$refs.footer.className = `footer is-${opts.footer}`
}
},
mounted() {
}
})
......
/* 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: '',
redirectUrl: ''
},
conf: {
adminEmail: '',
adminPassword: '',
adminPasswordConfirm: '',
gitAuthPass: '',
gitAuthSSHKey: '',
gitAuthSSHKeyEnv: '',
gitAuthSSHKeyDB: '',
gitAuthSSL: true,
gitAuthType: 'ssh',
gitAuthUser: '',
gitBranch: 'master',
gitServerEmail: '',
gitShowUserEmail: true,
gitUrl: '',
gitUseRemote: (siteConfig.git !== false),
lang: siteConfig.lang || 'en',
path: siteConfig.path || '/',
pathRepo: './repo',
port: siteConfig.port || 80,
public: (siteConfig.public === true),
selfRegister: (siteConfig.selfRegister === true),
telemetry: true,
title: siteConfig.title || 'Wiki',
upgrade: false,
upgMongo: 'mongodb://'
},
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':
perc = '25%'
break
case 'considerations':
perc = '30%'
break
case 'git':
perc = '50%'
break
case 'gitcheck':
perc = (this.gitcheck.ok) ? '70%' : '55%'
break
case 'admin':
perc = '75%'
break
case 'upgrade':
perc = '85%'
break
}
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(() => {
axios.post('/syscheck', self.conf).then(resp => {
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')
})
},
proceedToUpgrade: function (ev) {
if (this.conf.upgrade) {
this.state = 'upgrade'
this.loading = false
this.$nextTick(() => {
this.$validator.validateAll('upgrade')
})
} else {
this.proceedToFinal()
}
},
proceedToFinal: function (ev) {
let self = this
self.state = 'final'
self.loading = true
self.final = {
ok: false,
error: '',
redirectUrl: ''
}
this.$helpers._.delay(() => {
axios.post('/finalize', self.conf).then(resp => {
if (resp.data.ok === true) {
self.$helpers._.delay(() => {
self.final.ok = true
switch (resp.data.redirectPort) {
case 80:
self.final.redirectUrl = `http://${window.location.hostname}${resp.data.redirectPath}/login`
break
case 443:
self.final.redirectUrl = `https://${window.location.hostname}${resp.data.redirectPath}/login`
break
default:
self.final.redirectUrl = `http://${window.location.hostname}:${resp.data.redirectPort}${resp.data.redirectPath}/login`
break
}
self.loading = false
}, 5000)
} 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) {
window.location.assign(this.final.redirectUrl)
}
}
}
......@@ -10,7 +10,6 @@ const Promise = require('bluebird')
const autoprefixer = require('autoprefixer')
const colors = require('colors/safe')
const fsbx = require('fuse-box')
const nodemon = require('nodemon')
const fs = require('fs-extra')
const yargs = require('yargs')
const yaml = require('js-yaml')
......
......@@ -2,6 +2,7 @@ const webpack = require('webpack')
const merge = require('webpack-merge')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const WriteFilePlugin = require('write-file-webpack-plugin')
const common = require('./webpack.common.js')
......@@ -18,6 +19,7 @@ module.exports = merge(common, {
'process.env.NODE_ENV': JSON.stringify('development')
}),
new ExtractTextPlugin({ disable: true }),
new WriteFilePlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.WatchIgnorePlugin([
/node_modules/
......
......@@ -179,7 +179,6 @@
"name-all-modules-plugin": "1.0.1",
"node-dev": "3.1.3",
"node-sass": "4.7.2",
"nodemon": "1.14.11",
"offline-plugin": "4.9.0",
"postcss-loader": "2.0.10",
"postcss-selector-parser": "3.1.1",
......@@ -212,7 +211,8 @@
"webpack-dev-middleware": "2.0.4",
"webpack-hot-middleware": "2.21.0",
"webpack-merge": "4.1.1",
"whatwg-fetch": "2.0.3"
"whatwg-fetch": "2.0.3",
"write-file-webpack-plugin": "4.2.0"
},
"browserslist": [
"> 1%",
......
This diff was suppressed by a .gitattributes entry.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment