Skip to content

Commit

Permalink
Merge pull request #21 from philippebeck/dev
Browse files Browse the repository at this point in the history
Release 0.15.0
  • Loading branch information
philippebeck authored Feb 7, 2023
2 parents 7d14db0 + 1a3de74 commit 9b5c7ec
Show file tree
Hide file tree
Showing 18 changed files with 649 additions and 131 deletions.
53 changes: 30 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,36 +61,43 @@ Yarn : `yarn add vesan`
## Content

Available API Files (UNDER CONSTRUCTION) :
- **ProductModel, ReviewModel, ArticleModel, CommentModel, UserModel** *(Schemas MongoDB)*
- **ProductCtrl, ReviewCtrl, ArticleCtrl, CommentCtrl, UserCtrl** *(Controllers)*
- **ProductRoute, ReviewRoute, ArticleRoute, CommentRoute, UserRoute** *(Routes)*
- **ProductModel, ProductCtrl, ProductRoute** *(Products)*
- **ProductModel, ReviewCtrl, ReviewRoute** *(Product Reviews)*
- **OrderModel, OrderCtrl, OrderRoute** *(Product Orders)*
- **ArticleModel, ArticleCtrl, ArticleRoute** *(Articles)*
- **CommentModel, CommentCtrl, CommentRoute** *(Article Comments)*
- **UserModel, UserCtrl, UserRoute** *(Users)*
- **LinkModel, LinkCtrl, LinkRoute** *(Links)*

Available Views (UNDER CONSTRUCTION) :
- **HomeView** *(Home)*
- **ShopView** *(Shop)*
- **ProductView** *(Product of Shop)*
- **BlogView** *(Blog)*
- **ArticleView** *(Article of Blog)*
- **ShopView** *(Shop with products list)*
- **ProductView** *(Product of the shop)*
- **BlogView** *(Blog with articles list)*
- **ArticleView** *(Article of the blog)*
- **ContactView** *(Contact)*
- **BasketView** *(Basket)*
- **LoginView** *(Login with local Components)*
- **AdminView** *(Admin with local Components)*
- **BasketView** *(Basket & Orders)*
- **LoginView** *(Login with Connectors)*
- **AdminView** *(Admin with Managers)*
- **LinkView** *(Links list)*
- **ErrorView** *(Error)*

Available Components (UNDER CONSTRUCTION) :
- **ForgotPass** *(Forgot Password)*
- **SignIn** *(Sign In)*
- **SignUp** *(Sign Up)*
- **CreateProduct** *(Create Product)*
- **ListProducts** *(Update & Delete Product)*
- **CreateReview** *(Create Review)*
- **ListReviews** *(Update & Delete Review)*
- **CreateArticle** *(Create Article)*
- **ListArticles** *(Update & Delete Article)*
- **CreateComment** *(Create Comment)*
- **ListComments** *(Update & Delete Comment)*
- **CreateUser** *(Create User)*
- **ListUsers** *(Update & Delete User)*
- **ForgotPass** *(Connector)*
- **SignIn** *(Connector*
- **SignUp** *(Connector)*
- **CreateProduct** *(Creator)*
- **CreateReview** *(Creator)*
- **CreateArticle** *(Creator)*
- **CreateComment** *(Creator)*
- **CreateLink** *(Creator)*
- **ListProducts** *(Manager)*
- **ListReviews** *(Manager)*
- **ListOrders** *(Manager)*
- **ListArticles** *(Manager)*
- **ListComments** *(Manager)*
- **ListUsers** *(Manager)*
- **ListLinks** *(Manager)*

---

Expand Down
3 changes: 2 additions & 1 deletion api/controller/UserCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ exports.checkUsers = (req, res) => {
usersChecked.push({
_id: users[i]._id,
name: users[i].name,
email: users[i].email
email: users[i].email,
role: users[i].role
});
}
res.status(200).json(usersChecked);
Expand Down
6 changes: 3 additions & 3 deletions constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ export default {
],

ROLES_USER : [
"Admin",
"Author",
"User"
"admin",
"author",
"user"
],

FORGOT_CONFIRM : "Do you confirm sending a new password ?",
Expand Down
72 changes: 70 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vesan",
"version": "0.14.0",
"version": "0.15.0",
"description": "CMS with Vue-Elt, Servidio, Animadio & NemJS",
"keywords": [
"cms",
Expand Down Expand Up @@ -28,6 +28,7 @@
"@fortawesome/fontawesome-free": "^6.2.1",
"animadio": "^5.6.0",
"core-js": "^3.8.3",
"pinia": "^2.0.30",
"servidio": "^0.4.1",
"vue": "^3.2.45",
"vue-elt": "^0.6.6",
Expand All @@ -50,4 +51,4 @@
"email": "[email protected]",
"url": "https://philippebeck.net"
}
}
}
121 changes: 101 additions & 20 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,36 @@
<!-- Admin Part -->
<template #admin>

<!-- Visitor -->
<ListElt v-if="!userId"
:items="['basket', 'donation', 'sponsor', 'login']">
<!-- Admin -->
<ListElt v-if="checkSession('admin')"
:items="['basket', 'admin', 'logout']">

<template #item-1>
<a href="/basket"
title="Basket">
<i class="fa-solid fa-basket-shopping fa-fw"></i>
</a>
</template>

<template #item-2>
<a href="/admin"
title="Admin">
<i class="fa-solid fa-user-ninja fa-fw"></i>
</a>
</template>

<template #item-3>
<button type="button"
@click="logout()"
title="Logout">
<i class="fa-solid fa-sign-out-alt fa-fw"></i>
</button>
</template>
</ListElt>

<!-- Author & User -->
<ListElt v-else-if="checkSession('author') || checkSession('user')"
:items="['basket', 'donation', 'sponsor', 'logout']">

<template #item-1>
<a href="/basket"
Expand All @@ -53,16 +80,17 @@
</template>

<template #item-4>
<a href="/login"
title="Login">
<i class="fa-solid fa-sign-in-alt fa-fw"></i>
</a>
<button type="button"
@click="logout()"
title="Logout">
<i class="fa-solid fa-sign-out-alt fa-fw"></i>
</button>
</template>
</ListElt>

<!-- Admin -->
<!-- Visitor -->
<ListElt v-else
:items="['basket', 'admin', 'logout']">
:items="['basket', 'donation', 'sponsor', 'login']">

<template #item-1>
<a href="/basket"
Expand All @@ -72,20 +100,27 @@
</template>

<template #item-2>
<a href="/admin"
title="Admin">
<i class="fa-solid fa-user-ninja fa-fw"></i>
<a href="https://paypal.me/philippebeck"
title="Donation">
<i class="fa-brands fa-paypal fa-fw"></i>
</a>
</template>

<template #item-3>
<button type="button"
@click="logout()"
title="Logout">
<i class="fa-solid fa-sign-out-alt fa-fw"></i>
</button>
<a href="https://github.com/sponsors/philippebeck"
title="Sponsor">
<i class="fa-regular fa-heart fa-fw"></i>
</a>
</template>

<template #item-4>
<a href="/login"
title="Login">
<i class="fa-solid fa-sign-in-alt fa-fw"></i>
</a>
</template>
</ListElt>

</template>
</NavElt>

Expand Down Expand Up @@ -214,11 +249,57 @@ export default {
data() {
return {
users: [],
userId: null
}
},
methods: {
/**
* CHECK SESSION
* @param {string} role
* @returns
*/
checkSession(role) {
if (localStorage.userId) {
this.userId = JSON.parse(localStorage.userId);
for (const user of this.users) {
if (this.userId === user._id) {
let auth = null;
switch (user.role) {
case "admin":
auth = true;
break;
case "author":
if (role === "admin") {
auth = false;
} else {
auth = true;
}
break;
case "user":
if (role === "user") {
auth = true;
} else {
auth = false;
}
break;
default:
auth = false;
break;
}
return auth;
}
}
}
return false;
},
logout() {
localStorage.removeItem("userId");
localStorage.removeItem("userToken");
Expand All @@ -227,9 +308,9 @@ export default {
},
mounted() {
if (localStorage.userId) {
this.userId = JSON.parse(localStorage.userId);
}
this.$serve.getData("/api/users/check")
.then(res => { this.users = res })
.catch(err => { console.log(err) });
}
};
</script>
2 changes: 2 additions & 0 deletions src/components/creators/CreateLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ export default {
createLink(isReferenced) {
if (!isReferenced) {
let link = new FormData();
link.append("name", this.name);
link.append("url", this.url);
link.append("cat", this.cat);
this.$serve.postData("/api/links", link)
.then(() => {
alert(link.get("name") + " created !");
Expand Down
Loading

0 comments on commit 9b5c7ec

Please sign in to comment.