From e7127f3215a7ccec15c04aa4ec7a9be11a4dab55 Mon Sep 17 00:00:00 2001 From: Stan Date: Mon, 20 Apr 2026 21:04:54 +0200 Subject: [PATCH] Working version before modification. --- cookies.txt | 4 + docker-compose.yml | 1 + package-lock.json | 20 + package.json | 1 + project.txt | 35 + public/admin-app.js | 32 + public/admin.html | 712 +++++++++--- public/index.html | 503 ++++----- public/js/admin.js | 1788 ++++++++++++++++++++++++++++++ public/js/exif.js | 283 +++++ public/js/images.js | 31 +- public/js/user-db.js | 173 +++ public/js/user.js | 1588 ++++++++++++++++++++++++++ public/login-admin.html | 131 +++ public/login-user.html | 132 +++ public/portal.html | 160 ++- public/styles.css | 795 +++++-------- public/user-app.js | 25 + public/user.html | 309 +++--- sql/schema.sql | 209 +++- src/app.js | 32 +- src/middleware/authMiddleware.js | 85 ++ src/routes/adminRoutes.js | 325 ++++++ src/routes/authRoutes.js | 127 +++ src/routes/configRoutes.js | 36 +- src/routes/reportRoutes.js | 44 +- src/services/adminService.js | 388 +++++++ src/services/authService.js | 115 ++ src/services/configService.js | 28 + src/services/reportService.js | 135 ++- 30 files changed, 7046 insertions(+), 1201 deletions(-) create mode 100644 cookies.txt create mode 100644 project.txt create mode 100644 public/admin-app.js create mode 100644 public/js/admin.js create mode 100644 public/js/exif.js create mode 100644 public/js/user-db.js create mode 100644 public/js/user.js create mode 100644 public/login-admin.html create mode 100644 public/login-user.html create mode 100644 public/user-app.js create mode 100644 src/middleware/authMiddleware.js create mode 100644 src/routes/adminRoutes.js create mode 100644 src/routes/authRoutes.js create mode 100644 src/services/adminService.js create mode 100644 src/services/authService.js diff --git a/cookies.txt b/cookies.txt new file mode 100644 index 0000000..c31d989 --- /dev/null +++ b/cookies.txt @@ -0,0 +1,4 @@ +# Netscape HTTP Cookie File +# https://curl.se/docs/http-cookies.html +# This file was generated by libcurl! Edit at your own risk. + diff --git a/docker-compose.yml b/docker-compose.yml index 5c8986b..97a969a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,6 +26,7 @@ services: MARIADB_USER: ${DB_USER:-check_list_user} MARIADB_PASSWORD: ${DB_PASSWORD:-check_list_password} MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD:-root_password} + MARIADB_EXTRA_FLAGS: --max-allowed-packet=64M ports: - "${DB_PORT:-3306}:3306" volumes: diff --git a/package-lock.json b/package-lock.json index 06b7e4b..0c15040 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "check-list-poc-api", "version": "0.1.0", "dependencies": { + "cookie-parser": "^1.4.6", "cors": "^2.8.5", "dotenv": "^16.4.5", "express": "^4.21.2", @@ -143,6 +144,25 @@ "node": ">= 0.6" } }, + "node_modules/cookie-parser": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.7.tgz", + "integrity": "sha512-nGUvgXnotP3BsjiLX2ypbQnWoGUPIIfHQNZkkC668ntrzGWEZVW70HDEB1qnNGMicPje6EttlIgzo51YSwNQGw==", + "license": "MIT", + "dependencies": { + "cookie": "0.7.2", + "cookie-signature": "1.0.6" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/cookie-parser/node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", + "license": "MIT" + }, "node_modules/cookie-signature": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz", diff --git a/package.json b/package.json index a377b0b..72b4b87 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "node": ">=20.0.0" }, "dependencies": { + "cookie-parser": "^1.4.6", "cors": "^2.8.5", "dotenv": "^16.4.5", "express": "^4.21.2", diff --git a/project.txt b/project.txt new file mode 100644 index 0000000..652cf5a --- /dev/null +++ b/project.txt @@ -0,0 +1,35 @@ +admin page: + +Settings + - Image policy + - Allowed mime types <- multiselect list with know image formats + - Max file size <- maximum files size in KB + - Max width <- maximum image width in PX + - Max height <- maximum image height in PX + - Image quality + - Oversize behavior <- dropdown that defines behavior if image does not match defined settings (keep actual options) + - Template + - Categories <- text field to add categories values for the check lists records. view should be in form of the list with edit and removal option. + - Sub categories <- text field to add sub categories for the check lists records. it is mandatory to define parent category when adding subcategory. view should be in form of the list with edit and removal option. + - Severities <- text field to add severities values for the check lists records. view should be in form of the list with edit and removal option. + - Statuses <- text field to add statuses values for the check lists records. view should be in form of the list with edit and removal option. + - Handled by <- text field to add severities values for the check lists records. view should be in form of the list with edit and removal option. + - Task + - Projects <- text field to add projects values for the check lists records. view should be in form of the list with edit and removal option. + - Processes <- text field to add processes values for the check lists records. it is mandatory to define parent project when adding process. view should be in form of the list with edit and removal option. + +Users <- list view of the users with the button "Add user" on the top and option to edit and remove users from the list. In add user page it should be possible to define Email, Password, Name, Famili name, Company and role (CW, ANT or CW/ANT). + +Sites <- list view of the sites with the button "Add site" on the top and option to edit and remove sites from the list. In add site page it should be possible to define Site Code, Host (OBE, PXS), OBE Site Code and PXS Site Code. + +Check lists + - Templates <- list view with the "Add template" button on the top and option to edit and remove templates from the list. in add page it should be possible to define "Template name", Scope (CW, ANT, ANT_CPsite), Version, Valid from (date in form of dd/mm/yyyy and date picker), Valid till (date in form of dd/mm/yyyy and date picker) and a list of records assigned to the template with the checkbox in the first column. + - Records <- list view with the "Add record" button on the top and option to edit and remove record from the list. in add page it should be possible to define "Sort" (unique number), "Category" (dropdown vith values from the setting part), "Sub category" (dropdown with values from the setting part), "Severity" (dropdown with values from the setting part), "Image required" (checkbox that will indicate if user will have to add image to the record) "Description EN", "Description FR", "Description NL", "Status" (dropdown with values from the setting part but disabled from editing as it is just a placeholder here), "Handled by" (dropdown with values from the setting part but disabled from editing as it is just a placeholder here), "Comment" (disabled from editing as it is only a placeholder here). + +Reports <- list view with the "Add task" button on the top and option to edit and remove task from the list. on the list status of the task should be visible. value for it will be taken from the user part. in add page it should be possible to assigne task to the user based on user, site, template, project and process. + + + +user page: + +Tasks <- list view with the assigned tasks and option to open task for processing. after opening user should see information like Site Code, Project, Process. User should be able to pickup "Visit date" from the date picker. User should see records that are assigned to the task template and should be able to set values of "Status", "Handled by", "Comment" and should be albe to add images to the record. There should be an option that will allow user to save task as draft or final. when user chose option draft no checks has to be made. if user chose to save as final, it should be check if all records have "Status" value set and if record has value of "NOK", "TBC" or "ADD work" if the "Handled by" and "Comment" has a value and if images are added if they are mandatory for the record (based on record checkbox value). \ No newline at end of file diff --git a/public/admin-app.js b/public/admin-app.js new file mode 100644 index 0000000..bb4f40a --- /dev/null +++ b/public/admin-app.js @@ -0,0 +1,32 @@ +/* + * Admin entry point — bootstraps the admin console. + * + * Opens the shared IndexedDB, loads cached image rules, then hands control to + * the admin module which manages navigation, CRUD, and rendering for every + * admin category (Settings, Users, Sites, Check Lists, Reports). + */ + +import { state } from './js/state.js'; +import { openDatabase, dbGet } from './js/db.js'; +import { STORE_CONFIG } from './js/constants.js'; +import { initAdmin } from './js/admin.js'; + +document.addEventListener('DOMContentLoaded', async () => { + /* Open the shared IndexedDB so image-policy read/write keeps working. */ + state.db = await openDatabase(); + + /* Load cached image rules (may be null on first visit). */ + const configRow = await dbGet(STORE_CONFIG, 'imageRules'); + + /* Hand off to the admin module for all further initialization. */ + await initAdmin({ imageRules: configRow?.value || null }); +}); + +/* Re-init when navigating back (fixes stale localStorage after bfcache) */ +window.addEventListener('pageshow', async (e) => { + if (e.persisted) { + state.db = await openDatabase(); + const configRow = await dbGet(STORE_CONFIG, 'imageRules'); + await initAdmin({ imageRules: configRow?.value || null }); + } +}); diff --git a/public/admin.html b/public/admin.html index 831bef8..701e6bd 100644 --- a/public/admin.html +++ b/public/admin.html @@ -6,191 +6,587 @@ Check List PoC — Admin + + + + + + - -
-
+ + +
+
+
+

Sites

+

Manage Sites

+
+ +
+ +
+
+
+
+
+ + +
+ + +
+
+
+

Check Lists › Templates

+

Manage Templates

+
+ +
+ +
+
+ Template List + 0 +
+
+
+
+
+ + +
+ + +
+
+
+

Check Lists › Records

+

Manage Records

+
+ +
+ +
+
+ Record List + 0 +
+
+
+
+
+ + +
+ + +
+
+
+

Reports

+

Task Management

+
+ +
+ +
+
+
+
+
+ + +
+ - + + + diff --git a/public/index.html b/public/index.html index 9982392..0540c94 100644 --- a/public/index.html +++ b/public/index.html @@ -6,67 +6,55 @@ Check List PoC + + + + + - -
-