Commit ffa01ab4 authored by Le Dinh Trung's avatar Le Dinh Trung

refactor frontend

parent 2f43d5a6
module.exports = {
root: true,
env: {
browser: true,
node: true
},
parserOptions: {
parser: '@babel/eslint-parser',
requireConfigFile: false
},
extends: [
'@nuxtjs',
'plugin:nuxt/recommended'
],
plugins: [
],
// add your custom rules here
rules: {}
}
# KiaiSoft_Tuan_Anh
# web
## Build Setup
```bash
# install dependencies
$ npm install
$ yarn install
# serve with hot reload at localhost:3000
$ npm run dev
$ yarn dev
# build for production and launch server
$ npm run build
$ npm run start
$ yarn build
$ yarn start
# generate static project
$ npm run generate
$ yarn generate
```
For detailed explanation on how things work, check out the [documentation](https://nuxtjs.org).
......
// Ref: https://github.com/nuxt-community/vuetify-module#customvariables
//
// The variables you want to modify
// $font-size-root: 20px;
<template>
<v-footer
dark
padless
>
<v-card
flat
tile
class="indigo lighten-1 white--text text-center"
>
<v-footer dark padless>
<v-card flat tile class="indigo lighten-1 white--text text-center">
<v-card-text>
<v-btn
v-for="icon in icons"
:key="icon"
class="mx-4 white--text"
icon
>
<v-btn v-for="icon in icons" :key="icon" class="mx-4 white--text" icon>
<v-icon size="24px">
{{ icon }}
</v-icon>
......@@ -22,7 +10,11 @@
</v-card-text>
<v-card-text class="white--text pt-0">
Phasellus feugiat arcu sapien, et iaculis ipsum elementum sit amet. Mauris cursus commodo interdum. Praesent ut risus eget metus luctus accumsan id ultrices nunc. Sed at orci sed massa consectetur dignissim a sit amet dui. Duis commodo vitae velit et faucibus. Morbi vehicula lacinia malesuada. Nulla placerat augue vel ipsum ultrices, cursus iaculis dui sollicitudin. Vestibulum eu ipsum vel diam elementum tempor vel ut orci. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Phasellus feugiat arcu sapien, et iaculis ipsum elementum sit amet. Mauris cursus commodo interdum. Praesent ut
risus eget metus luctus accumsan id ultrices nunc. Sed at orci sed massa consectetur dignissim a sit amet dui.
Duis commodo vitae velit et faucibus. Morbi vehicula lacinia malesuada. Nulla placerat augue vel ipsum ultrices,
cursus iaculis dui sollicitudin. Vestibulum eu ipsum vel diam elementum tempor vel ut orci. Orci varius natoque
penatibus et magnis dis parturient montes, nascetur ridiculus mus.
</v-card-text>
<v-divider></v-divider>
......@@ -36,12 +28,7 @@
<p class="copyright">Riode eCommerce © 2022. All Rights Reserved</p>
<div class="footer-bottom-right">
<div class="social-link">
<v-btn
v-for="icon in icons"
:key="icon"
class="mx-4 white--text"
icon
>
<v-btn v-for="icon in icons" :key="icon" class="mx-4 white--text" icon>
<v-icon size="24px">
{{ icon }}
</v-icon>
......@@ -55,7 +42,7 @@
</template>
<script>
export default {
export default {
data: () => ({
icons: [
'mdi-facebook',
......@@ -64,20 +51,21 @@
'mdi-instagram',
],
}),
}
}
</script>
<style>
.footer-bottom-left {
position: absolute;
left: 0;
}
.footer-bottom-right {
position: absolute;
right: 0;
}
.copyright {
position: absolute;
......@@ -87,5 +75,4 @@
margin-right: auto;
}
</style>
\ No newline at end of file
<template>
<div>
<b-navbar
toggleable="lg"
type="dark"
variant="info"
style="background-color: #6f2ca6 !important"
>
<b-navbar toggleable="lg" type="dark" variant="info" style="background-color: #6f2ca6 !important">
<SideBar />
<b-navbar-toggle target="nav-collapse"></b-navbar-toggle>
......@@ -35,41 +30,31 @@
</template>
<script>
export default {
name: "Nav",
};
</script>
<script>
import sidebar from "@/components/SideBar";
import vuex from
export default {
components: { sidebar },
};
</script>
<script>
const token_access = localStorage.getItem("token");
export default {
name: "logout",
components: {
Sidebar
},
methods: {
logout() {
fetch("http://127.0.0.1:8000/api/logout", {
method: "POST",
fetch('http://127.0.0.1:8000/api/logout', {
method: 'POST',
headers: {
"Content-Type": "application/json",
accept: "application/json",
'Content-Type': 'application/json',
accept: 'application/json',
},
body: JSON.stringify({
token: this.$auth.$storage.getUniversal("token"),
token: this.$auth.$storage.getUniversal('token'),
}),
});
localStorage.setItem("token", "");
this.$auth.$storage.setUniversal("loggedIn", "false");
this.$auth.$storage.setUniversal("token", "");
this.$auth.$storage.setUniversal("userName", "");
this.$router.push("/login");
localStorage.setItem('token', '')
this.$auth.$storage.setUniversal('loggedIn', 'false')
this.$auth.$storage.setUniversal('token', '')
this.$auth.$storage.setUniversal('userName', '')
this.$router.push('/login')
},
},
};
}
</script>
<style></style>
<style>
</style>
<template>
<svg
class="nuxt-logo"
viewBox="0 0 45 30"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M24.7203 29.704H41.1008C41.6211 29.7041 42.1322 29.5669 42.5828 29.3061C43.0334 29.0454 43.4075 28.6704 43.6675 28.2188C43.9275 27.7672 44.0643 27.2549 44.0641 26.7335C44.0639 26.2121 43.9266 25.6999 43.6662 25.2485L32.6655 6.15312C32.4055 5.70162 32.0315 5.32667 31.581 5.06598C31.1305 4.8053 30.6195 4.66805 30.0994 4.66805C29.5792 4.66805 29.0682 4.8053 28.6177 5.06598C28.1672 5.32667 27.7932 5.70162 27.5332 6.15312L24.7203 11.039L19.2208 1.48485C18.9606 1.03338 18.5864 0.658493 18.1358 0.397853C17.6852 0.137213 17.1741 0 16.6538 0C16.1336 0 15.6225 0.137213 15.1719 0.397853C14.7213 0.658493 14.3471 1.03338 14.0868 1.48485L0.397874 25.2485C0.137452 25.6999 0.000226653 26.2121 2.8053e-07 26.7335C-0.000226092 27.2549 0.136554 27.7672 0.396584 28.2188C0.656614 28.6704 1.03072 29.0454 1.48129 29.3061C1.93185 29.5669 2.44298 29.7041 2.96326 29.704H13.2456C17.3195 29.704 20.3239 27.9106 22.3912 24.4118L27.4102 15.7008L30.0986 11.039L38.1667 25.0422H27.4102L24.7203 29.704ZM13.0779 25.0374L5.9022 25.0358L16.6586 6.36589L22.0257 15.7008L18.4322 21.9401C17.0593 24.2103 15.4996 25.0374 13.0779 25.0374Z"
fill="#00DC82"
/>
<svg class="nuxt-logo" viewBox="0 0 45 30" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M24.7203 29.704H41.1008C41.6211 29.7041 42.1322 29.5669 42.5828 29.3061C43.0334 29.0454 43.4075 28.6704 43.6675 28.2188C43.9275 27.7672 44.0643 27.2549 44.0641 26.7335C44.0639 26.2121 43.9266 25.6999 43.6662 25.2485L32.6655 6.15312C32.4055 5.70162 32.0315 5.32667 31.581 5.06598C31.1305 4.8053 30.6195 4.66805 30.0994 4.66805C29.5792 4.66805 29.0682 4.8053 28.6177 5.06598C28.1672 5.32667 27.7932 5.70162 27.5332 6.15312L24.7203 11.039L19.2208 1.48485C18.9606 1.03338 18.5864 0.658493 18.1358 0.397853C17.6852 0.137213 17.1741 0 16.6538 0C16.1336 0 15.6225 0.137213 15.1719 0.397853C14.7213 0.658493 14.3471 1.03338 14.0868 1.48485L0.397874 25.2485C0.137452 25.6999 0.000226653 26.2121 2.8053e-07 26.7335C-0.000226092 27.2549 0.136554 27.7672 0.396584 28.2188C0.656614 28.6704 1.03072 29.0454 1.48129 29.3061C1.93185 29.5669 2.44298 29.7041 2.96326 29.704H13.2456C17.3195 29.704 20.3239 27.9106 22.3912 24.4118L27.4102 15.7008L30.0986 11.039L38.1667 25.0422H27.4102L24.7203 29.704ZM13.0779 25.0374L5.9022 25.0358L16.6586 6.36589L22.0257 15.7008L18.4322 21.9401C17.0593 24.2103 15.4996 25.0374 13.0779 25.0374Z" fill="#00DC82" />
</svg>
</template>
<style>
.nuxt-logo {
height: 20%;
display: block;
margin-left: auto;
margin-right: auto;
margin-bottom: 15px;
height: 180px;
}
</style>
......@@ -42,9 +42,7 @@
Sign in
</a>
<span class="delimiter">/</span>
<a href="#register" class="register-toggle link-to-tab d-md-show ml-0"
>Register</a
>
<a href="#register" class="register-toggle link-to-tab d-md-show ml-0">Register</a>
</div>
</div>
<!-- end header top -->
......@@ -57,12 +55,7 @@
</a>
<div class="header-search">
<form action="" class="form-input">
<input
type="text"
name="search"
placeholder="Search..."
class="form-control"
/>
<input type="text" name="search" placeholder="Search..." class="form-control" />
<button type="submit" value="btn" class="btn btn-search">
<b-icon icon="search"></b-icon>
</button>
......@@ -108,7 +101,7 @@
<div class="header-bottom d-flex">
<div class="header-left">
<NavBar />
<NavigationBar />
</div>
<div class="header-right">
......@@ -118,22 +111,23 @@
</template>
<script>
import NavBar from "@/components/Shared/Header/NavBar";
import LoginForm from "@/components/Shared/Header/LoginForm";
import NavigationBar from "@/components/Shared/Header/NavigationBar"
import LoginForm from "@/components/Shared/Header/LoginForm"
export default {
name: "Header",
components: {
NavBar,
NavigationBar,
LoginForm,
},
methods: {
openModal() { this.$bvModal.show('modal-login') }
openModal() {
this.$bvModal.show('modal-login')
}
}
};
</script>
<style>
:root {
--color: #26c;
}
......@@ -256,10 +250,12 @@ a:hover {
font-weight: bold;
margin-bottom: 0;
}
.header-right .cart .icon-bag {
width: fit-content;
height: fit-content;
}
.cart-count {
position: absolute;
margin-left: -0.7rem;
......@@ -295,7 +291,7 @@ a:hover {
font-weight: normal;
}
.dropdown:hover .category-item > a {
.dropdown:hover .category-item>a {
color: var(--color);
}
</style>
\ No newline at end of file
<template>
<b-modal id="modal-login" title="Create User" class="modal fade" v-if="showModal">
<p class="my-4">
<form >
<form>
<label>Name :</label>
<input
type="text"
class="form-control mb-2"
placeholder="name"
v-model="name"
max="255"
min="1"
required
/>
<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
/>
<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
/>
<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 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>
......@@ -41,21 +22,18 @@
<script>
export default {
name: "LoginForm",
name: 'LoginForm',
data() {
return {
}
},
methods: {
show() {
this.showModal = true
},
hide(){
hide() {
this.showModal = false
}
}
}
</script>
\ No newline at end of file
......@@ -5,15 +5,8 @@
<div class="dropdown" v-for="(item, index) in categories" :key="index">
<div class="category-item" v-if="item.ordering == 1">
<a href="">{{ item.name }}</a>
<ul
class="category-children dropdown-box"
v-if="item.children.length > 0"
>
<li
class="category-child"
v-for="(children, index) in item.children"
:key="index"
>
<ul class="category-children dropdown-box" v-if="item.children.length > 0">
<li class="category-child" v-for="(children, index) in item.children" :key="index">
<a href="">{{ children.name }}</a>
</li>
</ul>
......@@ -24,34 +17,35 @@
</template>
<script>
import axios from "axios";
import axios from 'axios'
export default {
name: "NavBar",
name: 'NavigationBar',
data() {
return {
categories: [],
};
}
},
mounted() {
this.getCategories();
this.getCategories()
},
methods: {
async getCategories() {
try {
const response = await axios.get(
"http://localhost:8000/api/categories"
);
console.log(response.data.data);
this.categories = response.data.data;
'http://localhost:8000/api/categories'
)
console.log(response.data.data)
this.categories = response.data.data
} catch (error) {
console.error(error);
console.error(error)
}
},
},
};
}
</script>
<style scoped>
</style>
\ No newline at end of file
<!-- Please remove this file from your project -->
<template>
<div class="relative flex items-top justify-center min-h-screen bg-gray-100 sm:items-center sm:pt-0">
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.1.2/dist/tailwind.min.css" rel="stylesheet">
<div class="max-w-4xl mx-auto sm:px-6 lg:px-8">
<a class="flex justify-center pt-8 sm:pt-0" href="https://nuxtjs.org" target="_blank">
<svg width="218" height="45" viewBox="0 0 159 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M55.5017 6.81866H60.1727L70.0719 22.9912V6.81866H74.3837V29.7345H69.7446L59.8135 13.5955V29.7345H55.5017V6.81866Z" fill="#003543" /> <path d="M93.657 29.7344H89.6389V27.1747C88.7241 28.9761 86.8628 29.9904 84.5113 29.9904C80.7869 29.9904 78.3684 27.3059 78.3684 23.4423V13.2339H82.3865V22.5976C82.3865 24.8566 83.7594 26.4276 85.8171 26.4276C88.0712 26.4276 89.6389 24.6598 89.6389 22.2377V13.2339H93.657V29.7344Z" fill="#003543" /> <path d="M107.64 29.7344L103.784 24.2342L99.9291 29.7344H95.6492L101.596 21.1242L96.1074 13.2339H100.485L103.784 17.9821L107.051 13.2339H111.461L105.94 21.1242L111.886 29.7344H107.64Z" fill="#003543" /> <path d="M120.053 8.25848V13.2339H124.627V16.6063H120.053V24.7974C120.053 25.0725 120.162 25.3363 120.356 25.531C120.55 25.7257 120.813 25.8353 121.087 25.8357H124.627V29.728H121.98C118.386 29.728 116.035 27.6323 116.035 23.9687V16.6095H112.801V13.2339H114.83C115.776 13.2339 116.327 12.6692 116.327 11.7349V8.25848H120.053Z" fill="#003543" /> <path d="M134.756 24.5446V6.81866H139.066V23.1864C139.066 27.6067 136.943 29.7345 133.349 29.7345H128.332V25.8421H133.461C133.804 25.8421 134.134 25.7054 134.377 25.4621C134.619 25.2188 134.756 24.8888 134.756 24.5446Z" fill="#003543" /> <path d="M141.649 22.0409H145.799C146.029 24.6006 147.728 26.2308 150.472 26.2308C152.923 26.2308 154.623 25.2501 154.623 23.2199C154.623 18.3085 142.331 21.7129 142.331 12.9395C142.334 9.17515 145.568 6.55945 150.215 6.55945C155.05 6.55945 158.317 9.34153 158.516 13.6306H154.388C154.193 11.6341 152.632 10.2918 150.207 10.2918C147.953 10.2918 146.548 11.3397 146.548 12.9427C146.548 18.0173 159 14.2226 159 23.1576C159 27.4131 155.504 30 150.474 30C145.279 30 141.882 26.8563 141.654 22.0441" fill="#003543" /> <path d="M24.7203 29.704H41.1008C41.6211 29.7041 42.1322 29.5669 42.5828 29.3061C43.0334 29.0454 43.4075 28.6704 43.6675 28.2188C43.9275 27.7672 44.0643 27.2549 44.0641 26.7335C44.0639 26.2121 43.9266 25.6999 43.6662 25.2485L32.6655 6.15312C32.4055 5.70162 32.0315 5.32667 31.581 5.06598C31.1305 4.8053 30.6195 4.66805 30.0994 4.66805C29.5792 4.66805 29.0682 4.8053 28.6177 5.06598C28.1672 5.32667 27.7932 5.70162 27.5332 6.15312L24.7203 11.039L19.2208 1.48485C18.9606 1.03338 18.5864 0.658493 18.1358 0.397853C17.6852 0.137213 17.1741 0 16.6538 0C16.1336 0 15.6225 0.137213 15.1719 0.397853C14.7213 0.658493 14.3471 1.03338 14.0868 1.48485L0.397874 25.2485C0.137452 25.6999 0.000226653 26.2121 2.8053e-07 26.7335C-0.000226092 27.2549 0.136554 27.7672 0.396584 28.2188C0.656614 28.6704 1.03072 29.0454 1.48129 29.3061C1.93185 29.5669 2.44298 29.7041 2.96326 29.704H13.2456C17.3195 29.704 20.3239 27.9106 22.3912 24.4118L27.4102 15.7008L30.0986 11.039L38.1667 25.0422H27.4102L24.7203 29.704ZM13.0779 25.0374L5.9022 25.0358L16.6586 6.36589L22.0257 15.7008L18.4322 21.9401C17.0593 24.2103 15.4996 25.0374 13.0779 25.0374Z" fill="#00DC82" /></svg>
</a>
<div class="mt-8 bg-white overflow-hidden shadow sm:rounded-lg p-6">
<h2 class="text-2xl leading-7 font-semibold">
Welcome to your Nuxt Application
</h2>
<p class="mt-3 text-gray-600">
We recommend you take a look at the <a href="https://nuxtjs.org" target="_blank" class="button--doc text-green-500 hover:underline">Nuxt Documentation</a>, whether you are new or have previous experience with the framework.<br>
</p>
<p class="mt-4 pt-4 text-gray-800 border-t border-dashed">
To get started, remove <code class="bg-gray-100 text-sm p-1 rounded border">components/Tutorial.vue</code> and start coding in <code class="bg-gray-100 text-sm p-1 rounded border">pages/index.vue</code>. Have fun!
</p>
</div>
<div class="flex justify-center pt-4 space-x-2">
<a href="https://github.com/nuxt/nuxt.js" target="_blank"><svg
class="w-6 h-6 text-gray-600 hover:text-gray-800 button--github"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
aria-hidden="true"
role="img"
width="32"
height="32"
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 24 24"
><path d="M12 2.247a10 10 0 0 0-3.162 19.487c.5.088.687-.212.687-.475c0-.237-.012-1.025-.012-1.862c-2.513.462-3.163-.613-3.363-1.175a3.636 3.636 0 0 0-1.025-1.413c-.35-.187-.85-.65-.013-.662a2.001 2.001 0 0 1 1.538 1.025a2.137 2.137 0 0 0 2.912.825a2.104 2.104 0 0 1 .638-1.338c-2.225-.25-4.55-1.112-4.55-4.937a3.892 3.892 0 0 1 1.025-2.688a3.594 3.594 0 0 1 .1-2.65s.837-.262 2.75 1.025a9.427 9.427 0 0 1 5 0c1.912-1.3 2.75-1.025 2.75-1.025a3.593 3.593 0 0 1 .1 2.65a3.869 3.869 0 0 1 1.025 2.688c0 3.837-2.338 4.687-4.563 4.937a2.368 2.368 0 0 1 .675 1.85c0 1.338-.012 2.413-.012 2.75c0 .263.187.575.687.475A10.005 10.005 0 0 0 12 2.247z" fill="currentColor" /></svg></a>
<a href="https://twitter.com/nuxt_js" target="_blank"><svg
class="w-6 h-6 text-gray-600 hover:text-gray-800"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
aria-hidden="true"
role="img"
width="32"
height="32"
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 24 24"
><path d="M22.46 6c-.77.35-1.6.58-2.46.69c.88-.53 1.56-1.37 1.88-2.38c-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29c0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15c0 1.49.75 2.81 1.91 3.56c-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07a4.28 4.28 0 0 0 4 2.98a8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21C16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56c.84-.6 1.56-1.36 2.14-2.23z" fill="currentColor" /></svg></a>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'NuxtTutorial'
}
</script>
<template>
<img
class="vuetify-logo"
alt="Vuetify Logo"
src="/vuetify-logo.svg"
>
</template>
<style>
.vuetify-logo {
height: 180px;
width: 180px;
transform: rotateY(560deg);
animation: turn 3.5s ease-out forwards 1s;
}
@keyframes turn {
100% {
transform: rotateY(0deg);
}
}
</style>
......@@ -2,20 +2,10 @@
<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
>
<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-select id="backdrop-variant" v-model="variant" :options="variants"></b-form-select>
</b-form-group>
</div>
</b-sidebar>
......@@ -23,27 +13,27 @@
</template>
<script>
export default {
name: "SideBar",
};
name: 'SideBar',
}
</script>
<script>
export default {
data() {
return {
variant: "dark",
variant: 'dark',
variants: [
"transparent",
"white",
"light",
"dark",
"primary",
"secondary",
"success",
"danger",
"warning",
"info",
'transparent',
'white',
'light',
'dark',
'primary',
'secondary',
'success',
'danger',
'warning',
'info',
],
};
},
};
}
</script>
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"~/*": ["./*"],
"@/*": ["./*"],
"~~/*": ["./*"],
"@@/*": ["./*"]
}
},
"exclude": ["node_modules", ".nuxt", "dist"]
}
<template>
<div>
<Nav />
<Navbar />
<nuxt />
</div>
</template>
<script>
import Nav from "@/components/Nav";
import SideBar from "@/components/SideBar";
import Navbar from '@/components/Navbar'
export default {
components: { Nav },
components: { Navbar },
};
</script>
<template>
<div>
<Header />
<nuxt />
</div>
<v-app dark>
<v-navigation-drawer
v-model="drawer"
:mini-variant="miniVariant"
:clipped="clipped"
fixed
app
>
<v-list>
<v-list-item
v-for="(item, i) in items"
:key="i"
:to="item.to"
router
exact
>
<v-list-item-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>{{ item.title }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-navigation-drawer>
<v-app-bar
:clipped-left="clipped"
fixed
app
>
<v-app-bar-nav-icon @click.stop="drawer = !drawer" />
<v-btn
icon
@click.stop="miniVariant = !miniVariant"
>
<v-icon>mdi-{{ `chevron-${miniVariant ? 'right' : 'left'}` }}</v-icon>
</v-btn>
<v-btn
icon
@click.stop="clipped = !clipped"
>
<v-icon>mdi-application</v-icon>
</v-btn>
<v-btn
icon
@click.stop="fixed = !fixed"
>
<v-icon>mdi-minus</v-icon>
</v-btn>
<v-toolbar-title>{{ title }}</v-toolbar-title>
<v-spacer />
<v-btn
icon
@click.stop="rightDrawer = !rightDrawer"
>
<v-icon>mdi-menu</v-icon>
</v-btn>
</v-app-bar>
<v-main>
<v-container>
<Nuxt />
</v-container>
</v-main>
<v-navigation-drawer
v-model="rightDrawer"
:right="right"
temporary
fixed
>
<v-list>
<v-list-item @click.native="right = !right">
<v-list-item-action>
<v-icon light>
mdi-repeat
</v-icon>
</v-list-item-action>
<v-list-item-title>Switch drawer (click me)</v-list-item-title>
</v-list-item>
</v-list>
</v-navigation-drawer>
<v-footer
:absolute="!fixed"
app
>
<span>&copy; {{ new Date().getFullYear() }}</span>
</v-footer>
</v-app>
</template>
<script>
import Header from "@/components/Shared/Header/Header";
import NavBar from "@/components/Shared/Header/NavBar";
import Footer from "@/components/Footer";
export default {
components: {
Header,
Footer,
NavBar,
name: 'DefaultLayout',
data () {
return {
clipped: false,
drawer: false,
fixed: false,
items: [
{
icon: 'mdi-apps',
title: 'Welcome',
to: '/'
},
};
{
icon: 'mdi-chart-bubble',
title: 'Inspire',
to: '/inspire'
}
],
miniVariant: false,
right: true,
rightDrawer: false,
title: 'Vuetify.js'
}
}
}
</script>
<template>
<v-app dark>
<h1 v-if="error.statusCode === 404">
{{ pageNotFound }}
</h1>
<h1 v-else>
{{ otherError }}
</h1>
<NuxtLink to="/">
Home page
</NuxtLink>
</v-app>
</template>
<script>
export default {
name: 'EmptyLayout',
layout: 'empty',
props: {
error: {
type: Object,
default: null
}
},
data () {
return {
pageNotFound: '404 Not Found',
otherError: 'An error occurred'
}
},
head () {
const title =
this.error.statusCode === 404 ? this.pageNotFound : this.otherError
return {
title
}
}
}
</script>
<style scoped>
h1 {
font-size: 20px;
}
</style>
import http from 'http'
export default function ({ route }) {
return http.post('http://my-stats-api.com', {
url: route.fullPath
})
}
\ No newline at end of file
export default ({ redirect }) => {
// console.log('[LOG]: middleware is running ...')
if (localStorage.getItem("token")=="") {
if (localStorage.getItem('token') == '') {
return redirect('/login')
}
};
\ No newline at end of file
}
\ No newline at end of file
export default {
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
ssr: false,
import colors from 'vuetify/es5/util/colors'
export default {
// Target: https://go.nuxtjs.dev/config-target
target: 'static',
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'KiaiSoft_Tuan_Anh',
title: 'web',
titleTemplate: '%s - web',
htmlAttrs: {
lang: 'en'
},
......@@ -24,7 +24,6 @@ export default {
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
......@@ -35,51 +34,49 @@ export default {
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
'@nuxtjs/vuetify',
// https://go.nuxtjs.dev/eslint
'@nuxtjs/eslint-module',
// https://go.nuxtjs.dev/vuetify
'@nuxtjs/vuetify'
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
// https://go.nuxtjs.dev/bootstrap
'bootstrap-vue/nuxt',
// https://go.nuxtjs.dev/axios
'@nuxtjs/axios',
'@nuxtjs/auth-next',
'@nuxtjs/toast',
'@pinia/nuxt',
],
bootstrapVue: {
icons: true
},
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {
baseURL: 'http://127.0.0.1:8000/api/',
debug: false,
proxyHeaders: true,
credentials: false,
// Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
baseURL: '/',
},
// publicRuntimeConfig: {
// axios: {
// browserBaseURL: process.env.BROWSER_BASE_URL
// }
// },
// privateRuntimeConfig: {
// axios: {
// baseURL: process.env.BASE_URL
// }
// },
auth: {
// Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify
vuetify: {
customVariables: ['~/assets/variables.scss'],
theme: {
dark: true,
themes: {
dark: {
primary: colors.blue.darken2,
accent: colors.grey.darken3,
secondary: colors.amber.darken3,
info: colors.teal.lighten1,
warning: colors.amber.base,
error: colors.deepOrange.accent4,
success: colors.green.accent3
}
}
}
},
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
},
// router: {
// middleware: 'web'
// }
toast: {
position: 'top-center',
register: [ // Register custom toasts
......
{
"name": "kiaisoft_tuan_anh",
"name": "web",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
"generate": "nuxt generate",
"lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
"lint": "yarn lint:js",
"lintfix": "yarn lint:js --fix"
},
"dependencies": {
"@nuxtjs/auth-next": "5.0.0-1667386184.dfbbb54",
"@nuxtjs/axios": "^5.0.0",
"@nuxtjs/axios": "^5.13.6",
"@nuxtjs/toast": "^3.3.1",
"@pinia/nuxt": "^0.4.6",
"axios": "^1.2.1",
"bootstrap": "^4.6.2",
"bootstrap-vue": "^2.23.1",
"core-js": "^3.25.3",
"jquery": "^3.6.3",
"jsonwebtoken": "^9.0.0",
"moment-jalaali": "^0.9.6",
"nuxt": "^2.15.8",
"pinia": "^2.0.29",
"pinia-plugin-persistedstate": "^3.0.2",
"prism-themes": "^1.9.0",
"vue": "^2.7.10",
"vue-axios": "^3.5.2",
"vue-notification": "^1.3.20",
"vue-server-renderer": "^2.7.10",
"vue-template-compiler": "^2.7.10",
"vue-toasted": "^1.1.28",
"vuetify": "^2.6.13"
"vuetify": "^2.6.10"
},
"devDependencies": {
"@babel/eslint-parser": "^7.19.1",
"@nuxtjs/eslint-config": "^11.0.0",
"@nuxtjs/eslint-module": "^3.1.0",
"@nuxtjs/vuetify": "^1.12.3",
"sass": "^1.57.1",
"sass-loader": "^10.4.1"
},
"description": "## Build Setup",
"main": "nuxt.config.js",
"repository": {
"type": "git",
"url": "https://gitlab.kiaisoft.com/kiaisoft.anh.tran2/kiaisoft_tuananh_nuxt.git"
},
"keywords": [],
"author": "",
"license": "ISC"
"eslint": "^8.24.0",
"eslint-plugin-nuxt": "^4.0.0",
"eslint-plugin-vue": "^9.5.1"
}
}
......@@ -8,101 +8,65 @@
<b-breadcrumb-item href="/categories">Category</b-breadcrumb-item>
</b-breadcrumb>
<div style="float: right">
<b-button v-b-modal.modal-create class="text-white">New Category</b-button></div>
<b-button v-b-modal.modal-create class="text-white">New Category</b-button>
</div>
<!-- create modal -->
<b-modal id="modal-create" title="Create Category" class="modal fade" >
<b-modal id="modal-create" title="Create Category" class="modal fade">
<p class="my-4">
<form @submit.prevent="createCategory" >
<form @submit.prevent="createCategory">
<label>Name :</label>
<input
type="text"
class="form-control mb-2"
placeholder="name"
v-model="name"
max="255"
min="1"
required
/>
<input type="text" class="form-control mb-2" placeholder="name" v-model="name" max="255" min="1" required />
<label>Parent :</label>
<b-form-select v-model="parent_id">
<option v-for="item in categories" :value="item.id" v-if="item.parent_id == null">
{{item.name}}
{{ item.name }}
</option>
</b-form-select>
<label>Ordering :</label>
<input
type="text"
class="form-control mb-2"
placeholder="Ordering"
v-model="ordering"
required
/>
<input type="text" class="form-control mb-2" placeholder="Ordering" v-model="ordering" required />
<label>Image :</label>
<b-form-file
@change="fileSelected"
v-model="image"
:state="Boolean(image)"
placeholder="Choose a image or drop it here..."
drop-placeholder="Drop file here..."
></b-form-file>
<b-form-file @change="fileSelected" v-model="image" :state="Boolean(image)"
placeholder="Choose a image or drop it here..." drop-placeholder="Drop file here..."></b-form-file>
</form>
</p>
<template #modal-footer>
<button v-b-modal.modal-close_visit @click="$bvModal.hide('modal-create')" 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="createCategory" v-b-modal.modal-close_visit class="btn btn-success btn-sm m-1">Submit</button>
</template>
</b-modal>
<!-- edit-modal -->
<b-modal id="modal-edit" title="Edit Category" class="modal fade" >
<b-modal id="modal-edit" title="Edit Category" class="modal fade">
<p class="my-4">
<form >
<form>
<label>Name :</label>
<input
type="text"
class="form-control mb-2"
placeholder="name"
v-model="eName"
max="255"
min="1"
value="this?.eName"
/>
<input type="text" class="form-control mb-2" placeholder="name" v-model="eName" max="255" min="1"
value="this?.eName" />
<label>Parent :</label>
<b-form-select v-model="eParentId">
<option v-for="item in categories" :value="item.id" :key="item.id">
{{item.name}}
{{ item.name }}
</option>
</b-form-select>
<label>Ordering :</label>
<input
type="text"
class="form-control mb-2"
placeholder="Ordering"
v-model="eOrdering"
value="this?.eOrdering"
/>
<input type="text" class="form-control mb-2" placeholder="Ordering" v-model="eOrdering"
value="this?.eOrdering" />
<!-- <b-form-select v-model="selected" :options="options"></b-form-select> -->
<label>Image :</label>
<b-form-file
v-model="eImage"
:state="Boolean(eImage)"
placeholder="Choose a image or drop it here..."
drop-placeholder="Drop file here..."
></b-form-file>
<b-form-file v-model="eImage" :state="Boolean(eImage)" placeholder="Choose a image or drop it here..."
drop-placeholder="Drop file here..."></b-form-file>
</form>
</p>
<template #modal-footer>
<button v-b-modal.modal-close_visit @click="$bvModal.hide('modal-edit')" class="btn btn-danger btn-sm m-1">Close</button>
<button @click="updateCategory(this?.eID)" v-b-modal.modal-close_visit class="btn btn-success btn-sm m-1">Submit</button>
<button v-b-modal.modal-close_visit @click="$bvModal.hide('modal-edit')"
class="btn btn-danger btn-sm m-1">Close</button>
<button @click="updateCategory(this?.eID)" v-b-modal.modal-close_visit
class="btn btn-success btn-sm m-1">Submit</button>
</template>
</b-modal>
<div>
<v-data-table
:headers="headers"
:items="categories"
sort-by="calories"
class="elevation-1"
>
<template v-slot:top >
<v-data-table :headers="headers" :items="categories" sort-by="calories" class="elevation-1">
<template v-slot:top>
<v-toolbar flat>
<v-toolbar-title>Category Manage</v-toolbar-title>
<v-divider class="mx-4" inset vertical></v-divider>
......@@ -118,34 +82,19 @@
<v-container>
<v-row>
<v-col cols="12" sm="6" md="4">
<v-text-field
v-model="editedItem.name"
label="name"
></v-text-field>
<v-text-field v-model="editedItem.name" label="name"></v-text-field>
</v-col>
<v-col cols="12" sm="6" md="4">
<v-text-field
v-model="editedItem.id"
label="id"
></v-text-field>
<v-text-field v-model="editedItem.id" label="id"></v-text-field>
</v-col>
<v-col cols="12" sm="6" md="4">
<v-text-field
v-model="editedItem.ordering"
label="ordering"
></v-text-field>
<v-text-field v-model="editedItem.ordering" label="ordering"></v-text-field>
</v-col>
<v-col cols="12" sm="6" md="4">
<v-text-field
v-model="editedItem.created_at"
label="created_at"
></v-text-field>
<v-text-field v-model="editedItem.created_at" label="created_at"></v-text-field>
</v-col>
<v-col cols="12" sm="6" md="4">
<v-text-field
v-model="editedItem.updated_at"
label="updated_at"
></v-text-field>
<v-text-field v-model="editedItem.updated_at" label="updated_at"></v-text-field>
</v-col>
</v-row>
</v-container>
......@@ -161,17 +110,11 @@
</v-dialog>
<v-dialog v-model="dialogDelete" max-width="500px">
<v-card>
<v-card-title class="text-h5"
>Are you sure you want to delete this item?</v-card-title
>
<v-card-title class="text-h5">Are you sure you want to delete this item?</v-card-title>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="blue darken-1" text @click="closeDelete"
>Cancel</v-btn
>
<v-btn color="blue darken-1" text @click="deleteItemConfirm"
>OK</v-btn
>
<v-btn color="blue darken-1" text @click="closeDelete">Cancel</v-btn>
<v-btn color="blue darken-1" text @click="deleteItemConfirm">OK</v-btn>
<v-spacer></v-spacer>
</v-card-actions>
</v-card>
......@@ -179,8 +122,8 @@
</v-toolbar>
</template>
<template v-slot:item.actions="{ item }">
<v-icon small class="mr-2" @click="editCategory(item)" :id ="item.id"> mdi-pencil </v-icon>
<v-icon small @click="deleteCategory(item.id,item)" :id ="item.id"> mdi-delete </v-icon>
<v-icon small class="mr-2" @click="editCategory(item)" :id="item.id"> mdi-pencil </v-icon>
<v-icon small @click="deleteCategory(item.id, item)" :id="item.id"> mdi-delete </v-icon>
</template>
<template v-slot:no-data>
<v-btn color="primary" @click="initialize"> Reset </v-btn>
......@@ -190,19 +133,14 @@
</div>
</template>
<script>
import Nav from "@/components/Nav";
import axios from "axios";
import { BootstrapVue, BootstrapVueIcons } from 'bootstrap-vue';
export default {
layout: 'admin',
components: { Nav },
middleware: ["web"],
middleware: ['web'],
data: () => {
return {
parent_id: null,
name:'',
ordering:'',
name: '',
ordering: '',
image: null,
error: '',
dialog: false,
......@@ -210,47 +148,47 @@ export default {
options: [],
headers: [
{
text: "Name",
align: "start",
text: 'Name',
align: 'start',
sortable: false,
value: "name",
value: 'name',
},
{ text: "id", value: "id" },
{ text: "ordering", value: "ordering" },
{ text: "parent", value: "parent_id", sortable: false },
{ text: "created_at", value: "created_at" },
{ text: "updated_at", value: "updated_at" },
{ text: 'id', value: 'id' },
{ text: 'ordering', value: 'ordering' },
{ text: 'parent', value: 'parent_id', sortable: false },
{ text: 'created_at', value: 'created_at' },
{ text: 'updated_at', value: 'updated_at' },
{ text: 'Actions', value: 'actions', sortable: false },
],
categories: [],
eID: '',
eName:'',
eOrdering:'',
eParentId:null,
eName: '',
eOrdering: '',
eParentId: null,
eImage: null,
message: [],
editedIndex: -1,
editedItem: {
name: "",
id: "",
ordering: "",
parent_id: "",
created_at: "",
updated_at: "",
name: '',
id: '',
ordering: '',
parent_id: '',
created_at: '',
updated_at: '',
},
defaultItem: {
name: "",
id: "",
ordering: "",
status: "",
created_at: "",
updated_at: "",
name: '',
id: '',
ordering: '',
status: '',
created_at: '',
updated_at: '',
},
}
},
computed: {
formTitle() {
return this.editedIndex === -1 ? "New Item" : "Edit Item"
return this.editedIndex === -1 ? 'New Item' : 'Edit Item'
},
},
watch: {
......@@ -268,7 +206,7 @@ export default {
methods: {
initialize() {
this.users = []
this.categories= []
this.categories = []
},
editItem(item) {
this.editedIndex = this.categories.indexOf(item)
......@@ -308,7 +246,7 @@ export default {
},
getCategories() {
this.$axios
.get("/categories/")
.get('/categories/')
.then((response) => (this.categories = response.data.data))
.catch(function (error) {
console.log(error)
......@@ -319,15 +257,15 @@ 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': this.$auth.$storage.getUniversal('token')
}
})
.then(response => {
......@@ -343,12 +281,12 @@ 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
})
})
},
fileSelected(event){
fileSelected(event) {
console.log(event)
const file = event.target.files[0]
this.url = URL.createObjectURL(file)
......@@ -356,20 +294,20 @@ export default {
console.log(file)
console.log(this.image)
},
deleteCategory(ID,index) {
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}`)
.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)
}
}
......@@ -380,10 +318,10 @@ export default {
editCategory(item) {
this.$bvModal.show('modal-edit')
this.eID = item.id
this.eName= item.name
this.eOrdering= item.ordering
this.eParentId= item.parent_id
this.eImage= item.images
this.eName = item.name
this.eOrdering = item.ordering
this.eParentId = item.parent_id
this.eImage = item.images
this.editedIndex = this.categories.indexOf(item)
console.log(this?.eID)
console.log(item)
......@@ -395,20 +333,21 @@ 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': this.$auth.$storage.getUniversal('token')
}
} )
})
.then(response => {
self.$toast.success('User updated successfully!',{
self.$toast.success('User updated successfully!', {
duration: 3000
})
console.log(response)
......@@ -416,10 +355,10 @@ export default {
this.$bvModal.hide('modal-edit')
Object.assign(this.categories[this.editedIndex], this.editedItem)
})
} catch(error){
} catch (error) {
console.log(error)
}
}
},
};
}
</script>
\ No newline at end of file
<template>
<div>
<div>
<h1 style="text-align: center">HOME</h1>
</div>
<v-row justify="center" align="center">
<v-col cols="12" sm="8" md="6">
<v-card class="logo py-4 d-flex justify-center">
<NuxtLogo />
<VuetifyLogo />
</v-card>
<v-card>
<v-card-title class="headline">
Welcome to the Vuetify + Nuxt.js template
</v-card-title>
<v-card-text>
<p>Vuetify is a progressive Material Design component framework for Vue.js. It was designed to empower developers to create amazing applications.</p>
<p>
For more information on Vuetify, check out the <a
href="https://vuetifyjs.com"
target="_blank"
rel="noopener noreferrer"
>
documentation
</a>.
</p>
<p>
If you have questions, please join the official <a
href="https://chat.vuetifyjs.com/"
target="_blank"
rel="noopener noreferrer"
title="chat"
>
discord
</a>.
</p>
<p>
Find a bug? Report it on the github <a
href="https://github.com/vuetifyjs/vuetify/issues"
target="_blank"
rel="noopener noreferrer"
title="contribute"
>
issue board
</a>.
</p>
<p>Thank you for developing with Vuetify and I look forward to bringing more exciting features in the future.</p>
<div class="text-xs-right">
<em><small>&mdash; John Leider</small></em>
</div>
<hr class="my-3">
<a
href="https://nuxtjs.org/"
target="_blank"
rel="noopener noreferrer"
>
Nuxt Documentation
</a>
<br>
<a
href="https://github.com/nuxt/nuxt.js"
target="_blank"
rel="noopener noreferrer"
>
Nuxt GitHub
</a>
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn
color="primary"
nuxt
to="/inspire"
>
Continue
</v-btn>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</template>
<script>
import { onMounted } from "vue";
import axios from "axios";
import VueAxios from "vue-axios";
import Nav from "@/components/Nav";
export default {
layout: "admin",
components: { Nav },
layout: 'admin',
middleware: ['web'],
};
}
</script>
<style></style>
<template>
<v-row justify="center" align="center">
<v-col cols="12" sm="8" md="6">
<v-card class="logo py-4 d-flex justify-center">
<NuxtLogo />
<VuetifyLogo />
</v-card>
<v-card>
<v-card-title class="headline">
Welcome to the Vuetify + Nuxt.js template
</v-card-title>
<v-card-text>
<p>Vuetify is a progressive Material Design component framework for Vue.js. It was designed to empower developers to create amazing applications.</p>
<p>
For more information on Vuetify, check out the <a
href="https://vuetifyjs.com"
target="_blank"
rel="noopener noreferrer"
>
documentation
</a>.
</p>
<p>
If you have questions, please join the official <a
href="https://chat.vuetifyjs.com/"
target="_blank"
rel="noopener noreferrer"
title="chat"
>
discord
</a>.
</p>
<p>
Find a bug? Report it on the github <a
href="https://github.com/vuetifyjs/vuetify/issues"
target="_blank"
rel="noopener noreferrer"
title="contribute"
>
issue board
</a>.
</p>
<p>Thank you for developing with Vuetify and I look forward to bringing more exciting features in the future.</p>
<div class="text-xs-right">
<em><small>&mdash; John Leider</small></em>
</div>
<hr class="my-3">
<a
href="https://nuxtjs.org/"
target="_blank"
rel="noopener noreferrer"
>
Nuxt Documentation
</a>
<br>
<a
href="https://github.com/nuxt/nuxt.js"
target="_blank"
rel="noopener noreferrer"
>
Nuxt GitHub
</a>
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn
color="primary"
nuxt
to="/inspire"
>
Continue
</v-btn>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</template>
<script>
export default {
name: 'IndexPage'
}
</script>
<template>
<v-row>
<v-col class="text-center">
<img
src="/v.png"
alt="Vuetify.js"
class="mb-5"
>
<blockquote class="blockquote">
&#8220;First, solve the problem. Then, write the code.&#8221;
<footer>
<small>
<em>&mdash;John Johnson</em>
</small>
</footer>
</blockquote>
</v-col>
</v-row>
</template>
<script>
export default {
name: 'InspirePage'
}
</script>
......@@ -58,13 +58,10 @@
</template>
<script>
import Nav from "@/components/Nav";
import notification from "@/components/notification";
import Toasted from "vue-toasted";
import notification from "@/components/notification"
export default {
layout: "none",
components: { Nav },
components: { notification },
components: { NuxtLogo },
};
......
......@@ -2,12 +2,7 @@
<div>
<b-breadcrumb>
<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
</b-breadcrumb-item>
<b-breadcrumb-item href="/posts">Post</b-breadcrumb-item>
......@@ -19,17 +14,8 @@
<div class="w-full mt-4 p-10">
<form>
<label for="input-live">Title :</label>
<b-form-input
id="input-live"
type="text"
class="form-control mb-2"
placeholder="name"
aria-describedby="input-live-help input-live-feedback"
v-model="title"
max="255"
min="1"
trim
>
<b-form-input id="input-live" type="text" class="form-control mb-2" placeholder="name"
aria-describedby="input-live-help input-live-feedback" v-model="title" max="255" min="1" trim>
</b-form-input>
<label>Category ID :</label>
<b-form-select v-model="category_id">
......@@ -38,48 +24,21 @@
</option>
</b-form-select>
<label>Content :</label>
<input
type="text"
class="form-control mb-2"
placeholder="Ordering"
v-model="content"
size="sm"
required
/>
<input type="text" class="form-control mb-2" placeholder="Ordering" v-model="content" size="sm" required />
<label>Author :</label>
<input
type="text"
class="form-control mb-2"
placeholder="Description"
v-model="user_id"
size="sm"
required
/>
<input type="text" class="form-control mb-2" placeholder="Description" v-model="user_id" size="sm" required />
<label>Status :</label>
<b-form-select v-model="status" :options="options"></b-form-select>
<label>Image :</label>
<b-form-file
v-model="images"
multiple
:state="Boolean(images)"
placeholder="Choose a image or drop it here..."
drop-placeholder="Drop file here..."
></b-form-file>
<b-form-file v-model="images" multiple :state="Boolean(images)"
placeholder="Choose a image or drop it here..." drop-placeholder="Drop file here..."></b-form-file>
</form>
</div>
<template #modal-footer>
<button
v-b-modal.modal-close_visit
@click="$bvModal.hide('modal-create')"
class="btn btn-danger btn-sm m-1"
>
<button v-b-modal.modal-close_visit @click="$bvModal.hide('modal-create')" class="btn btn-danger btn-sm m-1">
Close
</button>
<button
@click="createPost()"
v-b-modal.modal-close_visit
class="btn btn-success btn-sm m-1"
>
<button @click="createPost()" v-b-modal.modal-close_visit class="btn btn-success btn-sm m-1">
Submit
</button>
</template>
......@@ -89,44 +48,15 @@
<div class="w-full mt-4 p-10">
<form>
<label>Title :</label>
<input
type="text"
class="form-control mb-2"
v-model="sTitle"
size="sm"
disabled
/>
<input type="text" class="form-control mb-2" v-model="sTitle" size="sm" disabled />
<label>Category ID :</label>
<input
type="text"
class="form-control mb-2"
v-model="sCategoryId"
size="sm"
disabled
/>
<input type="text" class="form-control mb-2" v-model="sCategoryId" size="sm" disabled />
<label>Content :</label>
<input
type="text"
class="form-control mb-2"
v-model="sContent"
size="sm"
disabled
/>
<input type="text" class="form-control mb-2" v-model="sContent" size="sm" disabled />
<label>Author :</label>
<input
type="text"
class="form-control mb-2"
placeholder="Description"
v-model="sUserId"
size="sm"
disabled
/>
<input type="text" class="form-control mb-2" placeholder="Description" v-model="sUserId" size="sm" disabled />
<label>Status :</label>
<b-form-select
v-model="sStatus"
:options="options"
disabled
></b-form-select>
<b-form-select v-model="sStatus" :options="options" disabled></b-form-select>
<label>Image :</label>
<div v-for="(image, index) in sImages" :key="index">
<b-img :src="image" fluid alt="Fluid image"></b-img>
......@@ -134,11 +64,7 @@
</form>
</div>
<template #modal-footer>
<button
v-b-modal.modal-close_visit
@click="$bvModal.hide('modal-show')"
class="btn btn-danger btn-sm m-1"
>
<button v-b-modal.modal-close_visit @click="$bvModal.hide('modal-show')" class="btn btn-danger btn-sm m-1">
Close
</button>
</template>
......@@ -148,16 +74,8 @@
<div class="w-full mt-4 p-10">
<form>
<label>Title :</label>
<input
type="text"
class="form-control mb-2"
placeholder="name"
v-model="eTitle"
max="255"
min="1"
size="sm"
required
/>
<input type="text" class="form-control mb-2" placeholder="name" v-model="eTitle" max="255" min="1" size="sm"
required />
<label>Category ID :</label>
<b-form-select v-model="eCategoryId">
<option v-for="item in categories" :value="item.id">
......@@ -165,59 +83,28 @@
</option>
</b-form-select>
<label>Content :</label>
<input
type="text"
class="form-control mb-2"
placeholder="Ordering"
v-model="eContent"
size="sm"
required
/>
<input type="text" class="form-control mb-2" placeholder="Ordering" v-model="eContent" size="sm" required />
<label>Author :</label>
<input
type="text"
class="form-control mb-2"
placeholder="Description"
v-model="eUserId"
size="sm"
/>
<input type="text" class="form-control mb-2" placeholder="Description" v-model="eUserId" size="sm" />
<label>Status :</label>
<b-form-select v-model="eStatus" :options="options"></b-form-select>
<label>Image :</label>
<b-form-file
v-model="eImages"
multiple
:state="Boolean(eImages)"
placeholder="Choose a image or drop it here..."
drop-placeholder="Drop file here..."
></b-form-file>
<b-form-file v-model="eImages" multiple :state="Boolean(eImages)"
placeholder="Choose a image or drop it here..." drop-placeholder="Drop file here..."></b-form-file>
</form>
</div>
<template #modal-footer>
<button
v-b-modal.modal-close_visit
@click="$bvModal.hide('modal-edit')"
class="btn btn-danger btn-sm m-1"
>
<button v-b-modal.modal-close_visit @click="$bvModal.hide('modal-edit')" class="btn btn-danger btn-sm m-1">
Close
</button>
<button
@click="updatePost()"
v-b-modal.modal-close_visit
class="btn btn-success btn-sm m-1"
>
<button @click="updatePost()" v-b-modal.modal-close_visit class="btn btn-success btn-sm m-1">
Submit
</button>
</template>
</b-modal>
<!-- table -->
<div>
<v-data-table
:headers="headers"
:items="posts"
sort-by="calories"
class="elevation-1"
>
<v-data-table :headers="headers" :items="posts" sort-by="calories" class="elevation-1">
<template v-slot:top>
<v-toolbar flat>
<v-toolbar-title>Post Manage</v-toolbar-title>
......@@ -245,81 +132,76 @@
</template>
<script>
import Nav from "@/components/Nav";
import axios from "axios";
export default {
layout: "admin",
name: "App",
components: {
Nav,
},
middleware: ["web"],
layout: 'admin',
name: 'App',
middleware: ['web'],
data: () => {
return {
title: "",
title: '',
category_id: null,
content: "",
user_id: "",
content: '',
user_id: '',
status: null,
images: [],
dialog: false,
dialogDelete: false,
options: [
{ value: 1, text: "Draft" },
{ value: 2, text: "Publish" },
{ value: 3, text: "UnPublish" },
{ value: 1, text: 'Draft' },
{ value: 2, text: 'Publish' },
{ value: 3, text: 'UnPublish' },
],
headers: [
{
text: "Title",
align: "start",
text: 'Title',
align: 'start',
sortable: false,
value: "title",
value: 'title',
},
{ text: "Category ID", value: "category_id" },
{ text: "content", value: "content", sortable: false },
{ text: "author", value: "user_id" },
{ text: "status", value: "status" },
{ text: "Actions", value: "actions", sortable: false },
{ text: 'Category ID', value: 'category_id' },
{ text: 'content', value: 'content', sortable: false },
{ text: 'author', value: 'user_id' },
{ text: 'status', value: 'status' },
{ text: 'Actions', value: 'actions', sortable: false },
],
posts: [],
categories: [],
sTitle: "",
sCategoryId: "",
sContent: "",
sUserId: "",
sTitle: '',
sCategoryId: '',
sContent: '',
sUserId: '',
sStatus: null,
sImages: null,
eId: "",
eTitle: "",
eCategoryId: "",
eContent: "",
eUserId: "",
eStatus: "",
eId: '',
eTitle: '',
eCategoryId: '',
eContent: '',
eUserId: '',
eStatus: '',
eImages: null,
message: [],
editedIndex: -1,
editedItem: {
title: "",
category_id: "",
content: "",
user_id: "",
status: "",
title: '',
category_id: '',
content: '',
user_id: '',
status: '',
},
defaultItem: {
name: "",
id: "",
ordering: "",
status: "",
created_at: "",
updated_at: "",
name: '',
id: '',
ordering: '',
status: '',
created_at: '',
updated_at: '',
},
}
},
computed: {
formTitle() {
return this.editedIndex === -1 ? "New Item" : "Edit Item"
return this.editedIndex === -1 ? 'New Item' : 'Edit Item'
},
nameState() {
return this.name.length > 2 ? true : false
......@@ -341,11 +223,11 @@ export default {
this.posts = [],
this.product = [],
this.categories = [],
this.sTitle = "",
this.sCategoryId = "",
this.sContent = "",
this.sUserId = "",
this.sStatus = "",
this.sTitle = '',
this.sCategoryId = '',
this.sContent = '',
this.sUserId = '',
this.sStatus = '',
this.sImages = null
},
editItem(item) {
......@@ -386,7 +268,7 @@ export default {
},
getCategories() {
this.$axios
.get("/categories/")
.get('/categories/')
.then((response) => (this.categories = response.data.data))
.catch(function (error) {
console.log(error)
......@@ -394,7 +276,7 @@ export default {
},
getposts() {
this.$axios
.get("/posts/")
.get('/posts/')
.then((response) => (this.posts = response.data.data))
.catch(function (error) {
console.log(error)
......@@ -403,7 +285,7 @@ export default {
createPost() {
const self = this
this.$axios
.post("/posts/",
.post('/posts/',
{
title: this.title,
category_id: this.category_id,
......@@ -414,14 +296,14 @@ export default {
},
{
headers: {
"Content-Type": "multipart/form-data",
Authorization: this.$auth.$storage.getUniversal("token"),
'Content-Type': 'multipart/form-data',
Authorization: this.$auth.$storage.getUniversal('token'),
},
}
)
.then((response) => {
this.$bvModal.hide("modal-create")
self.$toast.success("Post created successfully!", {
this.$bvModal.hide('modal-create')
self.$toast.success('Post created successfully!', {
duration: 3000,
})
this.editedItem = response.data.data
......@@ -429,10 +311,10 @@ export default {
this.posts.push(this.editedItem)
})
.catch((errors) => {
this.$bvModal.hide("modal-create")
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,
})
})
......@@ -440,18 +322,18 @@ export default {
deletePost(ID, index) {
const self = this
this.editedIndex = this.posts.indexOf(index)
if (confirm("Do you really want to delete?")) {
if (confirm('Do you really want to delete?')) {
this.$axios
.delete(`/posts/${ID}`)
.then((response) => {
this.posts.splice(this.editedIndex, 1)
self.$toast.success("Post deleted successfully!", {
self.$toast.success('Post deleted successfully!', {
duration: 3000,
})
})
.catch((error) => {
console.log(error)
self.$toast.error("Error!", {
self.$toast.error('Error!', {
duration: 3000,
})
})
......@@ -461,10 +343,10 @@ export default {
const ID = item.id
try {
const resp = await this.$axios.get(`/posts/${ID}`, {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "multipart/form-data",
Authorization: this.$auth.$storage.getUniversal("token"),
'Content-Type': 'multipart/form-data',
Authorization: this.$auth.$storage.getUniversal('token'),
},
})
console.log(resp.data)
......@@ -477,10 +359,10 @@ export default {
} catch (error) {
console.log(error)
}
this.$bvModal.show("modal-show")
this.$bvModal.show('modal-show')
},
editPost(item) {
this.$bvModal.show("modal-edit")
this.$bvModal.show('modal-edit')
this.eId = item.id
this.eTitle = item.title
this.eCategoryId = item.category_id
......@@ -504,14 +386,14 @@ export default {
},
{
headers: {
"Content-Type": "multipart/form-data",
Authorization: this.$auth.$storage.getUniversal("token"),
'Content-Type': 'multipart/form-data',
Authorization: this.$auth.$storage.getUniversal('token'),
},
}
)
.then((response) => {
this.$bvModal.hide("modal-edit")
self.$toast.success("Post updated successfully!", {
this.$bvModal.hide('modal-edit')
self.$toast.success('Post updated successfully!', {
duration: 3000,
})
console.log(response)
......@@ -521,14 +403,16 @@ export default {
})
.catch((error) => {
console.log(error)
this.$bvModal.hide("modal-edit")
self.$toast.error("something went wrong while trying create!", {
this.$bvModal.hide('modal-edit')
self.$toast.error('something went wrong while trying create!', {
duration: 3000,
})
})
},
},
};
}
</script>
<style></style>
<style>
</style>
......@@ -316,16 +316,10 @@
</template>
<script>
import Nav from "@/components/Nav";
import axios from "axios";
export default {
layout: 'admin',
name: "App",
components: {
Nav,
},
middleware: ["web"],
name: 'App',
middleware: ['web'],
data: () => {
return {
name: '',
......@@ -337,9 +331,9 @@ export default {
images: [],
variants: [
{
color: "",
size: "",
quantity: "",
color: '',
size: '',
quantity: '',
},
],
dialog: false,
......@@ -347,16 +341,16 @@ export default {
options: [],
headers: [
{
text: "Name",
align: "start",
text: 'Name',
align: 'start',
sortable: false,
value: "name",
value: 'name',
},
{ text: "id", value: "id" },
{ text: "category ID", value: "category_id" },
{ text: "price", value: "price", sortable: false },
{ text: "description", value: "description" },
{ text: "stock", value: "stock" },
{ text: 'id', value: 'id' },
{ text: 'category ID', value: 'category_id' },
{ text: 'price', value: 'price', sortable: false },
{ text: 'description', value: 'description' },
{ text: 'stock', value: 'stock' },
{ text: 'Actions', value: 'actions', sortable: false },
],
products: [],
......@@ -370,9 +364,9 @@ export default {
sImages: null,
sVariants: [
{
color: "",
size: "",
quantity: "",
color: '',
size: '',
quantity: '',
},
],
eId: '',
......@@ -384,33 +378,33 @@ export default {
eImages: null,
eVariants: [
{
color: "",
size: "",
quantity: "",
color: '',
size: '',
quantity: '',
},
],
message: [],
editedIndex: -1,
editedItem: {
name: "",
category_id: "",
price: "",
description: "",
stock: "",
name: '',
category_id: '',
price: '',
description: '',
stock: '',
},
defaultItem: {
name: "",
id: "",
ordering: "",
status: "",
created_at: "",
updated_at: "",
name: '',
id: '',
ordering: '',
status: '',
created_at: '',
updated_at: '',
},
}
},
computed: {
formTitle() {
return this.editedIndex === -1 ? "New Item" : "Edit Item"
return this.editedIndex === -1 ? 'New Item' : 'Edit Item'
},
nameState() {
return this.name.length > 2 ? true : false
......@@ -442,9 +436,9 @@ export default {
this.sImages= null,
this.sVariants= [
{
color: "",
size: "",
quantity: "",
color: '',
size: '',
quantity: '',
},
]
......@@ -487,7 +481,7 @@ export default {
},
getCategories() {
this.$axios
.get("/categories/")
.get('/categories/')
.then((response) => (this.categories = response.data.data))
.catch(function (error) {
console.log(error)
......@@ -495,7 +489,7 @@ export default {
},
getProducts() {
this.$axios
.get("/products/")
.get('/products/')
.then((response) => (this.products = response.data.data))
.catch(function (error) {
console.log(error)
......@@ -503,8 +497,8 @@ export default {
},
createProduct() {
const self = this
// const set = new Set([this.images]);
// const images = Array.from(set);
// const set = new Set([this.images])
// const images = Array.from(set)
this.$axios
.post('/products/',{
name: this.name,
......@@ -540,7 +534,7 @@ export default {
deleteProduct(ID,index) {
const self = this
this.editedIndex = this.products.indexOf(index)
if(confirm("Do you really want to delete?")){
if(confirm('Do you really want to delete?')){
try{
this.$axios
.delete(`/products/${ID}`)
......@@ -559,10 +553,10 @@ export default {
const ID = item.id
try {
const resp = await this.$axios.get(`/products/${ID}`, {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "multipart/form-data",
Authorization: this.$auth.$storage.getUniversal("token"),
'Content-Type': 'multipart/form-data',
Authorization: this.$auth.$storage.getUniversal('token'),
},
})
this.sName = resp.data.data.name
......@@ -601,8 +595,8 @@ export default {
variants: this.eVariants,
}, {
headers: {
"Content-Type": "multipart/form-data",
"Authorization": this.$auth.$storage.getUniversal("token")
'Content-Type': 'multipart/form-data',
'Authorization': this.$auth.$storage.getUniversal('token')
}
} )
.then(response => {
......@@ -620,16 +614,16 @@ export default {
},
addMore() {
this.variants.push({
color: "",
size: "",
quantity: "",
color: '',
size: '',
quantity: '',
})
},
addMoreVariant() {
this.eVariants.push({
color: "",
size: "",
quantity: "",
color: '',
size: '',
quantity: '',
})
},
remove(index) {
......@@ -639,8 +633,5 @@ export default {
this.eVariants.splice(index, 1)
},
},
};
}
</script>
\ No newline at end of file
<style>
</style>
\ No newline at end of file
<template>
<div style="background-color: #8fc2ff">
<div
class="container"
style="
<div class="container" style="
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #8fc2ff;
"
>
">
<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 mb-2"
placeholder="name"
v-model="name"
max="255"
min="1"
required
/>
<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
/>
<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
/>
<input type="password" class="form-control mb-2" placeholder="password" v-model="password" required />
<label>Confirm Password :</label>
<input
type="password"
class="form-control mb-2"
placeholder="Confirm password"
v-model="confirm_password"
required
/>
<input type="password" class="form-control mb-2" placeholder="Confirm password" v-model="confirm_password"
required />
<div class="button">
<button class="w-50 btn btn-lg btn-primary" type="submit">
Sign up
......@@ -59,25 +31,24 @@
</template>
<script>
import { reactive } from "vue";
export default {
layout: "none",
layout: 'none',
data: () => {
return {
name: "",
email: "",
password: "",
confirm_password: "",
};
name: '',
email: '',
password: '',
confirm_password: '',
}
},
methods: {
signin() {
fetch("http://127.0.0.1:8000/api/register", {
method: "POST",
fetch('http://127.0.0.1:8000/api/register', {
method: 'POST',
headers: {
"Content-Type": "application/json",
Accept: "application/json",
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify({
name: this.name,
......@@ -85,11 +56,11 @@ export default {
password: this.password,
confirm_password: this.confirm_password,
}),
});
this.$router.push("/");
})
this.$router.push('/')
},
},
};
}
</script>
<style scoped>
#form-logout {
......@@ -104,6 +75,7 @@ export default {
border-radius: 3%;
font-weight: 600;
}
.btn {
align-items: center;
justify-content: center;
......
......@@ -12,88 +12,46 @@
<div style="float: right">
<b-button v-b-modal.modal-login class="text-white">New User</b-button>
<!-- modal create user -->
<b-modal id="modal-login" title="Create User" class="modal fade" >
<b-modal id="modal-login" title="Create User" class="modal fade">
<Notification :message="error" v-if="error" />
<p class="my-4">
<form @submit.prevent="createUser" >
<form @submit.prevent="createUser">
<label>Name :</label>
<input
type="text"
class="form-control mb-2"
placeholder="name"
v-model="name"
max="255"
min="1"
required
/>
<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
/>
<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
/>
<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 v-b-modal.modal-close_visit @click="$bvModal.hide('modal-login')"
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>
</template>
</b-modal>
<!-- modal edit user -->
<b-modal id="modal-edit" title="Edit User" class="modal fade" >
<b-modal id="modal-edit" title="Edit User" class="modal fade">
<p class="my-4">
<form @submit.prevent="" >
<form @submit.prevent="">
<label>Name :</label>
<input
type="text"
class="form-control mb-2"
placeholder="name"
v-model="eName"
max="255"
min="1"
required
/>
<input type="text" class="form-control mb-2" placeholder="name" v-model="eName" max="255" min="1" required />
<label>Email :</label>
<input
type="email"
class="form-control mb-2"
placeholder="Email"
v-model="eEmail"
required
/>
<input type="email" class="form-control mb-2" placeholder="Email" v-model="eEmail" required />
<label>Password :</label>
<input
type="password"
class="form-control mb-2"
placeholder="password"
v-model="ePassword"
required
/>
<input type="password" class="form-control mb-2" placeholder="password" v-model="ePassword" required />
</form>
</p>
<template #modal-footer>
<button v-b-modal.modal-close_visit @click="$bvModal.hide('modal-edit')" class="btn btn-danger btn-sm m-1">Close</button>
<button @click="updateUser(this?.eID)" v-b-modal.modal-close_visit class="btn btn-success btn-sm m-1">Submit</button>
<button v-b-modal.modal-close_visit @click="$bvModal.hide('modal-edit')"
class="btn btn-danger btn-sm m-1">Close</button>
<button @click="updateUser(this?.eID)" v-b-modal.modal-close_visit
class="btn btn-success btn-sm m-1">Submit</button>
</template>
</b-modal>
</div>
<v-data-table
:headers="headers"
:items="users"
sort-by="calories"
class="elevation-1"
>
<template v-slot:top >
</div>
<v-data-table :headers="headers" :items="users" sort-by="calories" class="elevation-1">
<template v-slot:top>
<v-toolbar flat>
<v-toolbar-title>User Manage</v-toolbar-title>
<v-divider class="mx-4" inset vertical></v-divider>
......@@ -110,34 +68,19 @@
<v-container>
<v-row>
<v-col cols="12" sm="6" md="4">
<v-text-field
v-model="editedItem.name"
label="name"
></v-text-field>
<v-text-field v-model="editedItem.name" label="name"></v-text-field>
</v-col>
<v-col cols="12" sm="6" md="4">
<v-text-field
v-model="editedItem.id"
label="id"
></v-text-field>
<v-text-field v-model="editedItem.id" label="id"></v-text-field>
</v-col>
<v-col cols="12" sm="6" md="4">
<v-text-field
v-model="editedItem.email"
label="email"
></v-text-field>
<v-text-field v-model="editedItem.email" label="email"></v-text-field>
</v-col>
<v-col cols="12" sm="6" md="4">
<v-text-field
v-model="editedItem.created_at"
label="created_at"
></v-text-field>
<v-text-field v-model="editedItem.created_at" label="created_at"></v-text-field>
</v-col>
<v-col cols="12" sm="6" md="4">
<v-text-field
v-model="editedItem.updated_at"
label="updated_at"
></v-text-field>
<v-text-field v-model="editedItem.updated_at" label="updated_at"></v-text-field>
</v-col>
</v-row>
</v-container>
......@@ -153,17 +96,11 @@
</v-dialog>
<v-dialog v-model="dialogDelete" max-width="500px">
<v-card>
<v-card-title class="text-h5"
>Are you sure you want to delete this item?</v-card-title
>
<v-card-title class="text-h5">Are you sure you want to delete this item?</v-card-title>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="blue darken-1" text @click="closeDelete"
>Cancel</v-btn
>
<v-btn color="blue darken-1" text @click="deleteItemConfirm"
>OK</v-btn
>
<v-btn color="blue darken-1" text @click="closeDelete">Cancel</v-btn>
<v-btn color="blue darken-1" text @click="deleteItemConfirm">OK</v-btn>
<v-spacer></v-spacer>
</v-card-actions>
</v-card>
......@@ -171,8 +108,8 @@
</v-toolbar>
</template>
<template v-slot:item.actions="{ item }">
<v-icon small class="mr-2" @click=" editUser(item)" :id ="item.id"> mdi-pencil </v-icon>
<v-icon small @click="deleteUser(item.id, item)" :id ="item.id"> mdi-delete </v-icon>
<v-icon small class="mr-2" @click="editUser(item)" :id="item.id"> mdi-pencil </v-icon>
<v-icon small @click="deleteUser(item.id, item)" :id="item.id"> mdi-delete </v-icon>
</template>
<template v-slot:no-data>
<v-btn color="primary" @click="initialize"> Reset </v-btn>
......@@ -181,63 +118,59 @@
</div>
</template>
<script>
import Nav from "@/components/Nav";
import axios from "axios";
export default {
layout: "admin",
components: { Nav },
middleware: ["web"],
layout: 'admin',
middleware: ['web'],
data: () => {
return {
email:'',
name:'',
password:'',
email: '',
name: '',
password: '',
error: '',
dialog: false,
dialogDelete: false,
headers: [
{
text: "Name",
align: "start",
text: 'Name',
align: 'start',
sortable: false,
value: "name",
value: 'name',
},
{ text: "id", value: "id" },
{ text: "email", value: "email" },
{ text: "status", value: "id", sortable: false },
{ text: "created_at", value: "created_at" },
{ text: "updated_at", value: "updated_at" },
{ text: 'id', value: 'id' },
{ text: 'email', value: 'email' },
{ text: 'status', value: 'id', sortable: false },
{ text: 'created_at', value: 'created_at' },
{ text: 'updated_at', value: 'updated_at' },
{ text: 'Actions', value: 'actions', sortable: false },
],
users: [],
eIndex: [],
eID: '',
eEmail:'',
eName:'',
ePassword:'',
eEmail: '',
eName: '',
ePassword: '',
message: [],
editedIndex: -1,
editedItem: {
name: "",
id: "",
email: "",
created_at: "",
updated_at: "",
name: '',
id: '',
email: '',
created_at: '',
updated_at: '',
},
defaultItem: {
name: "",
id: "",
email: "",
status: "",
created_at: "",
updated_at: "",
name: '',
id: '',
email: '',
status: '',
created_at: '',
updated_at: '',
},
}
},
computed: {
formTitle() {
return this.editedIndex === -1 ? "New Item" : "Edit Item"
return this.editedIndex === -1 ? 'New Item' : 'Edit Item'
},
},
watch: {
......@@ -304,18 +237,18 @@ export default {
createUser() {
const self = this
this.$axios
.post('/users/',{
.post('/users/', {
headers: {
'Content-Type': 'application/json'
},
email: this.email,
password: this.password,
name:this.name,
name: this.name,
})
.then(response => {
// $bvModal.hide('modal-login');
// $bvModal.hide('modal-login')
this.$bvModal.hide('modal-login')
self.$toast.success('User created successfully!',{
self.$toast.success('User created successfully!', {
duration: 3000
})
console.log(response)
......@@ -327,7 +260,7 @@ export default {
this.$bvModal.hide('modal-login')
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
})
})
......@@ -335,18 +268,18 @@ export default {
deleteUser(userID, index) {
const self = this
this.editedIndex = this.users.indexOf(index)
if(confirm("Do you really want to delete?")){
try{
if (confirm('Do you really want to delete?')) {
try {
this.$axios
.delete(`/users/${userID}`)
.then(response => {
console.log(response.data)
this.users.splice(this.editedIndex, 1)
self.$toast.success('User deleted successfully!',{
self.$toast.success('User deleted successfully!', {
duration: 3000
})
})
} catch(error){
} catch (error) {
console.log(error)
}
}
......@@ -364,14 +297,15 @@ export default {
console.log(this.eName)
console.log(this.eEmail)
console.log(this?.eID)
try{
try {
this.$axios
.put(`/users/${this?.eID}`,{
.put(`/users/${this?.eID}`, {
email: this.eEmail,
password: this.ePassword,
name:this.eName,} )
name: this.eName,
})
.then(response => {
self.$toast.success('User updated successfully!',{
self.$toast.success('User updated successfully!', {
duration: 3000
})
console.log(response)
......@@ -379,10 +313,10 @@ export default {
this.$bvModal.hide('modal-edit')
Object.assign(this.users[this.editedIndex], this.editedItem)
})
} catch(error){
} catch (error) {
console.log(error)
}
}
},
};
}
</script>
export default function ({ $axios }, inject) {
export default function ({ $axios }, inject, redirect) {
$axios.onError(error => {
if(error.response.status === 500) {
redirect('/500')
}
})
$axios.onError(error => {
const code = parseInt(error.response && error.response.status)
if (code === 400) {
redirect('/400')
}
})
const api = $axios.create({
headers: {
......@@ -8,9 +20,6 @@ export default function ({ $axios }, inject) {
}
})
// Set baseURL to something different
api.setBaseURL('http://127.0.0.1:8000/api/')
// Inject to context as $api
inject('api', api)
}
\ No newline at end of file
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 87.5 100"><defs><style>.cls-1{fill:#1697f6;}.cls-2{fill:#7bc6ff;}.cls-3{fill:#1867c0;}.cls-4{fill:#aeddff;}</style></defs><title>Artboard 46</title><polyline class="cls-1" points="43.75 0 23.31 0 43.75 48.32"/><polygon class="cls-2" points="43.75 62.5 43.75 100 0 14.58 22.92 14.58 43.75 62.5"/><polyline class="cls-3" points="43.75 0 64.19 0 43.75 48.32"/><polygon class="cls-4" points="64.58 14.58 87.5 14.58 43.75 100 43.75 62.5 64.58 14.58"/></svg>
This source diff could not be displayed because it is too large. You can view the blob instead.
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