Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
K
kiaisoft_tuananh_nuxt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TTS Tran Viet Anh
kiaisoft_tuananh_nuxt
Commits
5c888d06
Commit
5c888d06
authored
Jan 31, 2023
by
TTS Kieu Tuan Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add base URL + navbar
parent
af9a149c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
292 additions
and
239 deletions
+292
-239
Navbar.vue
components/Navbar.vue
+14
-43
nuxt.config.js
nuxt.config.js
+4
-1
index.vue
pages/users/index.vue
+274
-195
No files found.
components/Navbar.vue
View file @
5c888d06
<
template
>
<
template
>
<!--
<div>
<b-navbar
toggleable=
"lg"
type=
"dark"
variant=
"info"
style=
"background-color: #6f2ca6 !important"
>
<SideBar
/>
<b-navbar-toggle
target=
"nav-collapse"
></b-navbar-toggle>
-->
<!--
<b-collapse
id=
"nav-collapse"
is-nav
>
<b-navbar-nav>
<b-nav-item
href=
"/users"
>
USER
</b-nav-item>
<b-nav-item
href=
"/categories"
>
CATEGORY
</b-nav-item>
<b-nav-item
href=
"/products"
>
PRODUCT
</b-nav-item>
<b-nav-item
href=
"/posts"
>
POST
</b-nav-item>
</b-navbar-nav>
-->
<!-- Right aligned nav items -->
<!--
<b-navbar-nav
class=
"ml-auto"
>
<b-nav-item-dropdown
right
>
-->
<!-- Using 'button-content' slot -->
<!--
<template
#button-content
>
<em>
{{
$auth
.
$storage
.
getUniversal
(
"
userName
"
)
}}
</em>
</
template
>
<b-dropdown-item
href=
"#"
>
Profile
</b-dropdown-item>
<b-dropdown-item
href=
"#"
@
click=
"logout"
>
Sign Out
</b-dropdown-item>
</b-nav-item-dropdown>
</b-navbar-nav>
</b-collapse>
</b-navbar>
</div>
-->
<div>
<div>
<v-toolbar
<v-toolbar
dark
dark
prominent
prominent
src=
"https://cdn.vuetifyjs.com/images/backgrounds/vbanner.jpg"
src=
"https://cdn.vuetifyjs.com/images/backgrounds/vbanner.jpg"
>
>
<v-app-bar-nav-icon
></v-app-bar-nav-icon
>
<v-app-bar-nav-icon
/
>
<v-toolbar-title>
<v-toolbar-title>
<v-btn
href=
"/users"
>
<v-btn
href=
"/users"
>
...
@@ -58,7 +29,7 @@
...
@@ -58,7 +29,7 @@
</v-btn>
</v-btn>
</v-toolbar-title>
</v-toolbar-title>
<v-spacer
></v-spacer
>
<v-spacer
/
>
<v-toolbar-title>
{{
$auth
.
$storage
.
getUniversal
(
"
userName
"
)
}}
</v-toolbar-title>
<v-toolbar-title>
{{
$auth
.
$storage
.
getUniversal
(
"
userName
"
)
}}
</v-toolbar-title>
...
...
nuxt.config.js
View file @
5c888d06
...
@@ -52,7 +52,10 @@ export default {
...
@@ -52,7 +52,10 @@ export default {
// Axios module configuration: https://go.nuxtjs.dev/config-axios
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios
:
{
axios
:
{
// Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
// Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
baseURL
:
'
/
'
,
baseURL
:
'
http://127.0.0.1:8000/api/
'
,
debug
:
false
,
proxyHeaders
:
true
,
credentials
:
false
,
},
},
// Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify
// Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify
...
...
pages/users/index.vue
View file @
5c888d06
<
template
>
<
template
>
<v-app>
<div>
<div>
<div
/>
<div>
<div>
</div>
<v-breadcrumbs
:items=
"items"
>
<b-breadcrumb>
<template
#divider
>
<b-breadcrumb-item
href=
"/home"
>
<v-icon>
mdi-chevron-right
</v-icon>
<b-icon
icon=
"house-fill"
scale=
"1.25"
shift-v=
"1.25"
aria-hidden=
"true"
></b-icon>
Home
</b-breadcrumb-item>
<b-breadcrumb-item
href=
"/home/users"
>
User
</b-breadcrumb-item>
</b-breadcrumb>
<div
style=
"float: right"
>
<b-button
v-b-modal
.
modal-login
class=
"text-white"
>
New User
</b-button>
<!-- modal create user -->
<b-modal
id=
"modal-login"
title=
"Create User"
class=
"modal fade"
>
<Notification
:message=
"error"
v-if=
"error"
/>
<p
class=
"my-4"
>
<form
@
submit.prevent=
"createUser"
>
<label>
Name :
</label>
<input
type=
"text"
class=
"form-control mb-2"
placeholder=
"name"
v-model=
"name"
max=
"255"
min=
"1"
required
/>
<label>
Email :
</label>
<input
type=
"email"
class=
"form-control mb-2"
placeholder=
"Email"
v-model=
"email"
required
/>
<label>
Password :
</label>
<input
type=
"password"
class=
"form-control mb-2"
placeholder=
"password"
v-model=
"password"
required
/>
</form>
</p>
<template
#modal-footer
>
<button
v-b-modal
.
modal-close_visit
@
click=
"$bvModal.hide('modal-login')"
class=
"btn btn-danger btn-sm m-1"
>
Close
</button>
<button
@
click=
"createUser"
v-b-modal
.
modal-close_visit
class=
"btn btn-success btn-sm m-1"
>
Submit
</button>
</
template
>
</
template
>
</b-modal>
</v-breadcrumbs>
<!-- modal edit user -->
<b-modal
id=
"modal-edit"
title=
"Edit User"
class=
"modal fade"
>
<p
class=
"my-4"
>
<form
@
submit.prevent=
""
>
<label>
Name :
</label>
<input
type=
"text"
class=
"form-control mb-2"
placeholder=
"name"
v-model=
"eName"
max=
"255"
min=
"1"
required
/>
<label>
Email :
</label>
<input
type=
"email"
class=
"form-control mb-2"
placeholder=
"Email"
v-model=
"eEmail"
required
/>
<label>
Password :
</label>
<input
type=
"password"
class=
"form-control mb-2"
placeholder=
"password"
v-model=
"ePassword"
required
/>
</form>
</p>
<
template
#modal-footer
>
<button
v-b-modal
.
modal-close_visit
@
click=
"$bvModal.hide('modal-edit')"
class=
"btn btn-danger btn-sm m-1"
>
Close
</button>
<button
@
click=
"updateUser(this?.eID)"
v-b-modal
.
modal-close_visit
class=
"btn btn-success btn-sm m-1"
>
Submit
</button>
</
template
>
</b-modal>
</div>
</div>
<v-data-table
:headers=
"headers"
:items=
"users"
sort-by=
"calories"
class=
"elevation-1"
>
<div
style=
"float: right"
>
<
template
v-slot:top
>
<v-dialog
<v-toolbar
flat
>
v-model=
"dialog1"
<v-toolbar-title>
User Manage
</v-toolbar-title>
persistent
<v-divider
class=
"mx-4"
inset
vertical
></v-divider>
max-width=
"600px"
<v-spacer></v-spacer>
@
submit.prevent=
"createUser"
<v-dialog
v-model=
"dialog"
max-width=
"500px"
>
>
<template
v-slot:activator=
"
{ on, attrs }">
<
template
#activator
="{
on
,
attrs
}"
>
<!-- modal create user -->
<v-btn
color=
"primary"
dark
v-bind=
"attrs"
v-on=
"on"
>
New USER
</v-btn>
</
template
>
</
template
>
<v-card>
<v-card>
<v-card-title>
<v-card-title>
<span
class=
"text-h5"
>
{{ formTitle }}
</span>
<span
class=
"text-h5"
>
User Profile
</span>
</v-card-title>
</v-card-title>
<v-card-text>
<v-card-text>
<v-container>
<v-container>
<v-row>
<v-row>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
<v-col
<v-text-field
v-model=
"editedItem.name"
label=
"name"
></v-text-field>
cols=
"12"
sm=
"6"
md=
"4"
>
<v-text-field
v-model=
"name"
label=
"Legal name*"
required
/>
</v-col>
</v-col>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
<v-col
cols=
"12"
>
<v-text-field
v-model=
"editedItem.id"
label=
"id"
></v-text-field>
<v-text-field
v-model=
"email"
label=
"Email*"
required
/>
</v-col>
</v-col>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
<v-col
cols=
"12"
>
<v-text-field
v-model=
"editedItem.email"
label=
"email"
></v-text-field>
<v-text-field
</v-col>
v-model=
"password"
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
label=
"Password*"
<v-text-field
v-model=
"editedItem.created_at"
label=
"created_at"
></v-text-field>
type=
"password"
</v-col>
required
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
/>
<v-text-field
v-model=
"editedItem.updated_at"
label=
"updated_at"
></v-text-field>
</v-col>
</v-col>
</v-row>
</v-row>
</v-container>
</v-container>
<small>
*indicates required field
</small>
</v-card-text>
</v-card-text>
<v-card-actions>
<v-card-actions>
<v-spacer></v-spacer>
<v-spacer
/>
<v-btn
color=
"blue darken-1"
text
@
click=
"close"
>
<v-btn
Cancel
color=
"blue darken-1"
text
@
click=
"dialog1 = false"
>
Close
</v-btn>
<v-btn
color=
"blue darken-1"
text
type=
"submit"
@
click=
"dialog1 = false; createUser();"
>
Save
</v-btn>
</v-btn>
<v-btn
color=
"blue darken-1"
text
@
click=
"save"
>
Save
</v-btn>
</v-card-actions>
</v-card-actions>
</v-card>
</v-card>
</v-dialog>
</v-dialog>
<v-dialog
v-model=
"dialogDelete"
max-width=
"500px"
>
</div>
<!-- modal-create -->
<v-dialog
v-model=
"dialog2"
persistent
max-width=
"600px"
>
<v-card>
<v-card>
<v-card-title
class=
"text-h5"
>
Are you sure you want to delete this item?
</v-card-title>
<v-card-title>
<span
class=
"text-h5"
>
User Edit
</span>
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
>
<v-text-field
v-model=
"eName"
label=
"Legal name*"
required
/>
</v-col>
<v-col
cols=
"12"
>
<v-text-field
v-model=
"eEmail"
label=
"Email*"
required
/>
</v-col>
<v-col
cols=
"12"
>
<v-text-field
v-model=
"ePassword"
label=
"Password*"
type=
"password"
required
/>
</v-col>
</v-row>
</v-container>
<small>
*indicates required field
</small>
</v-card-text>
<v-card-actions>
<v-card-actions>
<v-spacer></v-spacer>
<v-spacer
/>
<v-btn
color=
"blue darken-1"
text
@
click=
"closeDelete"
>
Cancel
</v-btn>
<v-btn
<v-btn
color=
"blue darken-1"
text
@
click=
"deleteItemConfirm"
>
OK
</v-btn>
color=
"blue darken-1"
<v-spacer></v-spacer>
text
@
click=
"dialog2 = false"
>
Close
</v-btn>
<v-btn
color=
"blue darken-1"
text
type=
"submit"
@
click=
"dialog2 = false; updateUser();"
>
Save
</v-btn>
</v-card-actions>
</v-card-actions>
</v-card>
</v-card>
</v-dialog>
</v-dialog>
<v-data-table
:headers=
"headers"
:items=
"users"
sort-by=
"calories"
class=
"elevation-1"
>
<
template
#top
>
<v-toolbar
flat
>
<v-toolbar-title>
User Manage
</v-toolbar-title>
<v-divider
class=
"mx-4"
inset
vertical
/>
<v-spacer
/>
</v-toolbar>
</v-toolbar>
</
template
>
</
template
>
<
template
v-slot:item.actions=
"{ item }"
>
<
template
#item.actions=
"{ item }"
>
<v-icon
small
class=
"mr-2"
@
click=
"editUser(item)"
:id=
"item.id"
>
mdi-pencil
</v-icon>
<v-icon
:id=
"item.id"
small
class=
"mr-2"
@
click=
"dialog2 = true; editUser(item);"
>
<v-icon
small
@
click=
"deleteUser(item.id, item)"
:id=
"item.id"
>
mdi-delete
</v-icon>
mdi-pencil
</v-icon>
<v-icon
:id=
"item.id"
small
@
click=
"deleteUser(item.id, item)"
>
mdi-delete
</v-icon>
</
template
>
</
template
>
<
template
v-slot:no-data
>
<
template
#no-data
>
<v-btn
color=
"primary"
@
click=
"initialize"
>
Reset
</v-btn>
<v-btn
color=
"primary"
@
click=
"initialize"
>
Reset
</v-btn>
</
template
>
</
template
>
</v-data-table>
</v-data-table>
</div>
</div>
</v-app>
</template>
</template>
<
script
>
<
script
>
export
default
{
export
default
{
...
@@ -127,21 +182,35 @@ export default {
...
@@ -127,21 +182,35 @@ export default {
name
:
''
,
name
:
''
,
password
:
''
,
password
:
''
,
error
:
''
,
error
:
''
,
dialog
:
false
,
dialog1
:
false
,
dialog2
:
false
,
dialogDelete
:
false
,
dialogDelete
:
false
,
headers
:
[
headers
:
[
{
{
text
:
'
Name
'
,
text
:
'
Name
'
,
align
:
'
start
'
,
align
:
'
start
'
,
sortable
:
false
,
sortable
:
false
,
value
:
'
name
'
,
value
:
'
name
'
},
},
{
text
:
'
id
'
,
value
:
'
id
'
},
{
text
:
'
id
'
,
value
:
'
id
'
},
{
text
:
'
email
'
,
value
:
'
email
'
},
{
text
:
'
email
'
,
value
:
'
email
'
},
{
text
:
'
status
'
,
value
:
'
id
'
,
sortable
:
false
},
{
text
:
'
status
'
,
value
:
'
id
'
,
sortable
:
false
},
{
text
:
'
created_at
'
,
value
:
'
created_at
'
},
{
text
:
'
created_at
'
,
value
:
'
created_at
'
},
{
text
:
'
updated_at
'
,
value
:
'
updated_at
'
},
{
text
:
'
updated_at
'
,
value
:
'
updated_at
'
},
{
text
:
'
Actions
'
,
value
:
'
actions
'
,
sortable
:
false
},
{
text
:
'
Actions
'
,
value
:
'
actions
'
,
sortable
:
false
}
],
items
:
[
{
icon
:
'
mdi-home
'
,
text
:
'
Home
'
,
disabled
:
false
,
href
:
'
/home
'
},
{
text
:
'
User
'
,
disabled
:
false
,
href
:
'
/users
'
}
],
],
users
:
[],
users
:
[],
eIndex
:
[],
eIndex
:
[],
...
@@ -156,7 +225,7 @@ export default {
...
@@ -156,7 +225,7 @@ export default {
id
:
''
,
id
:
''
,
email
:
''
,
email
:
''
,
created_at
:
''
,
created_at
:
''
,
updated_at
:
''
,
updated_at
:
''
},
},
defaultItem
:
{
defaultItem
:
{
name
:
''
,
name
:
''
,
...
@@ -164,61 +233,61 @@ export default {
...
@@ -164,61 +233,61 @@ export default {
email
:
''
,
email
:
''
,
status
:
''
,
status
:
''
,
created_at
:
''
,
created_at
:
''
,
updated_at
:
''
,
updated_at
:
''
}
,
}
}
}
},
},
computed
:
{
computed
:
{
formTitle
()
{
formTitle
()
{
return
this
.
editedIndex
===
-
1
?
'
New Item
'
:
'
Edit Item
'
return
this
.
editedIndex
===
-
1
?
'
New Item
'
:
'
Edit Item
'
}
,
}
},
},
watch
:
{
watch
:
{
dialog
(
val
)
{
dialog
(
val
)
{
val
||
this
.
close
()
val
||
this
.
close
()
},
},
dialogDelete
(
val
)
{
dialogDelete
(
val
)
{
val
||
this
.
closeDelete
()
val
||
this
.
closeDelete
()
}
},
},
},
created
()
{
created
()
{
this
.
initialize
()
this
.
initialize
()
this
.
getUsers
()
this
.
getUsers
()
},
},
methods
:
{
methods
:
{
initialize
()
{
initialize
()
{
this
.
users
=
[]
,
this
.
users
=
[]
this
.
editedItem
=
{}
this
.
editedItem
=
{}
},
},
editItem
(
item
)
{
editItem
(
item
)
{
this
.
editedIndex
=
this
.
users
.
indexOf
(
item
)
this
.
editedIndex
=
this
.
users
.
indexOf
(
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
dialog
=
true
this
.
dialog
=
true
},
},
deleteItem
(
item
)
{
deleteItem
(
item
)
{
this
.
editedIndex
=
this
.
users
.
indexOf
(
item
)
this
.
editedIndex
=
this
.
users
.
indexOf
(
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
editedItem
=
Object
.
assign
({},
item
)
this
.
dialogDelete
=
true
this
.
dialogDelete
=
true
},
},
deleteItemConfirm
()
{
deleteItemConfirm
()
{
this
.
users
.
splice
(
this
.
editedIndex
,
1
)
this
.
users
.
splice
(
this
.
editedIndex
,
1
)
this
.
closeDelete
()
this
.
closeDelete
()
},
},
close
()
{
close
()
{
this
.
dialog
=
false
this
.
dialog
=
false
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
this
.
editedIndex
=
-
1
this
.
editedIndex
=
-
1
})
})
},
},
closeDelete
()
{
closeDelete
()
{
this
.
dialogDelete
=
false
this
.
dialogDelete
=
false
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
this
.
editedItem
=
Object
.
assign
({},
this
.
defaultItem
)
this
.
editedIndex
=
-
1
this
.
editedIndex
=
-
1
})
})
},
},
save
()
{
save
()
{
if
(
this
.
editedIndex
>
-
1
)
{
if
(
this
.
editedIndex
>
-
1
)
{
Object
.
assign
(
this
.
users
[
this
.
editedIndex
],
this
.
editedItem
)
Object
.
assign
(
this
.
users
[
this
.
editedIndex
],
this
.
editedItem
)
}
else
{
}
else
{
...
@@ -226,34 +295,35 @@ export default {
...
@@ -226,34 +295,35 @@ export default {
}
}
this
.
close
()
this
.
close
()
},
},
getUsers
()
{
getUsers
()
{
this
.
$axios
this
.
$axios
.
get
(
'
/users/
'
,{
.
get
(
'
/users/
'
,
{
headers
:
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
},
}
})
})
.
then
(
(
response
)
=>
(
this
.
users
=
response
.
data
.
data
.
data
))
.
then
(
response
=>
(
this
.
users
=
response
.
data
.
data
.
data
))
.
catch
(
function
(
error
)
{
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
})
})
},
},
createUser
()
{
createUser
()
{
const
self
=
this
const
self
=
this
this
.
$axios
this
.
$axios
.
post
(
'
/users/
'
,{
.
post
(
'
/users/
'
,
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
},
email
:
this
.
email
,
email
:
this
.
email
,
password
:
this
.
password
,
password
:
this
.
password
,
name
:
this
.
name
,
name
:
this
.
name
})
},
{
.
then
(
response
=>
{
headers
:
{
// $bvModal.hide('modal-login');
'
Content-Type
'
:
'
application/json
'
,
this
.
$bvModal
.
hide
(
'
modal-login
'
)
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
self
.
$toast
.
success
(
'
User created successfully!
'
,{
}
}
)
.
then
((
response
)
=>
{
self
.
$toast
.
success
(
'
User created successfully!
'
,
{
duration
:
3000
duration
:
3000
})
})
console
.
log
(
response
)
console
.
log
(
response
)
...
@@ -261,66 +331,75 @@ export default {
...
@@ -261,66 +331,75 @@ export default {
console
.
log
(
this
.
editedItem
)
console
.
log
(
this
.
editedItem
)
this
.
users
.
push
(
this
.
editedItem
)
this
.
users
.
push
(
this
.
editedItem
)
})
})
.
catch
(
errors
=>
{
.
catch
((
errors
)
=>
{
this
.
$bvModal
.
hide
(
'
modal-login
'
)
this
.
$bvModal
.
hide
(
'
modal-login
'
)
console
.
log
(
errors
.
response
.
data
.
message
)
console
.
log
(
errors
.
response
.
data
.
message
)
this
.
message
=
errors
.
response
.
data
.
message
this
.
message
=
errors
.
response
.
data
.
message
self
.
$toast
.
error
(
'
something went wrong while trying create!
'
,
{
self
.
$toast
.
error
(
'
something went wrong while trying create!
'
,
{
duration
:
3000
duration
:
3000
})
})
})
})
},
},
deleteUser
(
userID
,
index
)
{
deleteUser
(
userID
,
index
)
{
const
self
=
this
const
self
=
this
this
.
editedIndex
=
this
.
users
.
indexOf
(
index
)
this
.
editedIndex
=
this
.
users
.
indexOf
(
index
)
if
(
confirm
(
"
Do you really want to delete?
"
))
{
if
(
confirm
(
'
Do you really want to delete?
'
))
{
try
{
try
{
this
.
$axios
this
.
$axios
.
delete
(
`/users/
${
userID
}
`
)
.
delete
(
`/users/
${
userID
}
`
)
.
then
(
response
=>
{
.
then
((
response
)
=>
{
console
.
log
(
response
.
data
)
console
.
log
(
response
.
data
)
this
.
users
.
splice
(
this
.
editedIndex
,
1
)
this
.
users
.
splice
(
this
.
editedIndex
,
1
)
self
.
$toast
.
success
(
'
User deleted successfully!
'
,
{
self
.
$toast
.
success
(
'
User deleted successfully!
'
,
{
duration
:
3000
duration
:
3000
})
})
})
})
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
}
}
}
}
},
},
editUser
(
user
)
{
editUser
(
user
)
{
this
.
$bvModal
.
show
(
'
modal-edit
'
)
this
.
eID
=
user
.
id
this
.
eID
=
user
.
id
this
.
eEmail
=
user
.
email
this
.
eEmail
=
user
.
email
this
.
eName
=
user
.
name
this
.
eName
=
user
.
name
this
.
editedIndex
=
this
.
users
.
indexOf
(
user
)
this
.
editedIndex
=
this
.
users
.
indexOf
(
user
)
console
.
log
(
this
?.
eID
)
console
.
log
(
this
?.
eID
)
},
},
updateUser
(
userID
)
{
updateUser
(
userID
)
{
const
self
=
this
const
self
=
this
console
.
log
(
this
.
eName
)
console
.
log
(
this
.
eName
)
console
.
log
(
this
.
eEmail
)
console
.
log
(
this
.
eEmail
)
console
.
log
(
this
?.
eID
)
console
.
log
(
this
?.
eID
)
try
{
this
.
$axios
this
.
$axios
.
put
(
`/users/
${
this
?.
eID
}
`,{
.
put
(
`/users/
${
this
?.
eID
}
`,
{
email: this.eEmail,
email: this.eEmail,
password: this.ePassword,
password: this.ePassword,
name:this.eName,} )
name: this.eName
.then(response => {
},
self.$toast.success('User updated successfully!',{
{
headers: {
'Content-Type': 'application/json',
Authorization: `
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)}
`
}
}
)
.then((response) => {
self.$toast.success('User updated successfully!', {
duration: 3000
duration: 3000
})
})
console.log(response)
console.log(response)
this.editedItem = response.data.data
this.editedItem = response.data.data
this.$bvModal.hide('modal-edit')
Object.assign(this.users[this.editedIndex], this.editedItem)
Object.assign(this.users[this.editedIndex], this.editedItem)
})
})
} catch(error)
{
.catch((error) =>
{
console.log(error)
console.log(error)
self.$toast.error('something went wrong while trying update!', {
duration: 3000
})
})
}
}
}
}
},
}
}
</
script
>
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment