Skip to content

Commit 966e7aa

Browse files
committed
changes related to access
1 parent 6450883 commit 966e7aa

File tree

16 files changed

+15971
-4060
lines changed

16 files changed

+15971
-4060
lines changed

package-lock.json

Lines changed: 15733 additions & 3877 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"devDependencies": {
1818
"@babel/core": "^7.9.6",
1919
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
20+
"@babel/plugin-transform-runtime": "^7.10.1",
2021
"@babel/preset-env": "^7.3.1",
2122
"@storybook/addon-actions": "^5.3.18",
2223
"@storybook/addon-links": "^5.3.18",
@@ -58,6 +59,7 @@
5859
"last 2 versions"
5960
],
6061
"dependencies": {
62+
"@babel/runtime": "^7.10.2",
6163
"axios": "^0.19.2",
6264
"babel-polyfill": "^6.26.0",
6365
"es6-promise": "^4.2.8",

src/admin/App.vue

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
11
<template lang="pug">
22
div.root-wrapper-container
33
div.root-container
4-
header.header-container
5-
app-header
6-
section.tabs-container
7-
tabs
8-
main.content-container
9-
router-view
4+
template(v-if="$route.meta.login")
5+
.login
6+
router-view
7+
template(v-else)
8+
.admin
9+
header.header-container
10+
app-header
11+
section.tabs-container
12+
tabs
13+
main.content-container
14+
router-view
1015

1116
</template>
1217

1318
<script>
1419
import { mapState, mapActions, mapGetters } from "vuex";
15-
import SimpleVueValidator from 'simple-vue-validator';
16-
const Validator = SimpleVueValidator.Validator;
20+
// import SimpleVueValidator from 'simple-vue-validator';
21+
// const Validator = SimpleVueValidator.Validator;
1722
export default {
18-
mixins: [SimpleVueValidator.mixin],
19-
validators: {
20-
'title': function (value) {
21-
return Validator.custom(function () {
22-
if (value.length < 3) {
23-
return 'Не менее 3 символов'
24-
}
25-
});
26-
}
27-
},
23+
// mixins: [SimpleVueValidator.mixin],
24+
// validators: {
25+
// 'title': function (value) {
26+
// return Validator.custom(function () {
27+
// if (value.length < 3) {
28+
// return 'Не менее 3 символов'
29+
// }
30+
// });
31+
// }
32+
// },
2833
2934
components: {
3035
appHeader: () => import("./components/header"),

src/admin/components/header.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
<script>
1717
import { mapActions } from "vuex";
1818
export default {
19-
// methods: {
20-
// ...mapActions("user", ["logout"]),
21-
// logoutUser() {
22-
// this.logout();
23-
// this.$router.replace("/login");
24-
// }
25-
// }
19+
methods: {
20+
...mapActions("user", ["logout"]),
21+
logoutUser() {
22+
this.logout();
23+
this.$router.replace("/login");
24+
}
25+
}
2626
};
2727
</script>
2828

src/admin/components/pages/about.vue

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,48 @@
55
h1.page-title Обо мне
66
button.about-page__add-new(
77
) Добавить группу
8+
//button(@click="login()") Login
9+
//button(@click="createCat()") Create Cat
810
911
.about-page__content
1012
.container.container--mobile-wide
11-
form(@submit.prevent="addNewCategory").categories-form
12-
input(type="text" v-model="title")
13-
input(type="submit" value="Добавить")
13+
form(@submit.prevent="createNewCategory").categories-form
14+
input(type="text" v-model="category.title")
15+
input(type="submit" value="Отправить")
1416

1517
ul.skill-list
16-
li.skill-list__item(v-for="category in categories" :key="category.id")
17-
skills-group(
18-
:category="category"
19-
)
20-
21-
form(@submit.prevent="addNewCategory").categories-form
22-
input(type="text" v-model="title")
23-
input(type="submit" value="Добавить")
24-
.error-box {{ validation.firstError('title')}}
18+
li.skill-list__item()
19+
//- skills-group(
20+
//- :category="category"
21+
//- )
2522
2623
</template>
2724

2825
<script>
29-
import { mapActions, mapState } from "vuex";
26+
import { mapActions } from "vuex";
27+
// import SimpleVueValidator from "simple-vue-validator";
28+
// const Validator = SimpleVueValidator.Validator;
3029
export default {
31-
components: {
32-
skillsGroup: () => import("../skills-group")
30+
// mixins: [SimpleVueValidator.mixin],
31+
// validators: {
32+
// "title": function(value) {
33+
// return Validator.custom(function() {
34+
// if (value.length < 3) {
35+
// return "Не менее 3 символов";
36+
// }
37+
// });
38+
// },
39+
// },
40+
// components: {
41+
// skillsGroup: () => import("../skills-group")
42+
// },
43+
data(){
44+
return {
45+
category: {
46+
title: ""
47+
}
48+
}
3349
},
34-
data: () => ({
35-
title: ""
36-
}),
3750
// computed : {
3851
// ...mapState("categories", {
3952
// categories: state => state.categories
@@ -42,22 +55,31 @@ export default {
4255
// created() {
4356
// this.fetchCategories();
4457
// },
45-
// methods: {
46-
// ...mapActions("categories", ["addCategory", "fetchCategories"]),
47-
// async addNewCategory() {
48-
// try {
49-
// await this.addCategory(this.title);
50-
// } catch (error) {
51-
// alert(error.message);
52-
// }
53-
// }
54-
// }
58+
methods: {
59+
...mapActions("categories", ["addCategory"]),
60+
async createNewCategory() {
61+
try {
62+
await this.addCategory(this.category.title);
63+
this.category.title = "";
64+
} catch (error) {
65+
alert(error.message);
66+
}
67+
68+
}
69+
// ...mapActions("categories", ["addCategory", "fetchCategories"]),
70+
// async addNewCategory() {
71+
// try {
72+
// await this.addCategory(this.title);
73+
// } catch (error) {
74+
// alert(error.message);
75+
// }
76+
// }
77+
}
5578
};
5679
</script>
5780

5881
<style lang="postcss" scoped>
5982
@import "../../../styles/mixins.pcss";
60-
@import "../../../styles/mixins.pcss";
6183
.skill-container {
6284
border: 1px solid black;
6385
padding: 10px;

src/admin/components/pages/login.vue

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
<template lang="pug">
22
.login-section
33
.login__content
4-
form.login-form
4+
form(@submit.prevent="submit").login-form
55
.login-form__title Авторизация
66
.login__row
7-
label.input
8-
.input__title
9-
input(v-model="user.name" placeholder="login" type="text").input__elem.field__elem
10-
//- .error-box {{ validation.firstError('user.name') }}
7+
app-input(
8+
title="Логин"
9+
icon="user"
10+
v-model="user.name"
11+
)
12+
//- .input__title
13+
//- input(v-model="user.name" placeholder="login" type="text").input__elem.field__elem
1114
.login__row
12-
label.input
13-
.input__title
14-
input(v-model="user.password" placeholder="password" type="password").input__elem.field__elem
15-
//- .error-box {{ validation.firstError('user.password') }}
15+
app-input(
16+
title="Пароль"
17+
icon="key"
18+
type="password"
19+
v-model="user.password"
20+
)
21+
//- .input__title
22+
//- input(v-model="user.password" placeholder="password" type="password").input__elem.field__elem
1623
.login__btn
1724
button(
1825
type="submit"
@@ -23,23 +30,10 @@
2330
import axios from '../../requests';
2431
import SimpleVueValidator from "simple-vue-validator";
2532
const Validator = SimpleVueValidator.Validator;
33+
2634
export default {
27-
mixins: [SimpleVueValidator.mixin],
28-
validators: {
29-
"user.name": function(value) {
30-
return Validator.custom(function() {
31-
if (value.length < 3) {
32-
return "Не менее 3 символов";
33-
}
34-
});
35-
},
36-
"user.password": function(value) {
37-
return Validator.custom(function() {
38-
if (value.length < 3) {
39-
return "Не менее 3 символов";
40-
}
41-
});
42-
}
35+
components: {
36+
appInput: () => import("../input.vue")
4337
},
4438
data() {
4539
return {
@@ -49,12 +43,31 @@ export default {
4943
}
5044
}
5145
},
46+
// methods: {
47+
// async loginUser() {
48+
// try {
49+
// const response = await $axios.post("/login", this.user);
50+
// const token = response.data.token;
51+
// localStorage.setItem('token', token);
52+
// console.log(response);
53+
// $axios.defaults.headers["Authorization"] = `Bearer ${token}`;
54+
55+
// this.$router.replace("/");
56+
// } catch (error) {
57+
// console.log(error);
58+
// }
59+
// }
60+
// }
5261
methods: {
5362
submit() {
5463
this.$validate()
55-
.then(function(success) {
64+
.then((success)=> {
5665
if (success) {
57-
alert("Успешно!");
66+
axios.post('/login', this.user).then(({data}) =>{
67+
localStorage.setItem('token', data.token);
68+
axios.defaults.headers["Authorization"] = `Bearer ${data.token}`;
69+
this.$router.replace('/');
70+
})
5871
} else {
5972
alert("Ошибка!");
6073
}
@@ -63,25 +76,13 @@ export default {
6376
console.log(err);
6477
})
6578
},
66-
login() {
67-
axios.post('/login', this.user).then(({data}) =>{
68-
localStorage.setItem('token', data.token);
69-
axios.defaults.headers["Authorization"] = `Bearer ${data.token}`;
70-
this.$router.replace('/');
71-
})
72-
// async login() {
73-
// try {
74-
// const response = await $axios.post("/login", this.user);
75-
// const token = response.data.token;
76-
// localStorage.setItem("token", token);
77-
// $axios.defaults.headers["Authorization"] = `Bearer ${token}`;
78-
// this.$router.replace("/");
79-
80-
// } catch (error) {
81-
82-
// }
79+
// login() {
80+
// axios.post('/login', this.user).then(({data}) =>{
81+
// localStorage.setItem('token', data.token);
82+
// axios.defaults.headers["Authorization"] = `Bearer ${data.token}`;
83+
// this.$router.replace('/');
84+
// })
8385
// }
84-
}
8586
}
8687
}
8788
</script>

src/admin/components/pages/reviews.vue

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,28 @@ export default {
7575
}
7676
};
7777
},
78-
// methods: {
79-
// ...mapActions("categories", ["addReview"]),
80-
// handleFile(e) {
81-
// const file = e.target.files[0];
82-
// this.review.photo = file;
83-
// this.renderImageFile(file);
84-
// },
85-
// send() {
86-
// this.addReview(this.review);
87-
// },
88-
// renderImageFile(file) {
89-
// const reader = new FileReader();
90-
// try {
91-
// reader.readAsDataURL(file);
92-
// reader.onloadend = () => {
93-
// this.renderedPhoto = reader.result;
94-
// };
95-
// } catch (error) {
96-
// throw new Errow("Ошибка при чтении файла");
97-
// }
98-
// }
99-
// }
78+
methods: {
79+
...mapActions("categories", ["addReview"]),
80+
handleFile(e) {
81+
const file = e.target.files[0];
82+
this.review.photo = file;
83+
this.renderImageFile(file);
84+
},
85+
send() {
86+
this.addReview(this.review);
87+
},
88+
renderImageFile(file) {
89+
const reader = new FileReader();
90+
try {
91+
reader.readAsDataURL(file);
92+
reader.onloadend = () => {
93+
this.renderedPhoto = reader.result;
94+
};
95+
} catch (error) {
96+
throw new Errow("Ошибка при чтении файла");
97+
}
98+
}
99+
}
100100
};
101101
</script>
102102

0 commit comments

Comments
 (0)