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> <template>
<div> <div>
<b-navbar toggleable="lg" type="dark" variant="info" style="background-color: #6f2ca6 !important"> <v-toolbar
<SideBar /> dark
prominent
<b-navbar-toggle target="nav-collapse"></b-navbar-toggle> src="https://cdn.vuetifyjs.com/images/backgrounds/vbanner.jpg"
>
<b-collapse id="nav-collapse" is-nav> <v-app-bar-nav-icon />
<b-navbar-nav>
<b-nav-item href="/users">USER</b-nav-item> <v-toolbar-title>
<b-nav-item href="/categories">CATEGORY</b-nav-item> <v-btn href="/users">
<b-nav-item href="/products">PRODUCT</b-nav-item> <span>USER</span>
<b-nav-item href="/posts">POST</b-nav-item> <v-icon dense>mdi-account</v-icon>
</b-navbar-nav> </v-btn>
<!-- Right aligned nav items --> <v-btn href="/categories">
<b-navbar-nav class="ml-auto"> <span>CATEGORY</span>
<b-nav-item-dropdown right> <v-icon dense>mdi-heart</v-icon>
<!-- Using 'button-content' slot --> </v-btn>
<template #button-content>
<em>{{ $auth.$storage.getUniversal("userName") }}</em> <v-btn href="/products">
</template> <span>PRODUCT</span>
<b-dropdown-item href="#">Profile</b-dropdown-item> <v-icon dense> mdi-briefcase</v-icon>
<b-dropdown-item href="#" @click="logout">Sign Out</b-dropdown-item> </v-btn>
</b-nav-item-dropdown>
</b-navbar-nav> <v-btn href="/posts">
</b-collapse> <span>POST</span>
</b-navbar> <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> </div>
</template> </template>
<script> <script>
import SideBar from '@/components/SideBar'
export default { export default {
components: {
SideBar
},
methods: { methods: {
logout () { logout () {
fetch('http://127.0.0.1:8000/api/logout', { fetch('http://127.0.0.1:8000/api/logout', {
......
...@@ -246,7 +246,11 @@ export default { ...@@ -246,7 +246,11 @@ export default {
}, },
getCategories() { getCategories() {
this.$axios 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)) .then((response) => (this.categories = response.data.data))
.catch(function (error) { .catch(function (error) {
console.log(error) console.log(error)
...@@ -257,34 +261,37 @@ export default { ...@@ -257,34 +261,37 @@ export default {
const image = Array.from(set) const image = Array.from(set)
const self = this const self = this
this.$axios this.$axios
.post('/categories/', { .post('/categories/',
{
name: this.name, name: this.name,
ordering: this.ordering, ordering: this.ordering,
parent_id: this.parent_id, parent_id: this.parent_id,
images: image, images: image,
}, { },
{
headers: { headers: {
'Content-Type': 'multipart/form-data', "Content-Type": "multipart/form-data",
'Authorization': this.$auth.$storage.getUniversal('token') Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
} },
}) }
.then(response => { )
this.$bvModal.hide('modal-create') .then(response => {
self.$toast.success('Category created successfully!', { this.$bvModal.hide('modal-create')
duration: 3000 self.$toast.success('Category created successfully!', {
}) duration: 3000
this.editedItem = response.data.data
console.log(this.editedItem)
this.categories.push(this.editedItem)
}) })
.catch(errors => { this.editedItem = response.data.data
this.$bvModal.hide('modal-create') console.log(this.editedItem)
console.log(errors.response.data.message) this.categories.push(this.editedItem)
this.message = errors.response.data.message })
self.$toast.error('something went wrong while trying create!', { .catch(errors => {
duration: 3000 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!',{
duration: 3000
}) })
})
}, },
fileSelected(event) { fileSelected(event) {
console.log(event) console.log(event)
...@@ -297,20 +304,26 @@ export default { ...@@ -297,20 +304,26 @@ export default {
deleteCategory(ID, index) { deleteCategory(ID, index) {
const self = this const self = this
this.editedIndex = this.categories.indexOf(index) this.editedIndex = this.categories.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(`/categories/${ID}`) .delete(`/categories/${ID}`,
.then(response => { {
this.categories.splice(this.editedIndex, 1) headers: {
self.$toast.success('Category deleted successfully!', { "Content-Type": "multipart/form-data",
duration: 3000 Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}) },
}) })
} catch (error) { .then(response => {
console.log(error) this.categories.splice(this.editedIndex, 1)
} self.$toast.success('Category deleted successfully!',{
duration: 3000
})
})
} catch(error){
console.log(error)
} }
}
}, },
getID(item) { getID(item) {
console.log(this.categories.indexOf(item)) console.log(this.categories.indexOf(item))
...@@ -333,29 +346,31 @@ export default { ...@@ -333,29 +346,31 @@ export default {
console.log(this.eName) console.log(this.eName)
console.log(this.eOrdering) console.log(this.eOrdering)
console.log(this?.eID) console.log(this?.eID)
try { try{
this.$axios this.$axios
.post(`categories/update/${this?.eID}`, { .post(`categories/update/${this?.eID}`,
{
name: this.eName, name: this.eName,
ordering: this.eOrdering, ordering: this.eOrdering,
parent_id: this.eParentId, parent_id: this.eParentId,
images: image images: image },
}, { {
headers: { headers: {
'Content-Type': 'multipart/form-data', "Content-Type": "multipart/form-data",
'Authorization': this.$auth.$storage.getUniversal('token') Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
} }
}) }
.then(response => { )
self.$toast.success('User updated successfully!', { .then(response => {
duration: 3000 self.$toast.success('User updated successfully!',{
}) duration: 3000
console.log(response) })
this.editedItem = response.data.data console.log(response)
this.$bvModal.hide('modal-edit') this.editedItem = response.data.data
Object.assign(this.categories[this.editedIndex], this.editedItem) this.$bvModal.hide('modal-edit')
}) Object.assign(this.categories[this.editedIndex], this.editedItem)
} catch (error) { })
} catch(error){
console.log(error) console.log(error)
} }
} }
......
...@@ -268,7 +268,11 @@ export default { ...@@ -268,7 +268,11 @@ export default {
}, },
getCategories() { getCategories() {
this.$axios 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)) .then((response) => (this.categories = response.data.data))
.catch(function (error) { .catch(function (error) {
console.log(error) console.log(error)
...@@ -276,7 +280,11 @@ export default { ...@@ -276,7 +280,11 @@ export default {
}, },
getposts() { getposts() {
this.$axios 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)) .then((response) => (this.posts = response.data.data))
.catch(function (error) { .catch(function (error) {
console.log(error) console.log(error)
...@@ -296,8 +304,8 @@ export default { ...@@ -296,8 +304,8 @@ export default {
}, },
{ {
headers: { headers: {
'Content-Type': 'multipart/form-data', "Content-Type": "multipart/form-data",
Authorization: this.$auth.$storage.getUniversal('token'), Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}, },
} }
) )
...@@ -324,7 +332,11 @@ export default { ...@@ -324,7 +332,11 @@ export default {
this.editedIndex = this.posts.indexOf(index) this.editedIndex = this.posts.indexOf(index)
if (confirm('Do you really want to delete?')) { if (confirm('Do you really want to delete?')) {
this.$axios this.$axios
.delete(`/posts/${ID}`) .delete(`/posts/${ID}`,{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}})
.then((response) => { .then((response) => {
this.posts.splice(this.editedIndex, 1) this.posts.splice(this.editedIndex, 1)
self.$toast.success('Post deleted successfully!', { self.$toast.success('Post deleted successfully!', {
...@@ -345,8 +357,8 @@ export default { ...@@ -345,8 +357,8 @@ export default {
const resp = await this.$axios.get(`/posts/${ID}`, { const resp = await this.$axios.get(`/posts/${ID}`, {
method: 'GET', method: 'GET',
headers: { headers: {
'Content-Type': 'multipart/form-data', "Content-Type": "multipart/form-data",
Authorization: this.$auth.$storage.getUniversal('token'), Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}, },
}) })
console.log(resp.data) console.log(resp.data)
...@@ -386,8 +398,8 @@ export default { ...@@ -386,8 +398,8 @@ export default {
}, },
{ {
headers: { headers: {
'Content-Type': 'multipart/form-data', "Content-Type": "multipart/form-data",
Authorization: this.$auth.$storage.getUniversal('token'), Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}, },
} }
) )
......
...@@ -481,7 +481,11 @@ export default { ...@@ -481,7 +481,11 @@ export default {
}, },
getCategories() { getCategories() {
this.$axios 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)) .then((response) => (this.categories = response.data.data))
.catch(function (error) { .catch(function (error) {
console.log(error) console.log(error)
...@@ -489,7 +493,11 @@ export default { ...@@ -489,7 +493,11 @@ export default {
}, },
getProducts() { getProducts() {
this.$axios 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)) .then((response) => (this.products = response.data.data))
.catch(function (error) { .catch(function (error) {
console.log(error) console.log(error)
...@@ -510,7 +518,7 @@ export default { ...@@ -510,7 +518,7 @@ export default {
}, { }, {
headers: { headers: {
'Content-Type': 'multipart/form-data', 'Content-Type': 'multipart/form-data',
'Authorization': this.$auth.$storage.getUniversal('token') Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
} }
}) })
.then(response => { .then(response => {
...@@ -537,7 +545,11 @@ export default { ...@@ -537,7 +545,11 @@ export default {
if(confirm('Do you really want to delete?')){ if(confirm('Do you really want to delete?')){
try{ try{
this.$axios this.$axios
.delete(`/products/${ID}`) .delete(`/products/${ID}`,{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}})
.then(response => { .then(response => {
this.products.splice(this.editedIndex, 1) this.products.splice(this.editedIndex, 1)
self.$toast.success('Category deleted successfully!',{ self.$toast.success('Category deleted successfully!',{
...@@ -555,8 +567,8 @@ export default { ...@@ -555,8 +567,8 @@ export default {
const resp = await this.$axios.get(`/products/${ID}`, { const resp = await this.$axios.get(`/products/${ID}`, {
method: 'GET', method: 'GET',
headers: { headers: {
'Content-Type': 'multipart/form-data', "Content-Type": "multipart/form-data",
Authorization: this.$auth.$storage.getUniversal('token'), Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}, },
}) })
this.sName = resp.data.data.name this.sName = resp.data.data.name
...@@ -594,11 +606,12 @@ export default { ...@@ -594,11 +606,12 @@ export default {
images: this.eImages, images: this.eImages,
variants: this.eVariants, variants: this.eVariants,
}, { }, {
headers: { headers: {
'Content-Type': 'multipart/form-data', "Content-Type": "multipart/form-data",
'Authorization': this.$auth.$storage.getUniversal('token') Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}
} }
} ) )
.then(response => { .then(response => {
self.$toast.success('User updated successfully!',{ self.$toast.success('User updated successfully!',{
duration: 3000 duration: 3000
......
<template> <!-- <template>
<div style="background-color: #8fc2ff"> <div style="background-color: #8fc2ff">
<div class="container" style=" <div class="container" style="
display: flex; display: flex;
...@@ -57,7 +57,7 @@ export default { ...@@ -57,7 +57,7 @@ export default {
confirm_password: this.confirm_password, confirm_password: this.confirm_password,
}), }),
}) })
this.$router.push('/') this.$router.push("/login")
}, },
}, },
} }
...@@ -81,4 +81,4 @@ export default { ...@@ -81,4 +81,4 @@ export default {
justify-content: center; justify-content: center;
margin-left: 50px; 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