diff --git a/front/vue-project/src/components/Components.vue b/front/vue-project/src/components/Components.vue index 6d92889..847b766 100644 --- a/front/vue-project/src/components/Components.vue +++ b/front/vue-project/src/components/Components.vue @@ -20,17 +20,18 @@ export default { dataFilterUrl: 'component/filter?' } }, + methods: { filter() { let urlParams = "" - if (document.getElementById('componentNameFilterInput').value != "") { - if (urlParams != "") { + if (document.getElementById('componentNameFilterInput').value !== "") { + if (urlParams !== "") { urlParams += "&"; } urlParams += "componentName=" + this.componentName; } - if (document.getElementById('componentAmountFilterInput').value != "") { - if (urlParams != "") { + if (document.getElementById('componentAmountFilterInput').value !== "") { + if (urlParams !== "") { urlParams += "&"; } urlParams += "amount=" + this.amount; @@ -46,6 +47,11 @@ export default { this.componentName = null; this.amount = null; } + }, + beforeCreate() { + if (localStorage.getItem("token") == null) { + this.$router.push("/login"); + } } } diff --git a/front/vue-project/src/components/Favors.vue b/front/vue-project/src/components/Favors.vue index fa7f239..bbc889a 100644 --- a/front/vue-project/src/components/Favors.vue +++ b/front/vue-project/src/components/Favors.vue @@ -30,6 +30,11 @@ export default { components: [], } }, + beforeCreate() { + if (localStorage.getItem("token") == null) { + this.$router.push("/login"); + } + }, created() { DataService.readAll(this.orderUrl, (data) => new Order(data)) .then(data => { @@ -43,14 +48,14 @@ export default { methods: { filter() { let urlParams = "" - if (document.getElementById('favorNameFilterInput').value != "") { - if (urlParams != "") { + if (document.getElementById('favorNameFilterInput').value !== "") { + if (urlParams !== "") { urlParams += "&"; } urlParams += "favorName=" + this.favorName; } - if (document.getElementById('priceFilterInput').value != "") { - if (urlParams != "") { + if (document.getElementById('priceFilterInput').value !== "") { + if (urlParams !== "") { urlParams += "&"; } urlParams += "price=" + this.price; @@ -68,7 +73,7 @@ export default { }, addComponentToFavor(favorId) { let componentId = document.getElementById('components').value; - let response = axios.post(`http://localhost:8080/favor/${favorId}/component?compId=${componentId}`); + let response = axios.post(`http://localhost:8080/api/favor/${favorId}/component?compId=${componentId}`); console.log(response); }, diff --git a/front/vue-project/src/components/Header.vue b/front/vue-project/src/components/Header.vue index 33b2974..031c179 100644 --- a/front/vue-project/src/components/Header.vue +++ b/front/vue-project/src/components/Header.vue @@ -3,6 +3,10 @@ export default { methods: { getRoutes() { return this.$router.options.routes.filter(route => route.meta?.hasOwnProperty('label')); + }, + logout() { + localStorage.clear(); + this.$router.push('/login'); } } } @@ -27,6 +31,8 @@ export default { + + diff --git a/front/vue-project/src/components/Login.vue b/front/vue-project/src/components/Login.vue new file mode 100644 index 0000000..f6b856b --- /dev/null +++ b/front/vue-project/src/components/Login.vue @@ -0,0 +1,96 @@ + + + \ No newline at end of file diff --git a/front/vue-project/src/components/Orders.vue b/front/vue-project/src/components/Orders.vue index b1fca3e..4fd758a 100644 --- a/front/vue-project/src/components/Orders.vue +++ b/front/vue-project/src/components/Orders.vue @@ -30,6 +30,11 @@ export default { components: [] } }, + beforeCreate() { + if (localStorage.getItem("token") == null) { + this.$router.push("/login"); + } + }, created() { DataService.readAll(this.favorUrl, (data) => new Favor(data)) .then(data => { @@ -43,7 +48,7 @@ export default { methods: { filter() { let urlParams = "" - if (document.getElementById('numberFilterInput').value != "") { + if (document.getElementById('numberFilterInput').value !== "") { urlParams += "number=" + this.number; } DataService.readAll(this.dataFilterUrl + urlParams, (data) => new Order(data)) diff --git a/front/vue-project/src/components/Signup.vue b/front/vue-project/src/components/Signup.vue new file mode 100644 index 0000000..acc75d3 --- /dev/null +++ b/front/vue-project/src/components/Signup.vue @@ -0,0 +1,51 @@ + + + \ No newline at end of file diff --git a/front/vue-project/src/components/Users.vue b/front/vue-project/src/components/Users.vue new file mode 100644 index 0000000..78b24b2 --- /dev/null +++ b/front/vue-project/src/components/Users.vue @@ -0,0 +1,45 @@ + + + \ No newline at end of file diff --git a/front/vue-project/src/main.js b/front/vue-project/src/main.js index d5453e0..64defca 100644 --- a/front/vue-project/src/main.js +++ b/front/vue-project/src/main.js @@ -4,12 +4,18 @@ import App from './App.vue' import Components from './components/Components.vue' import Favors from './components/Favors.vue' import Orders from './components/Orders.vue' +import Login from "./components/Login.vue"; +import Signup from "@/components/Signup.vue"; +import Users from "@/components/Users.vue"; const routes = [ { path: '/', redirect: '/components' }, { path: '/components', component: Components, meta: { label: 'Компоненты' } }, { path: '/favors', component: Favors, meta: { label: 'Услуги' } }, - { path: '/orders', component: Orders, meta: { label: 'Заказы' } } + { path: '/orders', component: Orders, meta: { label: 'Заказы' } }, + { path: '/users', component: Users, meta: { label: 'Пользователи' } }, + { path: '/login', component: Login}, + { path: '/signup', component: Signup} ] const router = createRouter({ diff --git a/front/vue-project/src/models/User.js b/front/vue-project/src/models/User.js new file mode 100644 index 0000000..2a4edbd --- /dev/null +++ b/front/vue-project/src/models/User.js @@ -0,0 +1,33 @@ +export default class Monitor { + constructor(data) { + this._id = data?.id; + this._login = data?.login; + this._role = data?.role; + } + + get id() { + return this._id; + } + + get login() { + return this._login; + } + + set login(value) { + if (typeof value !== 'string' || value === null || value.length == 0) { + throw 'New model name value ' + value + ' is not a string or empty'; + } + this._login = value; + } + + get role() { + return this._role; + } + + set role(value) { + if (typeof value !== 'string' || value === null || value.length == 0) { + throw 'New model name value ' + value + ' is not a string or empty'; + } + this._role = value; + } +} \ No newline at end of file