From 29086addf29e696bbc9a8536c03ec66d452de968 Mon Sep 17 00:00:00 2001 From: lnguyen34 Date: Sat, 18 Oct 2025 10:09:07 -0400 Subject: [PATCH 1/5] Revert "commented enrollmentstatus as it is not built in DB yet" This reverts commit 315ed021c89c00f6debf209c7cdb342bed817141. --- backend/controllers/admin/StudentController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/controllers/admin/StudentController.cpp b/backend/controllers/admin/StudentController.cpp index 55a6828..333dd34 100644 --- a/backend/controllers/admin/StudentController.cpp +++ b/backend/controllers/admin/StudentController.cpp @@ -85,7 +85,7 @@ void StudentController::getAllStudents(const HttpRequestPtr &req, student["phone"] = row["phone"].as(); student["email"] = row["email"].as(); student["address"] = row["address"].as(); - //student["enrollmentStatus"] = row["enrollmentStatus"].as(); // May be null + student["enrollmentStatus"] = row["enrollmentStatus"].as(); // May be null jsonResponse.append(student); } From 1d010f2ddffcb8c30d77e2b56ed7d41732d72e14 Mon Sep 17 00:00:00 2001 From: OCEAN RAI Date: Sat, 18 Oct 2025 10:31:22 -0400 Subject: [PATCH 2/5] Reapply "commented enrollmentstatus as it is not built in DB yet" This reverts commit 29086addf29e696bbc9a8536c03ec66d452de968. --- backend/controllers/admin/StudentController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/controllers/admin/StudentController.cpp b/backend/controllers/admin/StudentController.cpp index 333dd34..55a6828 100644 --- a/backend/controllers/admin/StudentController.cpp +++ b/backend/controllers/admin/StudentController.cpp @@ -85,7 +85,7 @@ void StudentController::getAllStudents(const HttpRequestPtr &req, student["phone"] = row["phone"].as(); student["email"] = row["email"].as(); student["address"] = row["address"].as(); - student["enrollmentStatus"] = row["enrollmentStatus"].as(); // May be null + //student["enrollmentStatus"] = row["enrollmentStatus"].as(); // May be null jsonResponse.append(student); } From 951da520fe060f7f05fdd436bb5ef9b856528d02 Mon Sep 17 00:00:00 2001 From: OCEAN RAI Date: Sat, 18 Oct 2025 10:31:37 -0400 Subject: [PATCH 3/5] Revert "commented enrollmentstatus as it is not built in DB yet" This reverts commit 315ed021c89c00f6debf209c7cdb342bed817141. --- backend/controllers/admin/StudentController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/controllers/admin/StudentController.cpp b/backend/controllers/admin/StudentController.cpp index 55a6828..333dd34 100644 --- a/backend/controllers/admin/StudentController.cpp +++ b/backend/controllers/admin/StudentController.cpp @@ -85,7 +85,7 @@ void StudentController::getAllStudents(const HttpRequestPtr &req, student["phone"] = row["phone"].as(); student["email"] = row["email"].as(); student["address"] = row["address"].as(); - //student["enrollmentStatus"] = row["enrollmentStatus"].as(); // May be null + student["enrollmentStatus"] = row["enrollmentStatus"].as(); // May be null jsonResponse.append(student); } From bfb50af007c1431cca58677c8199f15485809efa Mon Sep 17 00:00:00 2001 From: OCEAN RAI Date: Sat, 18 Oct 2025 10:31:51 -0400 Subject: [PATCH 4/5] Revert "Implement list of students page with a reusable sidebar and displays a table that gathers information from database with a radio button and confirm button" This reverts commit 2246b69fc62c0bf5595d15bfd3468cfee8f48886. --- .../controllers/admin/StudentController.cpp | 54 +------------ backend/controllers/admin/StudentController.h | 5 -- docs/admin/assets/sidebar.css | 16 ++-- docs/admin/assets/sidebar.js | 4 +- docs/admin/assets/student_table.css | 55 -------------- docs/admin/assets/student_table.js | 29 ------- docs/admin/list_of_students.html | 75 ++++++++++++------- docs/admin/sidebar.html | 9 +-- 8 files changed, 61 insertions(+), 186 deletions(-) delete mode 100644 docs/admin/assets/student_table.css delete mode 100644 docs/admin/assets/student_table.js diff --git a/backend/controllers/admin/StudentController.cpp b/backend/controllers/admin/StudentController.cpp index 333dd34..ab5281a 100644 --- a/backend/controllers/admin/StudentController.cpp +++ b/backend/controllers/admin/StudentController.cpp @@ -18,7 +18,7 @@ void StudentController::createStudent(const HttpRequestPtr &req, } // Validate required fields - if (!json->isMember("name") || !json->isMember("email") || + if (!json->isMember("name") || !json->isMember("email") || !json->isMember("studentId") || !json->isMember("phone") || !json->isMember("dateofbirth") || !json->isMember("address") || !json->isMember("sex")) @@ -55,52 +55,6 @@ void StudentController::createStudent(const HttpRequestPtr &req, (*json)["dateofbirth"].asString(), (*json)["address"].asString(), (*json)["sex"].asString(), - (*json)["studentId"].asString()); -} - -// Handles GET request to retrieve all student records from the database -void StudentController::getAllStudents(const HttpRequestPtr &req, - std::function &&callback) -{ - // Get the default database client instance - auto client = app().getDbClient("default"); - - // Execute SQL query asynchronously to fetch student data - client->execSqlAsync( - "SELECT id, name, phone, email, dateofbirth, address, sex, studentId FROM Students", - - // Success callback: transform DB result into JSON array - [callback](const drogon::orm::Result &result) - { - Json::Value jsonResponse(Json::arrayValue); - - // Iterate through each row and build a JSON object for each student - for (const auto &row : result) - { - Json::Value student; - student["studentId"] = row["studentId"].as(); - student["name"] = row["name"].as(); - student["dateofbirth"] = row["dateofbirth"].as(); - student["sex"] = row["sex"].as(); - student["phone"] = row["phone"].as(); - student["email"] = row["email"].as(); - student["address"] = row["address"].as(); - student["enrollmentStatus"] = row["enrollmentStatus"].as(); // May be null - jsonResponse.append(student); - } - - // Return JSON response with HTTP 200 OK - auto resp = HttpResponse::newHttpJsonResponse(jsonResponse); - resp->setStatusCode(k200OK); - callback(resp); - }, - - // Error callback: return HTTP 500 with error message - [callback](const drogon::orm::DrogonDbException &e) - { - auto resp = HttpResponse::newHttpResponse(); - resp->setStatusCode(k500InternalServerError); - resp->setBody("Database error: " + std::string(e.base().what())); - callback(resp); - }); -} + (*json)["studentId"].asString() + ); +} \ No newline at end of file diff --git a/backend/controllers/admin/StudentController.h b/backend/controllers/admin/StudentController.h index 219baeb..f2f211a 100644 --- a/backend/controllers/admin/StudentController.h +++ b/backend/controllers/admin/StudentController.h @@ -6,14 +6,9 @@ class StudentController : public drogon::HttpController { METHOD_LIST_BEGIN // Admin-only endpoint to create a new student ADD_METHOD_TO(StudentController::createStudent, "/api/admin/students", drogon::Post); - // Route: GET /api/admin/students → calls getAllStudents - ADD_METHOD_TO(StudentController::getAllStudents, "/api/admin/students", drogon::Get); METHOD_LIST_END // Handler void createStudent(const drogon::HttpRequestPtr &req, std::function &&callback); - // Handles GET request to return all students as JSON - void getAllStudents(const drogon::HttpRequestPtr &req, - std::function &&callback); }; diff --git a/docs/admin/assets/sidebar.css b/docs/admin/assets/sidebar.css index 09dc01a..b0ec0d5 100644 --- a/docs/admin/assets/sidebar.css +++ b/docs/admin/assets/sidebar.css @@ -1,12 +1,10 @@ -/* Base layout setup */ body { margin: 0; - display: flex; /* Enables sidebar + main layout */ + display: flex; height: 100vh; font-family: "Segoe UI", sans-serif; } -/* Sidebar styling */ .sidebar { width: 220px; background-color: #1e1e2f; @@ -14,20 +12,18 @@ body { display: flex; flex-direction: column; padding: 20px; - height: 100vh; /* Fill full vertical space */ - position: fixed; /* Stay fixed on the left */ + height: 100vh; /* ✅ makes sidebar fill full height */ + position: fixed; /* ✅ keeps sidebar fixed in place */ top: 0; left: 0; } -/* Sidebar title */ .sidebar h2 { font-size: 1.5rem; margin-bottom: 30px; text-align: center; } -/* Sidebar links */ .sidebar a { color: #cfd1d7; text-decoration: none; @@ -37,17 +33,15 @@ body { transition: background 0.2s ease; } -/* Hover and active link styles */ .sidebar a:hover, .sidebar a.active { background-color: #34344a; color: #fff; } -/* Main content area */ .main { - flex-grow: 1; /* Take remaining space */ + flex-grow: 1; background-color: #f8f9fa; padding: 40px; - margin-left: 220px; /* Offset for fixed sidebar */ + margin-left: 220px; /* ✅ prevents overlap */ } diff --git a/docs/admin/assets/sidebar.js b/docs/admin/assets/sidebar.js index f1ea5d6..9fb0176 100644 --- a/docs/admin/assets/sidebar.js +++ b/docs/admin/assets/sidebar.js @@ -1,15 +1,13 @@ -// Load sidebar HTML and highlight the active link document.addEventListener("DOMContentLoaded", () => { const sidebarContainer = document.getElementById("sidebar-container"); if (sidebarContainer) { - // Inject sidebar.html into the container fetch("sidebar.html") .then(res => res.text()) .then(html => { sidebarContainer.innerHTML = html; - // Add 'active' class to the link matching current page + // Highlight the active link based on current page const links = sidebarContainer.querySelectorAll("a"); const currentPage = window.location.pathname; links.forEach(link => { diff --git a/docs/admin/assets/student_table.css b/docs/admin/assets/student_table.css deleted file mode 100644 index f521ac8..0000000 --- a/docs/admin/assets/student_table.css +++ /dev/null @@ -1,55 +0,0 @@ -/* =============================== - Table layout and formatting - =============================== */ -table { - width: 100%; - border-collapse: collapse; - margin-top: 20px; -} - -thead th { - text-align: center; - background-color: #f0f0f0; - color: #333; -} - -th, -td { - padding: 10px; - border: 1px solid #ddd; - text-align: left; - white-space: nowrap; -} - -/* First column: center-align and fixed width */ -td:first-child, -th:first-child { - text-align: center; - width: 60px; -} - -/* =============================== - Confirm button styling - =============================== */ - -/* Container aligns button to bottom-right of table */ -.confirm-container { - display: flex; - justify-content: flex-end; - margin-top: 20px; -} - -/* Button appearance and hover effect */ -.confirm-button { - padding: 10px 20px; - background-color: #28a745; /* success green */ - color: white; - border: none; - border-radius: 5px; - font-size: 16px; - cursor: pointer; -} - -.confirm-button:hover { - background-color: #218838; -} diff --git a/docs/admin/assets/student_table.js b/docs/admin/assets/student_table.js deleted file mode 100644 index e1102cb..0000000 --- a/docs/admin/assets/student_table.js +++ /dev/null @@ -1,29 +0,0 @@ -// =============================== -// Fetch and render student data -// =============================== - -// Send GET request to backend API -fetch("/api/admin/students") - .then(res => res.json()) - .then(students => { - const tableBody = document.querySelector("#studentTableBody"); - tableBody.innerHTML = ""; // Clear any existing rows - - // Loop through each student and build a table row - students.forEach((student, index) => { - const row = ` - - - ${student.studentId} - ${student.name} - ${student.dateofbirth} - ${student.sex} - ${student.phone} - ${student.email} - ${student.address} - ${student.enrollmentStatus || "Active"} - - `; - tableBody.innerHTML += row; - }); - }); diff --git a/docs/admin/list_of_students.html b/docs/admin/list_of_students.html index 14b569e..789a134 100644 --- a/docs/admin/list_of_students.html +++ b/docs/admin/list_of_students.html @@ -1,29 +1,45 @@ - List of Students - - + - - + - -

Registered Students

- - @@ -31,29 +47,38 @@

Registered Students

- - - - + - +
Student ID Full Name DOBSexPhoneEmailAddressContact Info Enrollment Status
- - -
- -
- + + - - - diff --git a/docs/admin/sidebar.html b/docs/admin/sidebar.html index 2a9a050..472c390 100644 --- a/docs/admin/sidebar.html +++ b/docs/admin/sidebar.html @@ -1,13 +1,6 @@ - From 8966157a9cdcc0aeb383a31a3fae14dee5427fd0 Mon Sep 17 00:00:00 2001 From: OCEAN RAI Date: Sat, 18 Oct 2025 10:32:03 -0400 Subject: [PATCH 5/5] Revert "created a side menu for list of students with list of student display page, created a reusable sidebar and sidebar style" This reverts commit 25db170728cb2d30107dac100f25b50896d6eea7. --- docs/admin/assets/sidebar.css | 47 ------------------ docs/admin/assets/sidebar.js | 23 --------- docs/admin/dashboard.html | 50 ++++++++++++++++--- docs/admin/list_of_students.html | 84 -------------------------------- docs/admin/new_student.html | 48 +++++++++++++++--- docs/admin/sidebar.html | 6 --- 6 files changed, 84 insertions(+), 174 deletions(-) delete mode 100644 docs/admin/assets/sidebar.css delete mode 100644 docs/admin/assets/sidebar.js delete mode 100644 docs/admin/list_of_students.html delete mode 100644 docs/admin/sidebar.html diff --git a/docs/admin/assets/sidebar.css b/docs/admin/assets/sidebar.css deleted file mode 100644 index b0ec0d5..0000000 --- a/docs/admin/assets/sidebar.css +++ /dev/null @@ -1,47 +0,0 @@ -body { - margin: 0; - display: flex; - height: 100vh; - font-family: "Segoe UI", sans-serif; -} - -.sidebar { - width: 220px; - background-color: #1e1e2f; - color: #fff; - display: flex; - flex-direction: column; - padding: 20px; - height: 100vh; /* ✅ makes sidebar fill full height */ - position: fixed; /* ✅ keeps sidebar fixed in place */ - top: 0; - left: 0; -} - -.sidebar h2 { - font-size: 1.5rem; - margin-bottom: 30px; - text-align: center; -} - -.sidebar a { - color: #cfd1d7; - text-decoration: none; - padding: 10px 15px; - border-radius: 6px; - margin-bottom: 10px; - transition: background 0.2s ease; -} - -.sidebar a:hover, -.sidebar a.active { - background-color: #34344a; - color: #fff; -} - -.main { - flex-grow: 1; - background-color: #f8f9fa; - padding: 40px; - margin-left: 220px; /* ✅ prevents overlap */ -} diff --git a/docs/admin/assets/sidebar.js b/docs/admin/assets/sidebar.js deleted file mode 100644 index 9fb0176..0000000 --- a/docs/admin/assets/sidebar.js +++ /dev/null @@ -1,23 +0,0 @@ -document.addEventListener("DOMContentLoaded", () => { - const sidebarContainer = document.getElementById("sidebar-container"); - - if (sidebarContainer) { - fetch("sidebar.html") - .then(res => res.text()) - .then(html => { - sidebarContainer.innerHTML = html; - - // Highlight the active link based on current page - const links = sidebarContainer.querySelectorAll("a"); - const currentPage = window.location.pathname; - links.forEach(link => { - if (link.getAttribute("href") === currentPage) { - link.classList.add("active"); - } - }); - }) - .catch(err => { - console.error("Error loading sidebar:", err); - }); - } -}); diff --git a/docs/admin/dashboard.html b/docs/admin/dashboard.html index 83a80f2..813bb05 100644 --- a/docs/admin/dashboard.html +++ b/docs/admin/dashboard.html @@ -4,19 +4,55 @@ Admin Dashboard - + - - - +

Welcome, Admin!

This is your admin dashboard.

- - - diff --git a/docs/admin/list_of_students.html b/docs/admin/list_of_students.html deleted file mode 100644 index 789a134..0000000 --- a/docs/admin/list_of_students.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - - List of Students - - - - - - - - - -
-

Registered Students

- - - - - - - - - - - - - - -
Student IDFull NameDOBContact InfoEnrollment Status
-
- - - - - - - diff --git a/docs/admin/new_student.html b/docs/admin/new_student.html index f26fdb2..1f57828 100644 --- a/docs/admin/new_student.html +++ b/docs/admin/new_student.html @@ -5,16 +5,53 @@ New Student Registration - - - - +

Register New Student

@@ -123,8 +160,5 @@

Register New Student

}); }); - - - diff --git a/docs/admin/sidebar.html b/docs/admin/sidebar.html deleted file mode 100644 index 472c390..0000000 --- a/docs/admin/sidebar.html +++ /dev/null @@ -1,6 +0,0 @@ -