Compare commits

...
13 Commits
Author SHA1 Message Date
theis.gaedigk 8389eda7b1 adjust network config 2026-08-12 12:57:18 +02:00
theis.gaedigk 8c785bc4d9 Merge branch 'dev_demo' into host_demo 2026-08-12 12:52:52 +02:00
theis.gaedigk 7233370a61 Merge branch 'dev' into dev_demo 2026-08-12 12:52:10 +02:00
theis.gaedigk 929ec5ef10 fix: Fix issue/ticket #17 2026-07-15 15:40:08 +02:00
theis.gaedigk 67c704009e refactored loan code creation function 2026-05-13 19:42:54 +02:00
theis.gaedigk 831de8b610 added new loan code function - NOT TESTED YET 2026-05-13 14:04:12 +02:00
theis.gaedigk fd43e84c0c refactored code 2026-05-11 22:40:34 +02:00
theis.gaedigk 1ce8d33b0d pulled naas 2026-05-09 23:32:12 +02:00
theis.gaedigk c48da71cd5 improved translation 2026-05-09 11:37:44 +02:00
theis.gaedigk 8e35e81e8f Fixed bug: #16 2026-05-09 11:35:13 +02:00
theis.gaedigk 95aae1c050 cleaned changelog 2026-05-01 13:41:30 +02:00
theis.gaedigk 0cafaea487 edited compose 2026-05-01 13:33:23 +02:00
theis.gaedigk 9e0b2d3861 edited port config 2026-05-01 13:30:25 +02:00
10 changed files with 79 additions and 80 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ server {
}
location /backend/ {
proxy_pass http://demo_borrow_system-backend_v2:8102/;
proxy_pass http://demo_borrow_system-backend_v2:8004/;
}
location ~* \.(?:js|mjs|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ {
+24 -6
View File
@@ -121,10 +121,28 @@ export const MyLoansPage = () => {
const formatDate = (iso: string | null) => {
if (!iso) return "-";
const m = iso.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/);
if (!m) return iso;
const [, y, M, d, h, min] = m;
return `${d}.${M}.${y} ${h}:${min}`;
const date = new Date(iso);
if (isNaN(date.getTime())) return iso;
return date.toLocaleString("de-DE", {
timeZone: "Europe/Berlin",
day: "2-digit",
month: "2-digit",
year: "numeric",
hour: "2-digit",
minute: "2-digit",
});
};
const dateAndTime = (isISO: boolean) => {
const date = new Date();
if (isISO) {
return date.toISOString();
}
if (!isISO) {
return date;
}
};
const handleTakeAction = async (loanCode: string) => {
@@ -151,7 +169,7 @@ export const MyLoansPage = () => {
setLoans((prev) =>
prev.map((loan) =>
loan.loan_code === loanCode
? { ...loan, take_date: new Date().toISOString() }
? { ...loan, take_date: dateAndTime(true) }
: loan,
),
);
@@ -191,7 +209,7 @@ export const MyLoansPage = () => {
setLoans((prev) =>
prev.map((loan) =>
loan.loan_code === loanCode
? { ...loan, returned_date: new Date().toISOString() }
? { ...loan, returned_date: dateAndTime(true) }
: loan,
),
);
+1 -1
View File
@@ -60,7 +60,7 @@
"sure-delete-loan-2": "Für den Admin bleibt sie weiterhin sichtbar.",
"delete": "Löschen",
"change-language": "Sprache ändern",
"timezone-info": "Die angezeigten Daten und Uhrzeiten werden in deutscher Zeitzone dargestellt und müssen auch so eingegeben werden.",
"timezone-info": "Die angezeigten Daten und Uhrzeiten werden in deutscher Zeitzone dargestellt und müssen auch so eingegeben werden. Das gesamte System ist auf die deutsche Zeitzone eingestellt.",
"optional-note": "Optionale Notiz",
"note": "Notiz",
"user-info-desc": "Hier können Sie Ihre persönlichen Informationen einsehen und das Passwort ändern. Falls Sie weitere Änderungen benötigen, wenden Sie sich bitte an einen Administrator.",
+1 -1
View File
@@ -60,7 +60,7 @@
"sure-delete-loan-2": "It will remain visible to the admin.",
"delete": "Delete",
"change-language": "Change language",
"timezone-info": "The displayed dates and times are shown in Berlin timezone and must also be entered as such.",
"timezone-info": "The displayed dates and times are shown in Berlin timezone and must also be entered as such. The entire system is set to Berlin timezone.",
"optional-note": "Optional note",
"note": "Note",
"user-info-desc": "Here you can view your personal information and change your password. If you need to make further changes, please contact an administrator.",
@@ -12,7 +12,7 @@ const pool = mysql
.promise();
export const getAllLoans = async () => {
const [rows] = await pool.query("SELECT * FROM loans");
const [rows] = await pool.query("SELECT * FROM loans WHERE deleted_admin = 0;");
return { success: true, data: rows };
};
-8
View File
@@ -119,14 +119,6 @@ export const setTakeDateV2 = async (loanCode) => {
return { message: "Failed to set take date", success: false };
};
export const getAllLoansV2 = async () => {
const [result] = await pool.query("SELECT * FROM loans;");
if (result.length > 0) {
return { success: true, data: result };
}
return { success: false };
};
export const openDoor = async (doorKey) => {
const [result] = await pool.query(
"SELECT safe_nr, id FROM items WHERE door_key = ?;",
@@ -63,11 +63,9 @@ export const createLoanInDatabase = async (
};
}
const itemNames = itemIds
.map(
(id) => itemsRows.find((r) => Number(r.id) === Number(id))?.item_name,
)
.filter(Boolean);
const itemNames = itemIds.map(
(id) => itemsRows.find((r) => Number(r.id) === Number(id)).item_name,
);
// Build lockers array (unique, only 2-digit numbers from safe_nr)
const lockers = [
@@ -109,27 +107,24 @@ export const createLoanInDatabase = async (
};
}
// Generate unique loan_code (retry a few times)
let loanCode = null;
for (let i = 0; i < 6; i++) {
const candidate = Math.floor(100000 + Math.random() * 899999); // 6 digits
const [exists] = await conn.query(
"SELECT 1 FROM loans WHERE loan_code = ? LIMIT 1",
let index = false;
let candidate;
let loanCode;
// Generates 6-digit loan code
do {
candidate = Math.floor(100000 + Math.random() * 899999);
const [rows] = await conn.query(
"SELECT 1 FROM loans where loan_code = ? LIMIT 1",
[candidate],
);
if (exists.length === 0) {
if (rows.length == 0) {
index = true;
loanCode = candidate;
break;
}
}
if (!loanCode) {
await conn.rollback();
return {
success: false,
code: "SERVER_ERROR",
message: "Failed to generate unique loan code",
};
}
} while (index === false);
// Insert loan (now includes lockers)
const [insertRes] = await conn.query(
+8 -17
View File
@@ -1,37 +1,28 @@
# Changelog for upcoming version: v2.2
# Changelog for upcoming version: vX.X
This update provides some new features for the design. It also contains some improvements and I have also fixed some bugs.
Introduction
## New features
- **Deactivatable services:** I have added the ability to deactivate services, which can be useful for maintenance or other purposes. The admin can activate and deactivate services in the admin panel. If a service is deactivated, it will not be available for users and they will get an error message if they try to use it. They will also get an warning banner on the homepage.
- **New Animations:** I have added some new animations to the frontend, which make the user experience more enjoyable.
- **New Icon:** I have added a new icon for the frontend, which is now also used in the header and the favicon. It is a dark version of the old icon, which fits better to the overall design. I have made it with Icon Composer. The old icon is still used for the admin panel, which has a light design. (Maybe I will change the admin panel design in the future...)
- **New Button:** When you go to your user card (over the user icon in the header) you have a new button "Click me". If you click it, you will get an message... _I am just saying: I have implemented the no-as-a-service code in to my Backend._
-
## Improvements
- The overview page now shows the note column and is overall better organised.
- Improved error logging
- If you try to delete a loan that has not been returned yet, you will get an 507 error code.
- When the admin deletes a loan, the loan will be still visible in the database, but it will be marked as deleted. This is to prevent data loss and to keep track of deleted loans.
- Mailer improvements: The mailer is now more clearly organised. Two large code files are now split into five smaller code files which are easier to maintain. Also the design of the mails has improved.
-
## Fixed bugs
- Fixed bug: #13
- Fixed bug for messaging when server has an error
- Fixed footer height
-
---
## New version numbers
**Backend:** v2.2
**Backend:** vX.X
**Frontend:** v2.2
**Frontend:** vX.X
**Admin panel:** v1.4
**Admin panel:** vX.X
---
+25 -22
View File
@@ -1,22 +1,25 @@
services:
# usr-frontend_v2:
# container_name: borrow_system-usr-frontend
# build: ./FrontendV2
# ports:
# - "8001:80"
# restart: always
demo_usr_frontend:
container_name: demo_borrow_system-usr-frontend
networks:
proxynet:
ipv4_address: 172.20.0.14
build: ./FrontendV2
restart: unless-stopped
# admin-frontend:
# container_name: borrow_system-admin-frontend
# build: ./admin
# ports:
# - "8003:80"
# restart: always
demo_admin_frontend:
container_name: demo_borrow_system-admin-frontend
networks:
proxynet:
ipv4_address: 172.20.0.11
build: ./admin
restart: unless-stopped
demo_backend_v2:
container_name: demo_borrow_system-backend_v2
networks:
- proxynet
proxynet:
ipv4_address: 172.20.0.2
build: ./backendV2
environment:
NODE_ENV: production
@@ -25,15 +28,16 @@ services:
DB_PASSWORD: ${DB_PASSWORD_V2}
DB_NAME: borrow_system_new
depends_on:
- mysql_v2
restart: always
- demo_mysql_v2
restart: unless-stopped
demo_mysql_v2:
container_name: demo_borrow_system-mysql-v2
networks:
- proxynet
proxynet:
ipv4_address: 172.20.0.10
image: mysql:8.0
restart: always
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD_V2}
MYSQL_DATABASE: borrow_system_new
@@ -41,13 +45,12 @@ services:
volumes:
- demo_mysql-v2-data:/var/lib/mysql
- ./mysql-timezone.cnf:/etc/mysql/conf.d/timezone.cnf:ro
ports:
- "3310:3306"
no-as-a-service:
container_name: borrow_system-naas
ports:
- "3000:3000"
container_name: demo_borrow_system-naas
networks:
proxynet:
ipv4_address: 172.20.0.31
build:
context: ./no-as-a-service
dockerfile: Dockerfile