Commit b20eadaa authored by Deep Dey's avatar Deep Dey

feat: add api integration for dashboard form listing and login

parent f1430816
......@@ -46,12 +46,25 @@ body {
}
.book-appointment-box {
position: absolute;
top: 10px;
right: 20px;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
z-index: 100;
}
.book-appointment-box2 {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 20px;
z-index: 100;
}
.book-appointment-box2 .btn {
margin: 0 5px;
}
.navbar-filter {
background-color: #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
......
......@@ -51,5 +51,5 @@ body {
.error-message {
color: red;
display: none;
margin-top: 10px;
margin-bottom: 10px;
}
\ No newline at end of file
......@@ -5,6 +5,9 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dashboard</title>
<link
href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="css/dashboard.css" />
</head>
......@@ -18,22 +21,22 @@
<div class="row">
<div class="col-lg-3">
<div class="navbar-filter">
<h4>Filters</h4>
<h5>Filters</h5>
<hr />
<div class="filter-box">
<label for="schoolFilter" class="filter-label">School Wise</label>
<label for="schoolFilter" class="filter-label">School</label>
<select id="schoolFilter" class="form-control">
<option value="">All Schools</option>
<option value="">All</option>
<option value="La Martiniere for Boys">La Martiniere for Boys</option>
<option value="La Martiniere for Girls">La Martiniere for Girls</option>
<option value="La Martiniere for Girls">La Martiniere for girls</option>
</select>
</div>
<div class="filter-box">
<label for="dateFilter" class="filter-label">Date</label>
<label for="dateFilter" class="filter-label">Interaction Date</label>
<input type="date" id="dateFilter" class="form-control" />
</div>
<div class="filter-box">
<label for="timeFilter" class="filter-label">Time</label>
<label for="timeFilter" class="filter-label">Interaction Time</label>
<input type="time" id="timeFilter" class="form-control" />
</div>
<button id="applyFilters" class="btn btn-primary btn-block">Apply Filters</button>
......@@ -42,24 +45,35 @@
</div>
<div class="col-lg-9">
<div class="details-container">
<h2>Student Information</h2>
<div>
<h2 style="text-align: center;">Admission Information</h2>
<div class="book-appointment-box2">
<button class="btn btn-success btn-sm">Interaction Sheet</button>
<button class="btn btn-primary btn-sm">Interaction Scoring Sheet</button>
<button class="btn btn-secondary btn-sm">Counsellor Scoring Sheet</button>
</div>
<div class="book-appointment-box">
<button id="bookAppointmentBtn" class="btn btn-primary btn-sm">Schedule Appointment</button>
<button class="btn btn-success btn-sm">Download Admission Data</button>
</div>
</div>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">Select</th>
<th scope="col">ID</th>
<th scope="col">DOB</th>
<th scope="col">Student Name</th>
<th scope="col">Parent Name</th>
<th scope="col">
<input type="checkbox" id="selectAll" />
</th>
<th scope="col">Candidate Name</th>
<th scope="col">Interaction Date/Time</th>
<th scope="col">Father Name</th>
<th scope="col">Mother Name</th>
</tr>
</thead>
<tbody id="output"></tbody>
</table>
</div>
<div class="book-appointment-box">
<button id="bookAppointmentBtn" class="btn btn-success">Book Appointment</button>
</div>
</div>
</div>
</div>
......@@ -95,6 +109,7 @@
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="js/constant.js"></script>
<script src="js/dashboard.js"></script>
</body>
......
const BASE_URL = 'http://127.0.0.1:5000/webomagic-user/v1';
const BASE_URL_LAMARTIN = 'http://localhost:8084/webomagic-lamartin';
\ No newline at end of file
$(document).ready(function () {
var studentData = [
{
id: 1,
school: 'La Martiniere for Boys',
date: '2005-06-12',
name: 'John Doe',
parent: 'Jane Doe',
dob: '2003-12-10',
},
{
id: 2,
school: 'La Martiniere for Girls',
date: '2007-09-18',
name: 'arnab',
parent: 'Bob Smith',
dob: '2003-12-10',
},
{
id: 3,
school: 'La Martiniere for Boys',
date: '2007-09-20',
name: 'arnab1',
parent: 'Bob Smith',
dob: '2003-12-10',
},
{
id: 4,
school: 'La Martiniere for Boys',
date: '2007-09-21',
name: 'arnab2',
parent: 'Bob Smith',
dob: '2003-12-10',
},
{
id: 5,
school: 'La Martiniere for Girls',
date: '2007-09-15',
name: 'arnab3',
parent: 'Bob Smith',
dob: '2003-12-10',
},
{
id: 6,
school: 'La Martiniere for Boys',
date: '2007-09-22',
name: 'arnab6',
parent: 'Bob Smith',
dob: '2003-12-10',
},
{
id: 7,
school: 'La Martiniere for Girls',
date: '2007-09-15',
name: 'arnab4',
parent: 'Bob Smith',
dob: '2003-12-10',
},
{
id: 8,
school: 'La Martiniere for Girls',
date: '2007-09-05',
name: 'arnab5',
parent: 'Bob Smith',
dob: '2003-12-10',
},
];
function displayFilteredStudents(schoolFilter, dateFilter, timeFilter) {
var filteredData = studentData.filter(function (student) {
return (
(!schoolFilter || student.school === schoolFilter) &&
(!dateFilter || student.date === dateFilter) &&
(!timeFilter || student.time === timeFilter)
);
});
var studentData = [];
var loginData = JSON.parse(sessionStorage.getItem('loginData'));
if (!loginData || !loginData.apiKey) {
window.location.href = 'login.html';
}
// initially display all admission data
getAdmissionData(null, null, null, null);
function displayFilteredStudents() {
var filteredData = studentData;
var outputHtml = '';
filteredData.forEach(function (student) {
......@@ -82,25 +19,75 @@ $(document).ready(function () {
'<td><input type="checkbox" class="student-checkbox" data-id="' +
student.id +
'"></td>';
outputHtml += '<td>' + student.id + '</td>';
outputHtml += '<td>' + student.dob + '</td>';
outputHtml += '<td>' + student.name + '</td>';
outputHtml += '<td>' + student.parent + '</td>';
outputHtml += '<td>' + student.fullName + '</td>';
outputHtml += '<td>' + (student.interactionDate || '')+ ' ' + (student.interactionTime || '') + '</td>';
outputHtml += '<td>' + student.fatherName + '</td>';
outputHtml += '<td>' + student.motherName + '</td>';
outputHtml += '</tr>';
});
$('#output').html(outputHtml);
}
// Initial display of all students
displayFilteredStudents(null, null, null);
function getAdmissionData(
schoolName,
className,
interactionDate,
interactionTime
) {
let queryData = {};
if (schoolName) {
queryData.schoolName = schoolName;
}
if (className) {
queryData.className = className;
}
if (interactionDate) {
queryData.interactionDate = interactionDate;
}
if (interactionTime) {
queryData.interactionTime = interactionTime;
}
$.ajax({
url: BASE_URL_LAMARTIN + '/admission-form/get-all',
type: 'GET',
contentType: 'application/json',
dataType: 'json',
headers: {
apikey: loginData.apiKey,
},
data: queryData,
success: function (response) {
console.log('Success:', response);
// Handle the response data
if (response.data) {
studentData = response.data;
displayFilteredStudents();
}
},
error: function (error) {
console.error('Error:', error);
studentData = [];
// Handle error messages
if (error.responseJSON && error.responseJSON.message) {
alert('Request failed: ' + error.responseJSON.message);
} else {
alert('An unexpected error occurred. Please try again.');
}
},
});
}
// Apply filters button click event
$('#applyFilters').click(function () {
var schoolFilter = $('#schoolFilter').val();
var dateFilter = $('#dateFilter').val();
var timeFilter = $('#timeFilter').val();
displayFilteredStudents(schoolFilter, dateFilter, timeFilter);
getAdmissionData(schoolFilter, null, dateFilter, timeFilter);
});
// Reset filters button click event
......@@ -108,9 +95,18 @@ $(document).ready(function () {
$('#schoolFilter').val('');
$('#dateFilter').val('');
$('#timeFilter').val('');
displayFilteredStudents(null, null, null);
getAdmissionData(null, null, null, null);
});
// Select all checkbox click event
$('#selectAll').click(function () {
if ($(this).is(':checked')) {
$('.student-checkbox').prop('checked', true);
} else {
$('.student-checkbox').prop('checked', false);
}
});
// Book appointment button click event
$('#bookAppointmentBtn').click(function () {
var checkedValues = [];
......
......@@ -2,13 +2,26 @@ $(document).ready(function () {
$('#loginForm').on('submit', function (event) {
event.preventDefault();
var userID = $('#userid').val();
var userEmail = $('#userid').val();
var password = $('#password').val();
if (userID === 'admin' && password === 'admin') {
window.location.href = 'dashboard.html';
} else {
$('#errorMessage').show();
}
$.ajax({
url: BASE_URL + '/user/login',
type: 'POST',
contentType: 'application/json',
dataType: 'json',
data: JSON.stringify({
email: userEmail,
password: password,
}),
success: function (response) {
$('#errorMessage').hide();
sessionStorage.setItem('loginData', JSON.stringify(response.data));
window.location.href = 'dashboard.html';
},
error: function (error) {
$('#errorMessage').show();
},
});
});
});
......@@ -5,6 +5,9 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Page</title>
<link
href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/login.css">
</head>
......@@ -14,18 +17,19 @@
<h2>Login</h2>
<form id="loginForm">
<div class="form-group">
<input type="text" class="form-control" id="userid" name="userid" placeholder="Enter userID" required>
<input type="text" class="form-control" id="userid" name="userid" placeholder="Enter Email" required>
</div>
<div class="form-group">
<input type="password" class="form-control" id="password" name="password" placeholder="Enter Password"
required>
</div>
<div class="error-message" id="errorMessage">Invalid User ID or Password</div>
<div class="error-message" id="errorMessage">Invalid Email or Password</div>
<button type="submit" class="btn btn-primary btn-block">Login</button>
</form>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="js/constant.js"></script>
<script src="js/login.js"></script>
</body>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment