Skip to content

Commit

Permalink
Merge pull request #20 from sukhlotey/master
Browse files Browse the repository at this point in the history
Application and files
  • Loading branch information
hsrai authored Dec 27, 2024
2 parents 421948b + 33ba152 commit 4f716fb
Show file tree
Hide file tree
Showing 93 changed files with 228 additions and 27 deletions.
39 changes: 39 additions & 0 deletions Sukhpreet/403.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>403 Forbidden</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.error-container {
text-align: center;
}
img{
mix-blend-mode: color-burn;
}
h1 {
font-size: 5rem;
color: #ff6347;
}
p {
font-size: 1.5rem;
}
</style>
</head>
<body>
<div class="error-container">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ_fWKE_gfefjciX4CgWEuph_UJRQX9w2cHkCSgzC88YL0DkFCNaLMcKf6_l-Ra1S2hmIo&usqp=CAU" alt="forbidden">
<h1>403 Forbidden</h1>
<p>Sorry, you don't have access to this page.</p>
</div>
</body>
</html>
38 changes: 38 additions & 0 deletions Sukhpreet/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>404 Not Found</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.error-container {
text-align: center;
}

p {
font-size: 1.5rem;
}
a {
text-decoration: underline;
color: #ff6347;
font-size: 1.2rem;
}
</style>
</head>
<body>
<div class="error-container">
<img src="https://cdni.iconscout.com/illustration/premium/thumb/404-error-illustration-download-in-svg-png-gif-file-formats--web-message-missing-content-http-business-pack-industry-illustrations-8194728.png" alt="404">
<p>Sorry, the page you are looking for does not exist.</p>
<a href="/">Go back to Home</a>
</div>
</body>
</html>
3 changes: 3 additions & 0 deletions Sukhpreet/NGINX-topics.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ Now open on browser to see default welcome page for nginx server by:
* sudo systemctl reload nginx
#### Here is the demo of Error pages
### 403 Forbidden error
- [403 File](403.html)
![Screenshot from 2024-10-05 01-52-44](https://github.com/user-attachments/assets/79859f90-d529-4039-a289-091eb75c3f3a)

### 404 Not Found error
- [404 File](404.html)

![Screenshot from 2024-10-05 01-49-05](https://github.com/user-attachments/assets/b1c7ac16-aa1d-4dac-8e25-94e1620194ea)

************************************************
Expand Down
Binary file not shown.
File renamed without changes.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import frappe

@frappe.whitelist(allow_guest=True)
@frappe.whitelist()
def user_role():
user = frappe.session.user
roles = frappe.get_roles(user)
return {"is_librarian": "Librarian" in roles}
return {"role": "Librarian" if "Librarian" in roles else "Member"}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"index_web_pages_for_search": 1,
"is_published_field": "published",
"links": [],
"modified": "2024-12-20 03:52:47.223028",
"modified": "2024-12-25 00:13:39.714397",
"modified_by": "Administrator",
"module": "Books Management",
"name": "Book",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<template>
<h2 class="title">Books</h2>
<div class="container-books">
<div class="search-container">
<input
Expand All @@ -10,9 +11,15 @@
</div>

<button v-if="isLibrarian" class="add-btn-toggle" @click="toggleForm">
{{ showForm ? "+Add Book" : "+Add Book" }}
{{ showForm ? "Close Form" : "+Add Book" }}
</button>

<div class="latest-btn-direction">
<button class="latest-books-btn" @click="toggleLatestBooksModal">
Show Latest Books
</button>
</div>

<div class="book-list">
<div v-if="showForm" class="modal-overlay" @click.self="toggleForm">
<div class="modal-content">
Expand All @@ -25,7 +32,7 @@
v-for="book in paginatedBooks"
:key="book.name"
class="book-card"
@click="navigateToBookDetails(book.name)"
@click="navigateToBookDetails(book.name)"
>
<img :src="book.image" alt="Book Image" v-if="book.image" />
<div>
Expand All @@ -46,6 +53,22 @@
</div>
</div>
</div>

<div v-if="showLatestBooksModal" class="modal-overlay" @click.self="toggleLatestBooksModal">
<div class="modal-content">
<button class="close-button" @click="toggleLatestBooksModal">✖</button>
<h3 class="btn-latest">Latest Books</h3>
<ol class="latest-list-ol">
<li v-for="book in latestBooks" :key="book.name">
<img :src="book.image" alt="Book Image" v-if="book.image" class="latest-cover-book"/>
<div class="latest-content">
<strong>{{ book.name }}</strong> <br> by {{ book.author || "Unknown" }}
</div>

</li>
</ol>
</div>
</div>
</template>

<script>
Expand All @@ -60,10 +83,12 @@ export default {
data() {
return {
books: [],
searchQuery: "",
searchQuery: "",
showForm: false,
displayedBooksCount: 10,
isLibrarian: false,
displayedBooksCount: 10,
isLibrarian: false,
showLatestBooksModal: false,
latestBooks: [],
};
},
computed: {
Expand All @@ -85,8 +110,11 @@ export default {
},
mounted() {
this.fetchBooks();
this.checkIfLibrarian();
this.checkIfLibrarian();
},
created() {
this.checkIfLibrarian();
},
methods: {
async fetchBooks() {
try {
Expand Down Expand Up @@ -114,30 +142,64 @@ export default {
this.showForm = !this.showForm;
},
handleBookAdded() {
this.fetchBooks();
this.toggleForm();
this.fetchBooks();
this.toggleForm();
},
navigateToBookDetails(bookId) {
this.$router.push(`/book/${bookId}`);
this.$router.push(`/book/${bookId}`);
},
loadMoreBooks() {
this.displayedBooksCount += 10;
this.displayedBooksCount += 10;
},
async checkIfLibrarian() {
try {
const response = await axios.get("http://books.localhost:8002/api/method/books_management.api.user_role");
if (response.data.role === "Librarian") {
this.isLibrarian = true;
}
const response = await axios.get(
"http://books.localhost:8002/api/method/books_management.api.user_role",{
headers: {
Authorization: `token 28b908dbf65367b:f4ef14fb1da5c14`,
},
}
);
console.log("API Response:", response.data);
if (response.data.message.role === "Librarian") {
this.isLibrarian = true;
console.log("User is a Librarian:", this.isLibrarian);
}else {
console.log("User is not a Librarian:", this.isLibrarian);
}
} catch (error) {
console.error("Error checking user role:", error);
alert("You do not have permission to access this resource.");
}
},
toggleLatestBooksModal() {
this.showLatestBooksModal = !this.showLatestBooksModal;
if (this.showLatestBooksModal) {
this.fetchLatestBooks();
}
},
async fetchLatestBooks() {
try {
const response = await axios.get(
"http://books.localhost:8002/api/resource/Book",
{
params: {
fields: JSON.stringify(["name", "author","image"]),
order_by: "creation desc",
limit_page_length: 5,
},
}
);
this.latestBooks = response.data.data;
} catch (error) {
console.error("Error fetching latest books:", error);
}
},
},
};
</script>


<style>
body {
background-color: #121212;
Expand All @@ -146,6 +208,10 @@ body {
margin: 0;
padding: 0;
}
.title{
text-align: center;
font-size: xx-large;
}
.container-books{
margin-right:20%;
margin-left: 20%;
Expand Down Expand Up @@ -209,7 +275,7 @@ body {
margin-top: 2px;
cursor: pointer;
}
.modal-overlay {
.modal-overlayy {
position: fixed;
top: 0;
left: 0;
Expand Down Expand Up @@ -267,7 +333,7 @@ body {
color: #bbb;
}
.load-more-btn {
background-color: #3f418c;
background-color: #1e1e1e;
color: #fff;
border: none;
padding: 10px 20px;
Expand All @@ -277,22 +343,77 @@ body {
}
.load-more-btn:hover {
background-color: #2d4e95;
background-color: #4c4646;
}
.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
}
.latest-list-ol li{
display: flex;
align-items: center;
gap: 10px;
border-bottom: 2px solid #121212;
}
.latest-list-ol{
margin: 0;
}
.latest-content{
display:inline-block;
align-items: center;
}
.modal-content {
background: #1e1e1e;
padding: 20px;
border-radius: 8px;
width: 400px;
}
.latest-cover-book{
width: 100px;
margin-bottom: 5px;
border-radius: 5px;
}
.close-button {
background: none;
border: none;
font-size: 20px;
cursor: pointer;
float: right;
}
.latest-books-btn {
margin-top: 10px;
padding: 10px 20px;
background-color: #1e1e1e;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
}
.latest-btn-direction{
text-align: end;
}
.latest-books-btn:hover {
background-color: #4c4646;
}
@media screen and (max-width: 768px) {
.book-card {
flex: 1 1 calc(33.333% - 15px);
max-width: calc(33.333% - 15px);
width: 100%;
overflow:scroll;
}
}
@media screen and (max-width: 480px) {
.book-card {
flex: 1 1 calc(50% - 15px);
max-width: calc(50% - 15px);
width: 100%;
overflow:scroll;
}
}
</style>
File renamed without changes.
File renamed without changes.

0 comments on commit 4f716fb

Please sign in to comment.