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
eb3870a2
Commit
eb3870a2
authored
Jan 09, 2023
by
TTS Kieu Tuan Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add update user
parent
b0f0ef05
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
12 deletions
+79
-12
index.vue
pages/home/index.vue
+1
-1
user.vue
pages/home/user.vue
+1
-1
users.vue
pages/home/users.vue
+77
-10
No files found.
pages/home/index.vue
View file @
eb3870a2
...
@@ -17,7 +17,7 @@ import axios from "axios";
...
@@ -17,7 +17,7 @@ import axios from "axios";
import
VueAxios
from
"
vue-axios
"
;
import
VueAxios
from
"
vue-axios
"
;
import
Nav
from
"
@/components/Nav
"
;
import
Nav
from
"
@/components/Nav
"
;
import
Footer
from
"
@/components/
f
ooter
"
;
import
Footer
from
"
@/components/
F
ooter
"
;
export
default
{
export
default
{
components
:
{
Nav
},
components
:
{
Nav
},
...
...
pages/home/user.vue
View file @
eb3870a2
...
@@ -167,7 +167,7 @@
...
@@ -167,7 +167,7 @@
import
Nav
from
"
@/components/Nav
"
;
import
Nav
from
"
@/components/Nav
"
;
import
Navigation
from
"
@/components/Navigation
"
;
import
Navigation
from
"
@/components/Navigation
"
;
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
import
notification
from
"
@/components/
n
otification
"
;
import
notification
from
"
@/components/
N
otification
"
;
import
Toasted
from
'
vue-toasted
'
;
import
Toasted
from
'
vue-toasted
'
;
import
{
ModalPlugin
}
from
'
bootstrap-vue
'
;
import
{
ModalPlugin
}
from
'
bootstrap-vue
'
;
...
...
pages/home/users.vue
View file @
eb3870a2
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
</b-breadcrumb>
</b-breadcrumb>
<div
style=
"float: right"
>
<div
style=
"float: right"
>
<b-button
v-b-modal
.
modal-login
>
New User
</b-button>
<b-button
v-b-modal
.
modal-login
>
New User
</b-button>
<!-- modal create user -->
<b-modal
id=
"modal-login"
title=
"Create User"
class=
"modal fade"
>
<b-modal
id=
"modal-login"
title=
"Create User"
class=
"modal fade"
>
<Notification
:message=
"error"
v-if=
"error"
/>
<Notification
:message=
"error"
v-if=
"error"
/>
<p
class=
"my-4"
>
<p
class=
"my-4"
>
...
@@ -44,11 +44,7 @@
...
@@ -44,11 +44,7 @@
v-model=
"password"
v-model=
"password"
required
required
/>
/>
<!--
<div
class=
"button"
>
<button
class=
"w-30 btn btn-sm btn-primary"
type=
"submit"
>
Create
</button>
</div>
-->
</form>
</form>
</p>
</p>
<template
#modal-footer
>
<template
#modal-footer
>
...
@@ -56,6 +52,44 @@
...
@@ -56,6 +52,44 @@
<button
@
click=
"createUser"
v-b-modal
.
modal-close_visit
class=
"btn btn-success btn-sm m-1"
>
Submit
</button>
<button
@
click=
"createUser"
v-b-modal
.
modal-close_visit
class=
"btn btn-success btn-sm m-1"
>
Submit
</button>
</
template
>
</
template
>
</b-modal>
</b-modal>
<!-- 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
<v-data-table
:headers=
"headers"
:headers=
"headers"
...
@@ -153,7 +187,7 @@
...
@@ -153,7 +187,7 @@
</v-toolbar>
</v-toolbar>
</template>
</template>
<
template
v-slot:item.actions=
"{ item }"
>
<
template
v-slot:item.actions=
"{ item }"
>
<v-icon
small
class=
"mr-2"
@
click=
"
editItem(id)
"
:id =
"item.id"
>
mdi-pencil
</v-icon>
<v-icon
small
class=
"mr-2"
@
click=
"
editUser(item.id);
"
:id =
"item.id"
>
mdi-pencil
</v-icon>
<v-icon
small
@
click=
"deleteUser(item.id)"
:id =
"item.id"
>
mdi-delete
</v-icon>
<v-icon
small
@
click=
"deleteUser(item.id)"
:id =
"item.id"
>
mdi-delete
</v-icon>
</
template
>
</
template
>
<
template
v-slot:no-data
>
<
template
v-slot:no-data
>
...
@@ -167,7 +201,7 @@
...
@@ -167,7 +201,7 @@
import
Nav
from
"
@/components/Nav
"
;
import
Nav
from
"
@/components/Nav
"
;
import
Navigation
from
"
@/components/Navigation
"
;
import
Navigation
from
"
@/components/Navigation
"
;
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
import
notification
from
"
@/components/
n
otification
"
;
import
notification
from
"
@/components/
N
otification
"
;
import
Toasted
from
'
vue-toasted
'
;
import
Toasted
from
'
vue-toasted
'
;
import
{
ModalPlugin
}
from
'
bootstrap-vue
'
;
import
{
ModalPlugin
}
from
'
bootstrap-vue
'
;
...
@@ -200,6 +234,10 @@ export default {
...
@@ -200,6 +234,10 @@ export default {
{
text
:
'
Actions
'
,
value
:
'
actions
'
,
sortable
:
false
},
{
text
:
'
Actions
'
,
value
:
'
actions
'
,
sortable
:
false
},
],
],
users
:
[],
users
:
[],
eID
:
''
,
eEmail
:
''
,
eName
:
''
,
ePassword
:
''
,
message
:
[],
message
:
[],
editedIndex
:
-
1
,
editedIndex
:
-
1
,
editedItem
:
{
editedItem
:
{
...
@@ -298,7 +336,9 @@ export default {
...
@@ -298,7 +336,9 @@ export default {
})
})
.
then
(
response
=>
{
.
then
(
response
=>
{
// $bvModal.hide('modal-login');
// $bvModal.hide('modal-login');
self
.
$toast
.
success
(
'
User created successfully!
'
);
self
.
$toast
.
success
(
'
User created successfully!
'
,{
duration
:
3000
});
console
.
log
(
response
);
console
.
log
(
response
);
})
})
.
catch
(
errors
=>
{
.
catch
(
errors
=>
{
...
@@ -312,18 +352,45 @@ export default {
...
@@ -312,18 +352,45 @@ export default {
},
},
deleteUser
(
userID
)
{
deleteUser
(
userID
)
{
if
(
confirm
(
"
Do you really want to delete?
"
)){
try
{
try
{
axios
axios
.
delete
(
`http://127.0.0.1:8000/api/users/
${
userID
}
`
)
.
delete
(
`http://127.0.0.1:8000/api/users/
${
userID
}
`
)
}
catch
(
error
){
}
catch
(
error
){
console
.
log
(
error
)
console
.
log
(
error
)
}
}
}
},
},
editUser
(
userID
)
{
editUser
(
userID
)
{
this
.
$bvModal
.
show
(
'
modal-edit
'
);
this
.
eID
=
userID
;
console
.
log
(
this
?.
eID
);
},
updateUser
(
userID
)
{
const
self
=
this
console
.
log
(
this
.
eName
);
console
.
log
(
this
.
eEmail
);
console
.
log
(
this
?.
eID
);
try
{
axios
.
put
(
`http://127.0.0.1:8000/api/users/
${
this
?.
eID
}
`,{
email: this.eEmail,
password: this.ePassword,
name:this.eName,} )
.then(response => {
self.$toast.success('User updated successfully!',{
duration: 3000
});
console.log(response);
})
} catch(error){
console.log(error)
}
}
}
},
},
created() {
created() {
this.getUsers();
this.getUsers();
...
...
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