2017-05-21 20:43:58 +00:00
|
|
|
<template lang="pug">
|
2017-05-27 03:01:32 +00:00
|
|
|
transition(:duration="400")
|
|
|
|
.modal(v-show='isShown', v-cloak)
|
|
|
|
transition(name='modal-background')
|
|
|
|
.modal-background(v-show='isShown')
|
|
|
|
.modal-container
|
|
|
|
transition(name='modal-content')
|
|
|
|
.modal-content(v-show='isShown')
|
|
|
|
header.is-blue
|
2017-05-31 01:23:38 +00:00
|
|
|
span {{ $t('modal.createusertitle') }}
|
2017-06-10 02:33:33 +00:00
|
|
|
p.modal-notify(:class='{ "is-active": isLoading }'): i
|
2017-05-27 03:01:32 +00:00
|
|
|
section
|
2017-05-31 01:23:38 +00:00
|
|
|
label.label {{ $t('modal.createuseremail') }}
|
2017-05-27 03:01:32 +00:00
|
|
|
p.control.is-fullwidth
|
2017-06-10 02:33:33 +00:00
|
|
|
input.input(type='text', :placeholder='$t("modal.createuseremailplaceholder")', v-model='email', ref='createUserEmailInput')
|
2017-05-27 03:01:32 +00:00
|
|
|
section
|
2017-05-31 01:23:38 +00:00
|
|
|
label.label {{ $t('modal.createuserprovider') }}
|
2017-05-27 03:01:32 +00:00
|
|
|
p.control.is-fullwidth
|
|
|
|
select(v-model='provider')
|
|
|
|
option(value='local') Local Database
|
|
|
|
option(value='windowslive') Microsoft Account
|
|
|
|
option(value='google') Google ID
|
|
|
|
option(value='facebook') Facebook
|
|
|
|
option(value='github') GitHub
|
|
|
|
option(value='slack') Slack
|
|
|
|
section(v-if='provider=="local"')
|
2017-05-31 01:23:38 +00:00
|
|
|
label.label {{ $t('modal.createuserpassword') }}
|
2017-05-27 03:01:32 +00:00
|
|
|
p.control.is-fullwidth
|
|
|
|
input.input(type='password', placeholder='', v-model='password')
|
|
|
|
section(v-if='provider=="local"')
|
2017-06-10 14:41:15 +00:00
|
|
|
label.label {{ $t('modal.createusername') }}
|
2017-05-27 03:01:32 +00:00
|
|
|
p.control.is-fullwidth
|
2017-06-10 02:33:33 +00:00
|
|
|
input.input(type='text', :placeholder='$t("modal.createusernameplaceholder")', v-model='name')
|
2017-05-27 03:01:32 +00:00
|
|
|
footer
|
2017-06-10 02:33:33 +00:00
|
|
|
a.button.is-grey.is-outlined(@click='cancel') {{ $t('modal.discard') }}
|
|
|
|
a.button(@click='create', v-if='provider=="local"', :disabled='isLoading', :class='{ "is-disabled": isLoading, "is-blue": !loading }') {{ $t('modal.createuser') }}
|
|
|
|
a.button(@click='create', v-if='provider!="local"', :disabled='isLoading', :class='{ "is-disabled": isLoading, "is-blue": !loading }') {{ $t('modal.createuserauthorize') }}
|
2017-05-21 20:43:58 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2017-06-10 02:33:33 +00:00
|
|
|
export default {
|
|
|
|
name: 'modal-create-user',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
email: '',
|
|
|
|
provider: 'local',
|
|
|
|
password: '',
|
|
|
|
name: '',
|
|
|
|
isLoading: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
isShown() {
|
|
|
|
return this.$store.state.modalCreateUser.shown
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
init() {
|
|
|
|
let self = this
|
|
|
|
self._.delay(() => {
|
|
|
|
self.$refs.createUserEmailInput.focus()
|
|
|
|
}, 100)
|
2017-05-21 20:43:58 +00:00
|
|
|
},
|
2017-06-10 02:33:33 +00:00
|
|
|
cancel() {
|
|
|
|
this.$store.dispatch('modalCreateUser/close')
|
|
|
|
this.email = ''
|
|
|
|
this.provider = 'local'
|
2017-05-21 20:43:58 +00:00
|
|
|
},
|
2017-06-10 02:33:33 +00:00
|
|
|
create() {
|
|
|
|
let self = this
|
|
|
|
this.isLoading = true
|
|
|
|
this.$http.post('/admin/users/create', {
|
|
|
|
email: this.email,
|
|
|
|
provider: this.provider,
|
|
|
|
password: this.password,
|
|
|
|
name: this.name
|
|
|
|
}).then(resp => {
|
|
|
|
return resp.json()
|
|
|
|
}).then(resp => {
|
|
|
|
this.isLoading = false
|
|
|
|
if (resp.ok) {
|
|
|
|
this.cancel()
|
|
|
|
window.location.reload(true)
|
|
|
|
} else {
|
2017-05-21 20:43:58 +00:00
|
|
|
self.$store.dispatch('alert', {
|
|
|
|
style: 'red',
|
|
|
|
icon: 'square-cross',
|
2017-06-10 02:33:33 +00:00
|
|
|
msg: resp.msg
|
2017-05-21 20:43:58 +00:00
|
|
|
})
|
2017-06-10 02:33:33 +00:00
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
this.isLoading = false
|
|
|
|
self.$store.dispatch('alert', {
|
|
|
|
style: 'red',
|
|
|
|
icon: 'square-cross',
|
|
|
|
msg: 'Error: ' + err.body.msg
|
2017-05-21 20:43:58 +00:00
|
|
|
})
|
2017-06-10 02:33:33 +00:00
|
|
|
})
|
2017-05-21 20:43:58 +00:00
|
|
|
}
|
2017-06-10 02:33:33 +00:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.$root.$on('modalCreateUser/init', this.init)
|
2017-05-21 20:43:58 +00:00
|
|
|
}
|
2017-06-10 02:33:33 +00:00
|
|
|
}
|
2017-05-21 20:43:58 +00:00
|
|
|
</script>
|