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
fe51c5cb
Commit
fe51c5cb
authored
Feb 10, 2023
by
TTS Kieu Tuan Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add validate posts
parent
e8dd1c73
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
15 deletions
+45
-15
index.vue
pages/categories/index.vue
+1
-1
login.vue
pages/login.vue
+14
-9
index.vue
pages/posts/index.vue
+30
-5
No files found.
pages/categories/index.vue
View file @
fe51c5cb
...
@@ -389,7 +389,7 @@ export default {
...
@@ -389,7 +389,7 @@ export default {
v
=>
(
v
&&
v
.
length
<=
255
)
||
'
Name must be less than 255 characters
'
v
=>
(
v
&&
v
.
length
<=
255
)
||
'
Name must be less than 255 characters
'
],
],
requiredRules
:
[
requiredRules
:
[
v
=>
!!
v
||
'
This field is required
'
,
v
=>
!!
v
||
'
This field is required
'
],
],
numberRules
:
[
numberRules
:
[
v
=>
!!
v
||
'
This field is required
'
,
v
=>
!!
v
||
'
This field is required
'
,
...
...
pages/login.vue
View file @
fe51c5cb
...
@@ -109,10 +109,15 @@ export default {
...
@@ -109,10 +109,15 @@ export default {
this
.
password
=
''
this
.
password
=
''
this
.
checkbox
=
false
this
.
checkbox
=
false
},
},
async
login
()
{
async
login
()
{
try
{
try
{
const
resp
=
await
this
.
$axios
.
post
(
'
/login
'
,
const
resp
=
await
fetch
(
'
http://127.0.0.1:8000/api/login
'
,
{
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Accept
:
'
application/json
'
},
body
:
JSON
.
stringify
({
email
:
this
.
email
,
email
:
this
.
email
,
password
:
this
.
password
,
password
:
this
.
password
,
status
:
this
.
status
status
:
this
.
status
...
@@ -121,7 +126,7 @@ export default {
...
@@ -121,7 +126,7 @@ export default {
return
response
.
json
()
return
response
.
json
()
})
})
console
.
log
(
resp
.
status
)
console
.
log
(
resp
.
status
)
localStorage
.
setItem
(
'
token
'
,
resp
.
data
.
bearer_token
)
localStorage
.
setItem
(
'
token
'
,
resp
.
data
.
bearer_token
)
this
.
$auth
.
$storage
.
setUniversal
(
'
token
'
,
resp
.
data
.
bearer_token
)
this
.
$auth
.
$storage
.
setUniversal
(
'
token
'
,
resp
.
data
.
bearer_token
)
this
.
$auth
.
$storage
.
setUniversal
(
'
userName
'
,
resp
.
data
.
name
)
this
.
$auth
.
$storage
.
setUniversal
(
'
userName
'
,
resp
.
data
.
name
)
this
.
$auth
.
$storage
.
setUniversal
(
'
loggedIn
'
,
'
true
'
)
this
.
$auth
.
$storage
.
setUniversal
(
'
loggedIn
'
,
'
true
'
)
...
@@ -132,13 +137,13 @@ export default {
...
@@ -132,13 +137,13 @@ export default {
this
.
$router
.
push
(
'
home
'
)
this
.
$router
.
push
(
'
home
'
)
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
$toast
.
error
(
"
Username or Password not valid
"
,
{
this
.
$toast
.
error
(
'
Username or Password not valid
'
,
{
duration
:
2000
,
duration
:
2000
})
;
})
this
.
$router
.
push
(
"
/login
"
);
this
.
$router
.
push
(
'
/login
'
)
}
}
}
}
}
}
}
}
</
script
>
</
script
>
<
style
scoped
>
<
style
scoped
>
...
...
pages/posts/index.vue
View file @
fe51c5cb
...
@@ -68,9 +68,9 @@
...
@@ -68,9 +68,9 @@
</v-col>
</v-col>
<v-col
cols=
"12"
>
<v-col
cols=
"12"
>
<!-- <v-col v-for="(image, index) in sImages" :key="index" cols="12">
<!-- <v-col v-for="(image, index) in sImages" :key="index" cols="12">
<v-img :src="image"/> -->
<v-img :src="image"/>
</v-col>
-->
<v-img
<v-img
v-if=
"typeof sImages ==
=
'string'"
v-if=
"typeof sImages == 'string'"
:src=
"sImages"
:src=
"sImages"
/>
/>
</v-col>
</v-col>
...
@@ -95,6 +95,7 @@
...
@@ -95,6 +95,7 @@
v-model=
"dialog"
v-model=
"dialog"
persistent
persistent
max-width=
"600px"
max-width=
"600px"
lazy-validation
>
>
<v-card>
<v-card>
<v-card-title>
<v-card-title>
...
@@ -111,6 +112,7 @@
...
@@ -111,6 +112,7 @@
<v-text-field
<v-text-field
v-model=
"eTitle"
v-model=
"eTitle"
label=
"Title*"
label=
"Title*"
:rules=
"requiredRules"
required
required
/>
/>
</v-col>
</v-col>
...
@@ -123,6 +125,7 @@
...
@@ -123,6 +125,7 @@
item-text=
"name"
item-text=
"name"
item-value=
"id"
item-value=
"id"
label=
"Category"
label=
"Category"
:rules=
"requiredRules"
/>
/>
</v-col>
</v-col>
<v-col
cols=
"12"
>
<v-col
cols=
"12"
>
...
@@ -130,6 +133,7 @@
...
@@ -130,6 +133,7 @@
v-model=
"eContent"
v-model=
"eContent"
label=
"Content"
label=
"Content"
required
required
:rules=
"requiredRules"
/>
/>
</v-col>
</v-col>
<v-col
<v-col
...
@@ -141,6 +145,7 @@
...
@@ -141,6 +145,7 @@
item-text=
"name"
item-text=
"name"
item-value=
"id"
item-value=
"id"
label=
"Status"
label=
"Status"
:rules=
"requiredRules"
/>
/>
</v-col>
</v-col>
<v-col
cols=
"12"
>
<v-col
cols=
"12"
>
...
@@ -204,11 +209,13 @@
...
@@ -204,11 +209,13 @@
<v-divider
class=
"mx-4"
inset
vertical
/>
<v-divider
class=
"mx-4"
inset
vertical
/>
<v-spacer
/>
<v-spacer
/>
<v-toolbar-title>
<v-toolbar-title>
<!-- modal-create -->
<v-dialog
<v-dialog
v-model=
"dialog1"
v-model=
"dialog1"
persistent
persistent
max-width=
"600px"
max-width=
"600px"
enctype=
"multipart/form-data"
enctype=
"multipart/form-data"
lazy-validation
>
>
<template
#activator
="
{ on, attrs }">
<template
#activator
="
{ on, attrs }">
<v-btn
<v-btn
...
@@ -235,6 +242,7 @@
...
@@ -235,6 +242,7 @@
<v-text-field
<v-text-field
v-model=
"title"
v-model=
"title"
label=
"Title*"
label=
"Title*"
:rules=
"requiredRules"
required
required
/>
/>
</v-col>
</v-col>
...
@@ -247,12 +255,14 @@
...
@@ -247,12 +255,14 @@
item-text=
"name"
item-text=
"name"
item-value=
"id"
item-value=
"id"
label=
"Category"
label=
"Category"
:rules=
"requiredRules"
/>
/>
</v-col>
</v-col>
<v-col
cols=
"12"
>
<v-col
cols=
"12"
>
<v-textarea
<v-textarea
v-model=
"content"
v-model=
"content"
label=
"Content"
label=
"Content"
:rules=
"requiredRules"
required
required
/>
/>
</v-col>
</v-col>
...
@@ -265,6 +275,7 @@
...
@@ -265,6 +275,7 @@
item-text=
"name"
item-text=
"name"
item-value=
"id"
item-value=
"id"
label=
"Status"
label=
"Status"
:rules=
"requiredRules"
/>
/>
</v-col>
</v-col>
<v-col
cols=
"12"
>
<v-col
cols=
"12"
>
...
@@ -275,6 +286,7 @@
...
@@ -275,6 +286,7 @@
dense
dense
accept=
"image/*"
accept=
"image/*"
prepend-icon=
"mdi-camera"
prepend-icon=
"mdi-camera"
:rules=
"requiredRules"
@
change=
"fileSelected"
@
change=
"fileSelected"
/>
/>
</v-col>
</v-col>
...
@@ -428,7 +440,18 @@ export default {
...
@@ -428,7 +440,18 @@ export default {
status
:
''
,
status
:
''
,
created_at
:
''
,
created_at
:
''
,
updated_at
:
''
updated_at
:
''
}
},
requiredRules
:
[
v
=>
!!
v
||
'
This field is required
'
],
numberRules
:
[
v
=>
!!
v
||
'
This field is required
'
,
v
=>
v
>
0
||
'
value must be a positive integer
'
],
imageRules
:
[
v
=>
!!
v
||
'
Images is required
'
,
v
=>
(
v
&&
v
.
length
>
0
)
||
'
Images is required
'
]
}
}
},
},
computed
:
{
computed
:
{
...
@@ -618,6 +641,7 @@ export default {
...
@@ -618,6 +641,7 @@ export default {
this
.
eCategoryId
=
item
.
category_id
this
.
eCategoryId
=
item
.
category_id
this
.
eContent
=
item
.
content
this
.
eContent
=
item
.
content
this
.
eStatus
=
item
.
status
this
.
eStatus
=
item
.
status
this
.
eImages
=
[]
this
.
editedIndex
=
this
.
posts
.
indexOf
(
item
)
this
.
editedIndex
=
this
.
posts
.
indexOf
(
item
)
console
.
log
(
this
.
editedIndex
)
console
.
log
(
this
.
editedIndex
)
this
.
dialog
=
true
this
.
dialog
=
true
...
@@ -628,9 +652,10 @@ export default {
...
@@ -628,9 +652,10 @@ export default {
fd
.
append
(
'
title
'
,
this
.
eTitle
)
fd
.
append
(
'
title
'
,
this
.
eTitle
)
fd
.
append
(
'
category_id
'
,
this
.
eCategoryId
)
fd
.
append
(
'
category_id
'
,
this
.
eCategoryId
)
fd
.
append
(
'
content
'
,
this
.
eContent
)
fd
.
append
(
'
content
'
,
this
.
eContent
)
fd
.
append
(
'
images
'
,
this
.
eImages
)
fd
.
append
(
'
status
'
,
this
.
eStatus
)
fd
.
append
(
'
status
'
,
this
.
eStatus
)
if
(
typeof
this
.
eImages
!==
'
string
'
&&
this
.
eImages
!=
null
)
{
fd
.
append
(
'
images
'
,
this
.
eImages
)
}
const
currentPostIndex
=
this
.
editedIndex
const
currentPostIndex
=
this
.
editedIndex
this
.
$axios
this
.
$axios
.
post
(
.
post
(
...
...
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