consolidated
This commit is contained in:
@@ -8,11 +8,11 @@ const ConsolidatedTable = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get("http://localhost:8080/api/data/consolidated");
|
const response = await axios.get("http://localhost:8080/api/table/consolidated-table");
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching consolidated data:", error);
|
console.error("Error fetching table data:", error);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -26,29 +26,51 @@ const ConsolidatedTable = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1>Consolidated Data</h1>
|
<h1>Consolidated Table</h1>
|
||||||
<table border="1" style={{ width: "100%", textAlign: "left" }}>
|
<table border="1" style={{ width: "100%", textAlign: "left" }}>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Faculty ID</th>
|
<th>Sr No</th>
|
||||||
<th>Faculty Name</th>
|
<th>Semester</th>
|
||||||
<th>Course ID</th>
|
<th>Course Code</th>
|
||||||
<th>Course Name</th>
|
<th>Course Name</th>
|
||||||
<th>Task</th>
|
<th>Exam Type</th>
|
||||||
|
<th>Year</th>
|
||||||
|
<th>Marks</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Affiliation/College</th>
|
||||||
|
<th>Highest Qualification</th>
|
||||||
|
<th>Career Experience</th>
|
||||||
|
<th>Oral/Practical</th>
|
||||||
|
<th>Assessment</th>
|
||||||
|
<th>Reassessment</th>
|
||||||
|
<th>Paper Setting</th>
|
||||||
|
<th>Moderation</th>
|
||||||
|
<th>PwD Paper Setting</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{data.map((faculty) =>
|
{data.map((row, index) => (
|
||||||
faculty.tasks.map((task, index) => (
|
<tr key={index}>
|
||||||
<tr key={`${faculty.facultyId}-${index}`}>
|
<td>{row.srNo}</td>
|
||||||
<td>{faculty.facultyId}</td>
|
<td>{row.semester}</td>
|
||||||
<td>{faculty.facultyName}</td>
|
<td>{row.courseCode}</td>
|
||||||
<td>{task.courseId}</td>
|
<td>{row.courseName}</td>
|
||||||
<td>{task.courseName}</td>
|
<td>{row.examType}</td>
|
||||||
<td>{task.task}</td>
|
<td>{row.year}</td>
|
||||||
|
<td>{row.marks}</td>
|
||||||
|
<td>{row.Name}</td>
|
||||||
|
<td>{row.affiliation}</td>
|
||||||
|
<td>{row.qualification}</td>
|
||||||
|
<td>{row.experience}</td>
|
||||||
|
<td>{row.oralPractical}</td>
|
||||||
|
<td>{row.assessment}</td>
|
||||||
|
<td>{row.reassessment}</td>
|
||||||
|
<td>{row.paperSetting}</td>
|
||||||
|
<td>{row.moderation}</td>
|
||||||
|
<td>{row.pwdPaperSetting}</td>
|
||||||
</tr>
|
</tr>
|
||||||
))
|
))}
|
||||||
)}
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,33 +1,48 @@
|
|||||||
const express = require("express");
|
const express = require("express");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const Appointment = require("../models/Appointment");
|
const Appointment = require("../models/Appointment");
|
||||||
|
const Course = require("../models/Course");
|
||||||
|
const Faculty = require("../models/Faculty");
|
||||||
|
|
||||||
router.get("/consolidated", async (req, res) => {
|
router.get("/consolidated-table", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
// Fetch all appointments
|
||||||
const appointments = await Appointment.find();
|
const appointments = await Appointment.find();
|
||||||
|
// Fetch all courses
|
||||||
|
const courses = await Course.find();
|
||||||
|
// Fetch all faculties
|
||||||
|
const faculties = await Faculty.find();
|
||||||
|
|
||||||
// Group data by faculty
|
// Prepare data for the table
|
||||||
const groupedData = appointments.reduce((acc, appointment) => {
|
const tableData = appointments.map((appointment, index) => {
|
||||||
if (!acc[appointment.facultyId]) {
|
const course = courses.find((c) => c.courseId === appointment.courseId);
|
||||||
acc[appointment.facultyId] = {
|
const faculty = faculties.find((f) => f.facultyId === appointment.facultyId);
|
||||||
facultyId: appointment.facultyId,
|
|
||||||
facultyName: appointment.facultyName,
|
return {
|
||||||
tasks: [],
|
srNo: index + 1,
|
||||||
|
semester: course?.semester || "",
|
||||||
|
courseCode: course?.courseId || "",
|
||||||
|
courseName: course?.name || "",
|
||||||
|
examType: course?.scheme || "",
|
||||||
|
year: course?.program || "",
|
||||||
|
marks: "100+25", // Replace with actual marks logic if required
|
||||||
|
Name: faculty?.name || "",
|
||||||
|
affiliation: "KJSCE", // Replace with actual affiliation if needed
|
||||||
|
qualification: "M.E.", // Replace with actual qualification if needed
|
||||||
|
experience: "20+", // Replace with actual experience logic if required
|
||||||
|
oralPractical: appointment.task === "oralsPracticals" ? "✔" : "",
|
||||||
|
assessment: appointment.task === "assessment" ? "✔" : "",
|
||||||
|
reassessment: appointment.task === "reassessment" ? "✔" : "",
|
||||||
|
paperSetting: appointment.task === "paperSetting" ? "✔" : "",
|
||||||
|
moderation: appointment.task === "moderation" ? "✔" : "",
|
||||||
|
pwdPaperSetting: appointment.task === "pwdPaperSetter" ? "✔" : "",
|
||||||
};
|
};
|
||||||
}
|
|
||||||
acc[appointment.facultyId].tasks.push({
|
|
||||||
courseId: appointment.courseId,
|
|
||||||
courseName: appointment.courseName,
|
|
||||||
task: appointment.task,
|
|
||||||
});
|
});
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
const result = Object.values(groupedData);
|
res.status(200).json(tableData);
|
||||||
res.status(200).json(result);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching consolidated data:", error);
|
console.error("Error generating consolidated table:", error);
|
||||||
res.status(500).json({ message: "Failed to fetch consolidated data" });
|
res.status(500).json({ message: "Failed to generate table" });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ app.use(
|
|||||||
app.use(passport.initialize());
|
app.use(passport.initialize());
|
||||||
app.use(passport.session());
|
app.use(passport.session());
|
||||||
|
|
||||||
|
app.use("/api/table", consolidatedRoutes);
|
||||||
|
|
||||||
// Passport Config
|
// Passport Config
|
||||||
require("./config/passport");
|
require("./config/passport");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user