Add remove user action on dashboard
This commit is contained in:
@@ -26,6 +26,10 @@ export async function reset_password(prm) {
|
|||||||
return post('reset_password', prm)
|
return post('reset_password', prm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function remove_user(prm) {
|
||||||
|
return post('remove_user', prm)
|
||||||
|
}
|
||||||
|
|
||||||
export async function assign_project(prm) {
|
export async function assign_project(prm) {
|
||||||
return post('assign_project', prm)
|
return post('assign_project', prm)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,12 +18,13 @@
|
|||||||
<v-btn small color="warning" @click="newForm">Baru</v-btn>
|
<v-btn small color="warning" @click="newForm">Baru</v-btn>
|
||||||
<v-btn small color="primary" @click="saveUser">Simpan</v-btn>
|
<v-btn small color="primary" @click="saveUser">Simpan</v-btn>
|
||||||
<v-btn small color="info" @click="resetPassword">Reset Password</v-btn>
|
<v-btn small color="info" @click="resetPassword">Reset Password</v-btn>
|
||||||
|
<v-btn small color="error" :disabled="!isEditMode" @click="removeUser">Hapus User</v-btn>
|
||||||
</v-subheader>
|
</v-subheader>
|
||||||
<v-divider></v-divider>
|
<v-divider></v-divider>
|
||||||
|
|
||||||
<v-layout row wrap class="pa-2">
|
<v-layout row wrap class="pa-2">
|
||||||
<v-flex xs12 pa-1>
|
<v-flex xs12 pa-1>
|
||||||
<v-text-field label="Username*" v-model="username"></v-text-field>
|
<v-text-field label="Username*" :readonly="isEditMode" v-model="username"></v-text-field>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-flex xs12 pa-1>
|
<v-flex xs12 pa-1>
|
||||||
<v-text-field label="Display Name" v-model="displayName"></v-text-field>
|
<v-text-field label="Display Name" v-model="displayName"></v-text-field>
|
||||||
@@ -75,6 +76,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
selectedUser() { return this.$store.state.dashboard_user.selected_user || {} },
|
selectedUser() { return this.$store.state.dashboard_user.selected_user || {} },
|
||||||
|
isEditMode() { return !!(this.selectedUser && this.selectedUser.User_ID) },
|
||||||
assignedProjects() { return this.selectedUser.projects || [] },
|
assignedProjects() { return this.selectedUser.projects || [] },
|
||||||
dialogsuccess() { return this.$store.state.dashboard_user.dialog_success },
|
dialogsuccess() { return this.$store.state.dashboard_user.dialog_success },
|
||||||
msgsuccess() { return this.$store.state.dashboard_user.msg_success },
|
msgsuccess() { return this.$store.state.dashboard_user.msg_success },
|
||||||
@@ -153,6 +155,22 @@ module.exports = {
|
|||||||
alert(resp.message || 'Gagal reset password')
|
alert(resp.message || 'Gagal reset password')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async removeUser() {
|
||||||
|
if (!this.isEditMode || !this.username) {
|
||||||
|
alert('Pilih user dulu')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!window.confirm('Hapus user ini?')) return
|
||||||
|
let resp = await this.$store.dispatch('dashboard_user/remove_user', {
|
||||||
|
username: this.username
|
||||||
|
})
|
||||||
|
if (resp.status == 'OK') {
|
||||||
|
this.newForm()
|
||||||
|
this.refreshList()
|
||||||
|
} else {
|
||||||
|
alert(resp.message || 'Gagal hapus user')
|
||||||
|
}
|
||||||
|
},
|
||||||
async assignProject() {
|
async assignProject() {
|
||||||
if (!this.username) {
|
if (!this.username) {
|
||||||
alert('Pilih atau isi username dulu')
|
alert('Pilih atau isi username dulu')
|
||||||
|
|||||||
@@ -109,6 +109,20 @@ export default {
|
|||||||
context.commit('update_dialog_success', true)
|
context.commit('update_dialog_success', true)
|
||||||
return resp
|
return resp
|
||||||
},
|
},
|
||||||
|
async remove_user(context, prm) {
|
||||||
|
context.commit('update_save_status', 1)
|
||||||
|
prm.token = one_token()
|
||||||
|
let resp = await api.remove_user(prm)
|
||||||
|
if (resp.status != 'OK') {
|
||||||
|
context.commit('update_save_status', 3)
|
||||||
|
context.commit('update_save_error_message', resp.message)
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
context.commit('update_save_status', 2)
|
||||||
|
context.commit('update_msg_success', (resp.data && resp.data.message) ? resp.data.message : 'User berhasil dihapus')
|
||||||
|
context.commit('update_dialog_success', true)
|
||||||
|
return resp
|
||||||
|
},
|
||||||
async assign_project(context, prm) {
|
async assign_project(context, prm) {
|
||||||
context.commit('update_save_status', 1)
|
context.commit('update_save_status', 1)
|
||||||
prm.token = one_token()
|
prm.token = one_token()
|
||||||
|
|||||||
Reference in New Issue
Block a user