Commit ee8f9bac authored by vietanh-0511's avatar vietanh-0511

Merge branch 'dev' of...

Merge branch 'dev' of https://gitlab.kiaisoft.com/kiaisoft.anh.tran2/kiaisoft_tuananh_nuxt into feature/user-login
parents 5a873b10 ef3630f7
<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>
<v-toolbar
dark
prominent
src="https://cdn.vuetifyjs.com/images/backgrounds/vbanner.jpg"
>
<v-app-bar-nav-icon />
<v-toolbar-title>
<v-btn href="/users">
<span>USER</span>
<v-icon dense>mdi-account</v-icon>
</v-btn>
<v-btn href="/categories">
<span>CATEGORY</span>
<v-icon dense>mdi-heart</v-icon>
</v-btn>
<v-btn href="/products">
<span>PRODUCT</span>
<v-icon dense> mdi-briefcase</v-icon>
</v-btn>
<v-btn href="/posts">
<span>POST</span>
<v-icon dense>mdi-newspaper</v-icon>
</v-btn>
</v-toolbar-title>
<v-spacer />
<v-toolbar-title>{{ $auth.$storage.getUniversal("userName") }}</v-toolbar-title>
<v-btn icon @click="logout">
<v-icon>mdi-export</v-icon>
</v-btn>
</v-toolbar>
</div>
</template>
<script>
import SideBar from '@/components/SideBar'
export default {
components: {
SideBar
},
methods: {
logout () {
fetch('http://127.0.0.1:8000/api/logout', {
......
......@@ -246,7 +246,11 @@ export default {
},
getCategories() {
this.$axios
.get('/categories/')
.get("/categories/",{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}})
.then((response) => (this.categories = response.data.data))
.catch(function (error) {
console.log(error)
......@@ -257,17 +261,20 @@ export default {
const image = Array.from(set)
const self = this
this.$axios
.post('/categories/', {
.post('/categories/',
{
name: this.name,
ordering: this.ordering,
parent_id: this.parent_id,
images: image,
}, {
},
{
headers: {
'Content-Type': 'multipart/form-data',
'Authorization': this.$auth.$storage.getUniversal('token')
"Content-Type": "multipart/form-data",
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
},
}
})
)
.then(response => {
this.$bvModal.hide('modal-create')
self.$toast.success('Category created successfully!', {
......@@ -281,7 +288,7 @@ export default {
this.$bvModal.hide('modal-create')
console.log(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
})
})
......@@ -297,17 +304,23 @@ export default {
deleteCategory(ID, index) {
const self = this
this.editedIndex = this.categories.indexOf(index)
if (confirm('Do you really want to delete?')) {
try {
if(confirm("Do you really want to delete?")){
try{
this.$axios
.delete(`/categories/${ID}`)
.delete(`/categories/${ID}`,
{
headers: {
"Content-Type": "multipart/form-data",
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
},
})
.then(response => {
this.categories.splice(this.editedIndex, 1)
self.$toast.success('Category deleted successfully!', {
self.$toast.success('Category deleted successfully!',{
duration: 3000
})
})
} catch (error) {
} catch(error){
console.log(error)
}
}
......@@ -333,21 +346,23 @@ export default {
console.log(this.eName)
console.log(this.eOrdering)
console.log(this?.eID)
try {
try{
this.$axios
.post(`categories/update/${this?.eID}`, {
.post(`categories/update/${this?.eID}`,
{
name: this.eName,
ordering: this.eOrdering,
parent_id: this.eParentId,
images: image
}, {
images: image },
{
headers: {
'Content-Type': 'multipart/form-data',
'Authorization': this.$auth.$storage.getUniversal('token')
"Content-Type": "multipart/form-data",
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}
})
}
)
.then(response => {
self.$toast.success('User updated successfully!', {
self.$toast.success('User updated successfully!',{
duration: 3000
})
console.log(response)
......@@ -355,7 +370,7 @@ export default {
this.$bvModal.hide('modal-edit')
Object.assign(this.categories[this.editedIndex], this.editedItem)
})
} catch (error) {
} catch(error){
console.log(error)
}
}
......
......@@ -268,7 +268,11 @@ export default {
},
getCategories() {
this.$axios
.get('/categories/')
.get("/categories/",{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}})
.then((response) => (this.categories = response.data.data))
.catch(function (error) {
console.log(error)
......@@ -276,7 +280,11 @@ export default {
},
getposts() {
this.$axios
.get('/posts/')
.get("/posts/",{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}})
.then((response) => (this.posts = response.data.data))
.catch(function (error) {
console.log(error)
......@@ -296,8 +304,8 @@ export default {
},
{
headers: {
'Content-Type': 'multipart/form-data',
Authorization: this.$auth.$storage.getUniversal('token'),
"Content-Type": "multipart/form-data",
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
},
}
)
......@@ -324,7 +332,11 @@ export default {
this.editedIndex = this.posts.indexOf(index)
if (confirm('Do you really want to delete?')) {
this.$axios
.delete(`/posts/${ID}`)
.delete(`/posts/${ID}`,{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}})
.then((response) => {
this.posts.splice(this.editedIndex, 1)
self.$toast.success('Post deleted successfully!', {
......@@ -345,8 +357,8 @@ export default {
const resp = await this.$axios.get(`/posts/${ID}`, {
method: 'GET',
headers: {
'Content-Type': 'multipart/form-data',
Authorization: this.$auth.$storage.getUniversal('token'),
"Content-Type": "multipart/form-data",
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
},
})
console.log(resp.data)
......@@ -386,8 +398,8 @@ export default {
},
{
headers: {
'Content-Type': 'multipart/form-data',
Authorization: this.$auth.$storage.getUniversal('token'),
"Content-Type": "multipart/form-data",
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
},
}
)
......
......@@ -481,7 +481,11 @@ export default {
},
getCategories() {
this.$axios
.get('/categories/')
.get("/categories/",{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}})
.then((response) => (this.categories = response.data.data))
.catch(function (error) {
console.log(error)
......@@ -489,7 +493,11 @@ export default {
},
getProducts() {
this.$axios
.get('/products/')
.get("/products/",{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}})
.then((response) => (this.products = response.data.data))
.catch(function (error) {
console.log(error)
......@@ -510,7 +518,7 @@ export default {
}, {
headers: {
'Content-Type': 'multipart/form-data',
'Authorization': this.$auth.$storage.getUniversal('token')
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}
})
.then(response => {
......@@ -537,7 +545,11 @@ export default {
if(confirm('Do you really want to delete?')){
try{
this.$axios
.delete(`/products/${ID}`)
.delete(`/products/${ID}`,{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}})
.then(response => {
this.products.splice(this.editedIndex, 1)
self.$toast.success('Category deleted successfully!',{
......@@ -555,8 +567,8 @@ export default {
const resp = await this.$axios.get(`/products/${ID}`, {
method: 'GET',
headers: {
'Content-Type': 'multipart/form-data',
Authorization: this.$auth.$storage.getUniversal('token'),
"Content-Type": "multipart/form-data",
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
},
})
this.sName = resp.data.data.name
......@@ -595,10 +607,11 @@ export default {
variants: this.eVariants,
}, {
headers: {
'Content-Type': 'multipart/form-data',
'Authorization': this.$auth.$storage.getUniversal('token')
"Content-Type": "multipart/form-data",
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}
}
} )
)
.then(response => {
self.$toast.success('User updated successfully!',{
duration: 3000
......
<template>
<!-- <template>
<div style="background-color: #8fc2ff">
<div class="container" style="
display: flex;
......@@ -57,7 +57,7 @@ export default {
confirm_password: this.confirm_password,
}),
})
this.$router.push('/')
this.$router.push("/login")
},
},
}
......@@ -81,4 +81,4 @@ export default {
justify-content: center;
margin-left: 50px;
}
</style>
</style> -->
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment