Commit 831cfb88 authored by TTS Kieu Tuan Anh's avatar TTS Kieu Tuan Anh

add image

parent 3d7ed82f
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<div class="footer-bottom"> <div class="footer-bottom">
<div class="footer-bottom-left"> <div class="footer-bottom-left">
<figure class="payment"> <figure class="payment">
<img src="~/assets/images/payment.png" alt="payment" width="159" height="29"></img> <img src="~/assets/images/payment.png" alt="payment" width="159" height="29">
</figure> </figure>
</div> </div>
<p class="copyright">Riode eCommerce © 2022. All Rights Reserved</p> <p class="copyright">Riode eCommerce © 2022. All Rights Reserved</p>
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<b-icon icon="info-circle"></b-icon> <b-icon icon="info-circle"></b-icon>
Need Help Need Help
</a> </a>
<a href="#signin" class="login-toggle link-to-tab d-md-show"> <a @click="openModal" v-b-modal.modal-login class="login-toggle link-to-tab d-md-show">
<b-icon icon="person" font-scale="1.3"></b-icon> <b-icon icon="person" font-scale="1.3"></b-icon>
Sign in Sign in
</a> </a>
...@@ -119,11 +119,16 @@ ...@@ -119,11 +119,16 @@
<script> <script>
import NavBar from "@/components/Shared/Header/NavBar"; import NavBar from "@/components/Shared/Header/NavBar";
import LoginForm from "@/components/Shared/Header/LoginForm";
export default { export default {
name: "Header", name: "Header",
components: { components: {
NavBar, NavBar,
LoginForm,
}, },
methods: {
openModal() { this.$bvModal.show('modal-login') }
}
}; };
</script> </script>
......
<template>
<b-modal id="modal-login" title="Create User" class="modal fade" v-if="showModal">
<p class="my-4">
<form >
<label>Name :</label>
<input
type="text"
class="form-control mb-2"
placeholder="name"
v-model="name"
max="255"
min="1"
required
/>
<label>Email :</label>
<input
type="email"
class="form-control mb-2"
placeholder="Email"
v-model="email"
required
/>
<label>Password :</label>
<input
type="password"
class="form-control mb-2"
placeholder="password"
v-model="password"
required
/>
</form>
</p>
<template #modal-footer>
<button v-b-modal.modal-close_visit @click="$bvModal.hide('modal-login')" class="btn btn-danger btn-sm m-1">Close</button>
<button @click="" v-b-modal.modal-close_visit class="btn btn-success btn-sm m-1">Submit</button>
</template>
</b-modal>
</template>
<script>
export default {
name: "LoginForm",
data() {
return {
}
},
methods: {
show() {
this.showModal = true
},
hide(){
this.showModal = false
}
}
}
</script>
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<b-collapse id="nav-collapse" is-nav> <b-collapse id="nav-collapse" is-nav>
<b-navbar-nav> <b-navbar-nav>
<b-nav-item href="/home/users">USER</b-nav-item> <b-nav-item href="/home/users">USER</b-nav-item>
<b-nav-item href="#">CATEGORY</b-nav-item> <b-nav-item href="/home/categories">CATEGORY</b-nav-item>
</b-navbar-nav> </b-navbar-nav>
<!-- Right aligned nav items --> <!-- Right aligned nav items -->
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
<div> <div>
<h1 style="text-align: center">ABOUT</h1> <h1 style="text-align: center">ABOUT</h1>
</div> </div>
......
<template> <template>
<div> <div>
<div>
<Nav />
</div>
<b-breadcrumb> <b-breadcrumb>
<b-breadcrumb-item href="/home"> <b-breadcrumb-item href="/home">
<b-icon icon="house-fill" scale="1.25" shift-v="1.25" aria-hidden="true"></b-icon> <b-icon icon="house-fill" scale="1.25" shift-v="1.25" aria-hidden="true"></b-icon>
Home Home
</b-breadcrumb-item> </b-breadcrumb-item>
<b-breadcrumb-item href="/home/users">User</b-breadcrumb-item> <b-breadcrumb-item href="/home/categories">Category</b-breadcrumb-item>
</b-breadcrumb> </b-breadcrumb>
<div style="float: right"> <div style="float: right">
<b-button v-b-modal.modal-1 >New User</b-button> <b-button v-b-modal.modal-create >New Category</b-button></div>
<!-- create modal -->
<b-modal id="modal-1" title="Create User" class="modal fade" > <b-modal id="modal-create" title="Create Category" class="modal fade" >
<Notification :message="error" v-if="error" />
<p class="my-4"> <p class="my-4">
<form @submit.prevent="createUser" > <form @submit.prevent="" >
<label>Name :</label> <label>Name :</label>
<input <input
type="text" type="text"
...@@ -27,60 +23,54 @@ ...@@ -27,60 +23,54 @@
min="1" min="1"
required required
/> />
<label>Email :</label> <label>Parent ID :</label>
<input <input
type="email" type="text"
class="form-control mb-2" class="form-control mb-2"
placeholder="Email" placeholder="Parent ID"
v-model="email" v-model="parent_id"
required
/> />
<label>Password :</label> <label>Ordering :</label>
<input <input
type="password" type="text"
class="form-control mb-2" class="form-control mb-2"
placeholder="password" placeholder="password"
v-model="password" v-model="ordering"
required required
/> />
<!-- <div class="button"> <!-- <b-form-select v-model="selected" :options="options"></b-form-select> -->
<button class="w-30 btn btn-sm btn-primary" type="submit"> <label>Image :</label>
Create <b-form-file
</button> @change="fileSelected"
</div> --> v-model="image"
:state="Boolean(image)"
placeholder="Choose a image or drop it here..."
drop-placeholder="Drop file here..."
></b-form-file>
</form> </form>
</p> </p>
<template #modal-footer> <template #modal-footer>
<button v-b-modal.modal-close_visit @click="this.hide('modal-1')" class="btn btn-danger btn-sm m-1">Close</button> <button v-b-modal.modal-close_visit @click="$bvModal.hide('modal-create')" class="btn btn-danger btn-sm m-1">Close</button>
<button @click="createUser" v-b-modal.modal-close_visit class="btn btn-success btn-sm m-1">Submit</button> <button @click="createCategory" v-b-modal.modal-close_visit class="btn btn-success btn-sm m-1">Submit</button>
</template> </template>
</b-modal> </b-modal>
</div> <div>
<v-data-table <v-data-table
:headers="headers" :headers="headers"
:items="users" :items="categories"
sort-by="calories" sort-by="calories"
class="elevation-1" class="elevation-1"
> >
<template v-slot:top > <template v-slot:top >
<v-toolbar flat> <v-toolbar flat>
<v-toolbar-title>User Manage</v-toolbar-title> <v-toolbar-title>Category Manage</v-toolbar-title>
<v-divider class="mx-4" inset vertical></v-divider> <v-divider class="mx-4" inset vertical></v-divider>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-dialog v-model="dialog" max-width="500px"> <v-dialog v-model="dialog" max-width="500px">
<template v-slot:activator="{ on, attrs }"> <template v-slot:activator="{ on, attrs }">
<!-- <v-btn
color="primary"
dark
class="mb-2"
v-bind="attrs"
v-on="on"
v-on:click="getUser"
>
New User
</v-btn> -->
<!-- modal create user -->
</template> </template>
<v-card> <v-card>
<v-card-title> <v-card-title>
...@@ -104,8 +94,8 @@ ...@@ -104,8 +94,8 @@
</v-col> </v-col>
<v-col cols="12" sm="6" md="4"> <v-col cols="12" sm="6" md="4">
<v-text-field <v-text-field
v-model="editedItem.email" v-model="editedItem.ordering"
label="email" label="ordering"
></v-text-field> ></v-text-field>
</v-col> </v-col>
<v-col cols="12" sm="6" md="4"> <v-col cols="12" sm="6" md="4">
...@@ -153,7 +143,7 @@ ...@@ -153,7 +143,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>
...@@ -161,6 +151,12 @@ ...@@ -161,6 +151,12 @@
</template> </template>
</v-data-table> </v-data-table>
</div> </div>
</div>
</template> </template>
<script> <script>
...@@ -168,23 +164,30 @@ import Nav from "@/components/Nav"; ...@@ -168,23 +164,30 @@ 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/Notification"; import notification from "@/components/Notification";
import Toasted from 'vue-toasted';
import { ModalPlugin } from 'bootstrap-vue';
export default { export default {
layout: 'admin',
components: { Nav }, components: { Nav },
components: { Navigation }, components: { Navigation },
components: { notification }, components: { notification },
middleware: ["web"], middleware: ["web"],
data: () => { data: () => {
return { return {
email:'', parent_id:'',
name:'', name:'',
password:'', ordering:'',
image: null,
error: '', error: '',
dialog: false, dialog: false,
dialogDelete: false, dialogDelete: false,
options: [
{ value: null, text: 'Please select an option' },
{ value: 'a', text: 'This is First option' },
{ value: 'b', text: 'Selected Option' },
{ value: { C: '3PO' }, text: 'This is an option with object value' },
{ value: 'd', text: 'This one is disabled', disabled: true }
],
headers: [ headers: [
{ {
text: "Name", text: "Name",
...@@ -193,19 +196,23 @@ export default { ...@@ -193,19 +196,23 @@ export default {
value: "name", value: "name",
}, },
{ text: "id", value: "id" }, { text: "id", value: "id" },
{ text: "email", value: "email" }, { text: "ordering", value: "ordering" },
{ text: "status", value: "status", sortable: false }, { text: "parent", value: "parent_id", sortable: false },
{ text: "created_at", value: "created_at" }, { text: "created_at", value: "created_at" },
{ text: "updated_at", value: "updated_at" }, { text: "updated_at", value: "updated_at" },
{ text: 'Actions', value: 'actions', sortable: false }, { text: 'Actions', value: 'actions', sortable: false },
], ],
users: [], categories: [],
eID: '',
eEmail:'',
eName:'',
ePassword:'',
message: [], message: [],
editedIndex: -1, editedIndex: -1,
editedItem: { editedItem: {
name: "", name: "",
id: "", id: "",
email: "", ordering: "",
status: "", status: "",
created_at: "", created_at: "",
updated_at: "", updated_at: "",
...@@ -214,7 +221,7 @@ export default { ...@@ -214,7 +221,7 @@ export default {
defaultItem: { defaultItem: {
name: "", name: "",
id: "", id: "",
email: "", ordering: "",
status: "", status: "",
created_at: "", created_at: "",
updated_at: "", updated_at: "",
...@@ -236,23 +243,25 @@ export default { ...@@ -236,23 +243,25 @@ export default {
}, },
created() { created() {
this.initialize(); this.initialize();
this.getCategories();
}, },
methods: { methods: {
initialize() { initialize() {
this.users = []; this.users = [];
this.categories= [];
}, },
editItem(item) { editItem(item) {
this.editedIndex = this.users.indexOf(item); this.editedIndex = this.categories.indexOf(item);
this.editedItem = Object.assign({}, item); this.editedItem = Object.assign({}, item);
this.dialog = true; this.dialog = true;
}, },
deleteItem(item) { deleteItem(item) {
this.editedIndex = this.users.indexOf(item); this.editedIndex = this.categories.indexOf(item);
this.editedItem = Object.assign({}, item); this.editedItem = Object.assign({}, item);
this.dialogDelete = true; this.dialogDelete = true;
}, },
deleteItemConfirm() { deleteItemConfirm() {
this.users.splice(this.editedIndex, 1); this.categories.splice(this.editedIndex, 1);
this.closeDelete(); this.closeDelete();
}, },
close() { close() {
...@@ -271,49 +280,96 @@ export default { ...@@ -271,49 +280,96 @@ export default {
}, },
save() { save() {
if (this.editedIndex > -1) { if (this.editedIndex > -1) {
Object.assign(this.users[this.editedIndex], this.editedItem); Object.assign(this.categories[this.editedIndex], this.editedItem);
} else { } else {
this.users.push(this.editedItem); this.categories.push(this.editedItem);
} }
this.close(); this.close();
}, },
getUser() { getCategories() {
axios axios
.get("http://127.0.0.1:8000/api/users/") .get("http://127.0.0.1:8000/api/categories/")
.then((response) => (this.users = response.data.data.data)) .then((response) => (this.categories = response.data.data))
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);
}); });
}, },
createUser() { createCategory() {
const self = this
axios axios
.post('http://127.0.0.1:8000/api/users/',{ .post('http://127.0.0.1:8000/api/categories/',{
headers: { name: this.name,
'Content-Type': 'application/json' ordering: this.ordering,
}, parent_id: this.parent_id,
email: this.email, image: this.image,
password: this.password, })
name:this.name, .then(response => {
// $bvModal.hide('modal-login');
self.$toast.success('Category created successfully!',{
duration: 3000
});
console.log(response);
}) })
.then(response => (this.message = response)) .catch(errors => {
.catch(function (errors) { this.$bvModal.hide('modal-create')
console.log(errors); console.log(errors.response.data.message);
this.message = errors; this.message = errors.response.data.message;
self.$toast.error('something went wrong while trying create!',{
duration: 3000
});
}); });
},
fileSelected(event){
console.log(event)
const file = event.target.files[0];
this.url = URL.createObjectURL(file);
this.image = file;
console.log(file)
}, },
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/categories/${userID}`)
} catch(error){ } catch(error){
console.log(error) console.log(error)
} }
}
}, },
},
created() { editUser(userID) {
this.getUser(); 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/categories/${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)
}
}
}, },
}; };
</script>
</script>
\ No newline at end of file
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