minors + set Favicon

This commit is contained in:
les
2020-01-15 23:51:09 +01:00
parent 474794e9ab
commit 3b04cdd485
10 changed files with 116 additions and 73 deletions

View File

@@ -31,11 +31,8 @@ export default {
user: {}
}
},
head () {
return {
title: this.settings.title + ' - ' + this.$t('common.register')
}
},
// https://nuxtjs.org/api/pages-validate/
// If the validate method does not return true, Nuxt.js will automatically load the 404 error page.
validate ({ store }) {
return store.state.settings.allow_registration
},
@@ -71,6 +68,11 @@ export default {
}
this.loading = false
}
},
head () {
return {
title: this.settings.title + ' - ' + this.$t('common.register')
}
}
}
</script>

View File

@@ -1,41 +1,38 @@
<template lang="pug">
el-main
h4 <nuxt-link to='/'><img src='/favicon.ico'/></nuxt-link> {{$t('common.settings')}}
el-divider {{$auth.user.email}}
el-form(action='/api/user' method='PUT' @submit.native.prevent='update_settings' inline label-width='200px')
el-form-item(:label="$t('settings.change_password')")
el-input(v-model='password' type='password')
el-button(type='success' native-type='submit') {{$t('common.save')}}
p {{$auth.user.email}}
//- el-form(action='/api/user' method='PUT' @submit.native.prevent='update_settings' inline label-width='200px')
//- el-form-item(:label="$t('settings.change_password')")
//- el-input(v-model='password' type='password')
//- el-button(type='success' native-type='submit') {{$t('common.save')}}
el-divider {{$t('settings.danger_section')}}
p {{$t('settings.remove_account')}}
el-button(type='danger' @click='remove_account') {{$t('common.remove')}}
</template>
<script>
import { mapState, mapActions } from 'vuex'
import { mapState } from 'vuex'
import { Message, MessageBox } from 'element-ui'
import url from 'url'
export default {
name: 'Settings',
async asyncData ({ $axios, params, error }) {
try {
const user = await $axios.$get('/auth/user')
return { user }
} catch (e) {
error({ statusCode: 404, message: 'Something goes wrong...' })
}
},
middleware: ['auth'],
data () {
return {
password: '',
user: { }
}
},
head () {
return {
title: `${this.settings.title} - ${this.$t('common.settings')}`
}
},
async asyncData ({ $axios, params }) {
const user = await $axios.$get('/auth/user')
return { user }
},
computed: {
...mapState(['settings']),
baseurl () {
@@ -43,30 +40,30 @@ export default {
}
},
methods: {
async change_password () {
if (!this.password) { return }
const user_data = { id: this.$auth.user.id, password: this.password }
try {
const user = await this.$axios.$put('/user', user_data)
Message({ message: this.$t('settings.password_updated'), showClose: true, type: 'success' })
this.$router.replace('/')
} catch (e) {
console.log(e)
}
},
async update_settings () {
MessageBox.confirm(this.$t('settings.update_confirm'),
this.$t('common.confirm'), {
confirmButtonText: this.$t('common.ok'),
cancelButtonText: this.$t('common.cancel'),
type: 'error'
}).then(async () => {
this.user = await this.$axios.$put('/user', { ...this.user, password: this.password })
}).catch(e => {
Message({ message: e, showClose: true, type: 'warning' })
})
},
async remove_account () {
// async change_password () {
// if (!this.password) { return }
// const user_data = { id: this.$auth.user.id, password: this.password }
// try {
// await this.$axios.$put('/user', user_data)
// Message({ message: this.$t('settings.password_updated'), showClose: true, type: 'success' })
// this.$router.replace('/')
// } catch (e) {
// console.log(e)
// }
// },
// update_settings () {
// MessageBox.confirm(this.$t('settings.update_confirm'),
// this.$t('common.confirm'), {
// confirmButtonText: this.$t('common.ok'),
// cancelButtonText: this.$t('common.cancel'),
// type: 'error'
// }).then(async () => {
// this.user = await this.$axios.$put('/user', { ...this.user, password: this.password })
// }).catch(e => {
// Message({ message: e, showClose: true, type: 'warning' })
// })
// },
remove_account () {
MessageBox.confirm(this.$t('settings.remove_account_confirm'), this.$t('common.confirm'), {
confirmButtonText: this.$t('common.ok'),
cancelButtonText: this.$t('common.cancel'),
@@ -77,6 +74,11 @@ export default {
this.$router.replace('/')
})
}
},
head () {
return {
title: `${this.settings.title} - ${this.$t('common.settings')}`
}
}
}
</script>