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
2f21fd36
Commit
2f21fd36
authored
Dec 28, 2022
by
TTS Kieu Tuan Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix layouts
parent
2250c2ba
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
222 additions
and
106 deletions
+222
-106
nav.vue
components/nav.vue
+7
-1
notification.vue
components/notification.vue
+18
-18
sidebar.vue
components/sidebar.vue
+46
-0
web.js
middleware/web.js
+2
-2
package-lock.json
package-lock.json
+62
-1
index.vue
pages/home/index.vue
+2
-2
index.vue
pages/index.vue
+59
-59
register.vue
pages/register.vue
+26
-23
No files found.
components/nav.vue
View file @
2f21fd36
<
template
>
<div>
<b-navbar
toggleable=
"lg"
type=
"dark"
variant=
"info"
>
<
b-navbar-brand
href=
"#"
>
NavBar
</b-navbar-brand
>
<
sidebar
/
>
<b-navbar-toggle
target=
"nav-collapse"
></b-navbar-toggle>
...
...
@@ -49,7 +49,13 @@ export default {
name
:
"
nav
"
,
};
</
script
>
<
script
>
import
Sidebar
from
"
@/components/sidebar
"
;
export
default
{
components
:
{
sidebar
},
};
</
script
>
<
script
>
const
token_access
=
localStorage
.
getItem
(
"
token
"
);
export
default
{
...
...
components/notification.vue
View file @
2f21fd36
<
template
>
<div
class=
"notification is-danger bg-danger"
>
{{
message
}}
</div>
</
template
>
<
style
>
.notification
{
padding
:
11px
;
margin
:
10px
0px
;
}
</
style
>
<
script
>
export
default
{
name
:
'
Notification
'
,
props
:
[
'
message
'
]
}
</
script
>
\ No newline at end of file
<div
class=
"notification is-danger bg-danger"
>
{{
message
}}
</div>
</
template
>
<
style
>
.notification
{
padding
:
11px
;
margin
:
10px
0px
;
}
</
style
>
<
script
>
export
default
{
name
:
"
Notification
"
,
props
:
[
"
message
"
],
};
</
script
>
components/sidebar.vue
0 → 100644
View file @
2f21fd36
<
template
>
<div>
<b-button
v-b-toggle
.
sidebar-backdrop
>
More
</b-button>
<b-sidebar
id=
"sidebar-backdrop"
title=
"Sidebar with backdrop"
:backdrop-variant=
"variant"
backdrop
shadow
>
<div
class=
"px-3 py-2"
>
<b-form-group
label=
"Backdrop variant"
label-for=
"backdrop-variant"
>
<b-form-select
id=
"backdrop-variant"
v-model=
"variant"
:options=
"variants"
></b-form-select>
</b-form-group>
</div>
</b-sidebar>
</div>
</
template
>
<
script
>
export
default
{
name
:
"
sidebar
"
,
};
</
script
>
<
script
>
export
default
{
data
()
{
return
{
variant
:
'
dark
'
,
variants
:
[
'
transparent
'
,
'
white
'
,
'
light
'
,
'
dark
'
,
'
primary
'
,
'
secondary
'
,
'
success
'
,
'
danger
'
,
'
warning
'
,
'
info
'
,
]
}
}
}
</
script
>
\ No newline at end of file
middleware/web.js
View file @
2f21fd36
const
token_access
=
localStorage
.
getItem
(
'
token
'
);
export
default
function
()
{
export
default
function
(
{
redirect
}
)
{
if
(
!
token_access
)
{
// this.$router.push('/')
console
.
log
(
'
[LOG]: running ...
'
)
console
.
log
(
'
[LOG]: running ...
'
)
;
}
}
\ No newline at end of file
package-lock.json
View file @
2f21fd36
...
...
@@ -9,8 +9,9 @@
"version"
:
"1.0.0"
,
"license"
:
"ISC"
,
"dependencies"
:
{
"@nuxtjs/auth"
:
"^4.9.1"
,
"@nuxtjs/auth-next"
:
"5.0.0-1667386184.dfbbb54"
,
"@nuxtjs/axios"
:
"^5.
0.0
"
,
"@nuxtjs/axios"
:
"^5.
13.6
"
,
"axios"
:
"^1.2.1"
,
"bootstrap"
:
"^4.6.2"
,
"bootstrap-vue"
:
"^2.23.1"
,
...
...
@@ -2383,6 +2384,21 @@
"webpackbar"
:
"^4.0.0"
}
},
"node_modules/@nuxtjs/auth"
:
{
"version"
:
"4.9.1"
,
"resolved"
:
"https://registry.npmjs.org/@nuxtjs/auth/-/auth-4.9.1.tgz"
,
"integrity"
:
"sha512-h5VZanq2+P47jq3t0EnsZv800cg/ufOPC6JqvcyeDFJM99p58jHSODAjDuePo3PrZxd8hovMk7zusU5lOHgjvQ=="
,
"dependencies"
:
{
"@nuxtjs/axios"
:
"^5.9.5"
,
"body-parser"
:
"^1.19.0"
,
"consola"
:
"^2.11.3"
,
"cookie"
:
"^0.4.0"
,
"is-https"
:
"^1.0.0"
,
"js-cookie"
:
"^2.2.1"
,
"lodash"
:
"^4.17.15"
,
"nanoid"
:
"^2.1.11"
}
},
"node_modules/@nuxtjs/auth-next"
:
{
"version"
:
"5.0.0-1667386184.dfbbb54"
,
"resolved"
:
"https://registry.npmjs.org/@nuxtjs/auth-next/-/auth-next-5.0.0-1667386184.dfbbb54.tgz"
,
...
...
@@ -7082,6 +7098,11 @@
"node"
:
">=0.10.0"
}
},
"node_modules/is-https"
:
{
"version"
:
"1.0.0"
,
"resolved"
:
"https://registry.npmjs.org/is-https/-/is-https-1.0.0.tgz"
,
"integrity"
:
"sha512-1adLLwZT9XEXjzhQhZxd75uxf0l+xI9uTSFaZeSESjL3E1eXSPpO+u5RcgqtzeZ1KCaNvtEwZSTO2P4U5erVqQ=="
},
"node_modules/is-negative-zero"
:
{
"version"
:
"2.0.2"
,
"resolved"
:
"https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz"
,
...
...
@@ -7306,6 +7327,11 @@
"integrity"
:
"sha512-bZ5Sy3YzKo9Fyc8wH2iIQK4JImJ6R0GWI9kL1/k7Z91ZBNgkRXE6U0JfHIizZbort8ZunhSI3jw9I6253ahKfg=="
,
"peer"
:
true
},
"node_modules/js-cookie"
:
{
"version"
:
"2.2.1"
,
"resolved"
:
"https://registry.npmjs.org/js-cookie/-/js-cookie-2.2.1.tgz"
,
"integrity"
:
"sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ=="
},
"node_modules/js-tokens"
:
{
"version"
:
"4.0.0"
,
"resolved"
:
"https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz"
,
...
...
@@ -7954,6 +7980,11 @@
"integrity"
:
"sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ=="
,
"optional"
:
true
},
"node_modules/nanoid"
:
{
"version"
:
"2.1.11"
,
"resolved"
:
"https://registry.npmjs.org/nanoid/-/nanoid-2.1.11.tgz"
,
"integrity"
:
"sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA=="
},
"node_modules/nanomatch"
:
{
"version"
:
"1.2.13"
,
"resolved"
:
"https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz"
,
...
...
@@ -15462,6 +15493,21 @@
"webpackbar"
:
"^4.0.0"
}
},
"@nuxtjs/auth"
:
{
"version"
:
"4.9.1"
,
"resolved"
:
"https://registry.npmjs.org/@nuxtjs/auth/-/auth-4.9.1.tgz"
,
"integrity"
:
"sha512-h5VZanq2+P47jq3t0EnsZv800cg/ufOPC6JqvcyeDFJM99p58jHSODAjDuePo3PrZxd8hovMk7zusU5lOHgjvQ=="
,
"requires"
:
{
"@nuxtjs/axios"
:
"^5.9.5"
,
"body-parser"
:
"^1.19.0"
,
"consola"
:
"^2.11.3"
,
"cookie"
:
"^0.4.0"
,
"is-https"
:
"^1.0.0"
,
"js-cookie"
:
"^2.2.1"
,
"lodash"
:
"^4.17.15"
,
"nanoid"
:
"^2.1.11"
}
},
"@nuxtjs/auth-next"
:
{
"version"
:
"5.0.0-1667386184.dfbbb54"
,
"resolved"
:
"https://registry.npmjs.org/@nuxtjs/auth-next/-/auth-next-5.0.0-1667386184.dfbbb54.tgz"
,
...
...
@@ -19124,6 +19170,11 @@
"is-extglob"
:
"^2.1.1"
}
},
"is-https"
:
{
"version"
:
"1.0.0"
,
"resolved"
:
"https://registry.npmjs.org/is-https/-/is-https-1.0.0.tgz"
,
"integrity"
:
"sha512-1adLLwZT9XEXjzhQhZxd75uxf0l+xI9uTSFaZeSESjL3E1eXSPpO+u5RcgqtzeZ1KCaNvtEwZSTO2P4U5erVqQ=="
},
"is-negative-zero"
:
{
"version"
:
"2.0.2"
,
"resolved"
:
"https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz"
,
...
...
@@ -19270,6 +19321,11 @@
"integrity"
:
"sha512-bZ5Sy3YzKo9Fyc8wH2iIQK4JImJ6R0GWI9kL1/k7Z91ZBNgkRXE6U0JfHIizZbort8ZunhSI3jw9I6253ahKfg=="
,
"peer"
:
true
},
"js-cookie"
:
{
"version"
:
"2.2.1"
,
"resolved"
:
"https://registry.npmjs.org/js-cookie/-/js-cookie-2.2.1.tgz"
,
"integrity"
:
"sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ=="
},
"js-tokens"
:
{
"version"
:
"4.0.0"
,
"resolved"
:
"https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz"
,
...
...
@@ -19794,6 +19850,11 @@
"integrity"
:
"sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ=="
,
"optional"
:
true
},
"nanoid"
:
{
"version"
:
"2.1.11"
,
"resolved"
:
"https://registry.npmjs.org/nanoid/-/nanoid-2.1.11.tgz"
,
"integrity"
:
"sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA=="
},
"nanomatch"
:
{
"version"
:
"1.2.13"
,
"resolved"
:
"https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz"
,
...
...
pages/home/index.vue
View file @
2f21fd36
...
...
@@ -39,11 +39,11 @@ export default {
// console.log(data);
</
script
>
<
script
>
<
!-- <
script>
export default {
middleware: "web"
}
</
script
>
</script>
-->
<
style
>
</
style
>
pages/index.vue
View file @
2f21fd36
<
template
>
<div>
<Notification
:message=
"error"
v-if=
"error"
/>
<div
style=
"background-color: #8fc2ff"
>
<Notification
:message=
"error"
v-if=
"error"
/>
<div
class=
"container"
style=
"
...
...
@@ -8,16 +8,17 @@
justify-content: center;
align-items: center;
height: 100vh;
background-color: #8fc2ff;
"
>
<div
id=
"form-group"
>
<form
@
submit.prevent=
"login"
>
<h1
class=
"h3 mb-
3 fw-normal
"
>
Sign In
</h1>
<h1
class=
"h3 mb-
2 fw-normal"
style=
"text-align: center
"
>
Sign In
</h1>
<input
id=
"email"
v-model=
"email"
type=
"email"
class=
"form-control"
class=
"form-control
mb-3
"
placeholder=
"Email"
required
/>
...
...
@@ -25,10 +26,20 @@
id=
"password"
v-model=
"password"
type=
"password"
class=
"form-control"
class=
"form-control
mb-3
"
placeholder=
"password"
required
/>
<b-form-checkbox
id=
"checkbox-1"
v-model=
"status"
name=
"checkbox-1"
value=
"accepted"
class=
"mb-2"
unchecked-value=
"not_accepted"
>
Remember me
</b-form-checkbox>
<button
class=
"w-100 btn btn-lg btn-primary"
type=
"submit"
>
Sign in
</button>
...
...
@@ -40,87 +51,76 @@
<
script
>
import
Nav
from
"
@/components/Nav
"
;
import
Notification
from
'
@/components/Notification
'
;
import
Notification
from
"
@/components/Notification
"
;
export
default
{
components
:
{
Nav
},
components
:
{
Notification
}
components
:
{
Notification
},
};
</
script
>
<
script
>
import
{
reactive
}
from
"
vue
"
;
import
axios
from
'
axios
'
;
import
axios
from
"
axios
"
;
export
default
{
data
:
()
=>
{
return
{
email
:
""
,
password
:
""
,
error
:
null
error
:
null
,
};
},
methods
:
{
async
login
()
{
try
{
const
resp
=
await
fetch
(
"
http://127.0.0.1:8000/api/login
"
,
{
method
:
"
POST
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
},
body
:
JSON
.
stringify
({
email
:
this
.
email
,
password
:
this
.
password
,
}),
}).
then
((
response
)
=>
{
return
response
.
json
();
});
console
.
log
(
resp
.
status
);
localStorage
.
setItem
(
'
token
'
,
resp
.
data
.
bearer_token
);
if
(
resp
.
status
==
"
success
"
){
this
.
$router
.
push
(
'
home
'
)
}
}
catch
(
e
)
{
this
.
error
=
'
Username or Password not valid
'
}
// async login() {
// try {
// const response = await this.$axios.post('http://127.0.0.1:8000/api/login', {
// email: this.email,
// password: this.password
// });
async
login
()
{
try
{
const
resp
=
await
fetch
(
"
http://127.0.0.1:8000/api/login
"
,
{
method
:
"
POST
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
},
body
:
JSON
.
stringify
({
email
:
this
.
email
,
password
:
this
.
password
,
}),
}).
then
((
response
)
=>
{
return
response
.
json
();
});
console
.
log
(
resp
.
status
);
localStorage
.
setItem
(
"
token
"
,
resp
.
data
.
bearer_token
);
if
(
resp
.
status
==
"
success
"
)
{
this
.
$router
.
push
(
"
home
"
);
}
}
catch
(
e
)
{
this
.
error
=
"
Username or Password not valid
"
;
}
// await this.$auth.setToken('local', "Bearer " + response.data.access);
// await this.$auth.setRefreshToken('local', response.data.refresh);
// await this.$auth.setUserToken(response.data.access);
// } catch (e) {
// this.error = 'Username or Password not valid'
// }
// async login() {
// try {
// const response = await this.$axios.post('http://127.0.0.1:8000/api/login', {
// email: this.email,
// password: this.password
// });
},
// await this.$auth.setToken('local', "Bearer " + response.data.access);
// await this.$auth.setRefreshToken('local', response.data.refresh);
// await this.$auth.setUserToken(response.data.access);
// } catch (e) {
// this.error = 'Username or Password not valid'
// }
},
},
};
</
script
>
<
style
scoped
>
#form-group
{
height
:
50%
;
width
:
50
%
;
border
:
1px
solid
black
;
width
:
25
%
;
/* border: 1px solid black; */
padding
:
12px
;
padding-top
:
60px
;
display
:
flex
;
justify-content
:
center
;
background-color
:
#17a2b8
;
border-radius
:
10
%
;
background-color
:
white
;
border-radius
:
3
%
;
font-weight
:
600
;
}
</
style
>
pages/register.vue
View file @
2f21fd36
<
template
>
<div
style=
"background-color: #8fc2ff;"
>
<div
class=
"container"
style=
"
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
"
class=
"container"
style=
"
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #8fc2ff;
"
>
<div
id=
"form-
group
"
>
<div
id=
"form-
logout
"
>
<form
@
submit.prevent=
"signin"
>
<h1
class=
"h3 mb-3 fw-normal"
style=
"text-align:center;"
>
Sign up
</h1>
<label>
Name :
</label>
<input
type=
"text"
class=
"form-control"
class=
"form-control
mb-2
"
placeholder=
"name"
v-model=
"name"
max=
"255"
...
...
@@ -23,7 +26,7 @@
<label>
Email :
</label>
<input
type=
"email"
class=
"form-control"
class=
"form-control
mb-2
"
placeholder=
"Email"
v-model=
"email"
required
...
...
@@ -32,7 +35,7 @@
<label>
Password :
</label>
<input
type=
"password"
class=
"form-control"
class=
"form-control
mb-2
"
placeholder=
"password"
v-model=
"password"
required
...
...
@@ -40,18 +43,19 @@
<label>
Confirm Password :
</label>
<input
type=
"password"
class=
"form-control"
placeholder=
"Confirm
_
password"
class=
"form-control
mb-2
"
placeholder=
"Confirm
password"
required
/>
<div
class=
"button"
>
<button
class=
"w-
75
btn btn-lg btn-primary"
type=
"submit"
>
Sign up
here
<button
class=
"w-
50
btn btn-lg btn-primary"
type=
"submit"
>
Sign up
</button>
</div>
</form>
</div>
</div>
</div>
</
template
>
<
script
>
...
...
@@ -84,22 +88,21 @@ export default {
};
</
script
>
<
style
scoped
>
#form-
group
{
height
:
5
0%
;
width
:
5
0%
;
border
:
1px
solid
black
;
#form-
logout
{
height
:
6
0%
;
width
:
3
0%
;
/* border: 1px solid black; */
padding
:
12px
;
padding-top
:
30px
;
display
:
flex
;
justify-content
:
center
;
background-color
:
#17a2b8
;
border-radius
:
10
%
;
background-color
:
white
;
border-radius
:
3
%
;
font-weight
:
600
;
}
.btn
{
align-items
:
center
;
justify-content
:
center
;
margin-left
:
20px
;
margin-top
:
5px
;
margin-left
:
50px
;
}
</
style
>
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