126 lines
No EOL
4.2 KiB
HTML
126 lines
No EOL
4.2 KiB
HTML
<!-- FILEPATH: /D:/Git/satitm-sso-node/statics/selfservice/student.html -->
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
|
<style>
|
|
.student-box {
|
|
background-color: #f2f2f2;
|
|
border-radius: 10px;
|
|
padding: 20px;
|
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
max-width: 400px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.inner-box {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
h2 {
|
|
font-size: 20px;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
p {
|
|
margin: 5px 0;
|
|
}
|
|
|
|
.linked-parent {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
button {
|
|
background-color: #4CAF50;
|
|
color: white;
|
|
border: none;
|
|
padding: 10px 20px;
|
|
text-align: center;
|
|
text-decoration: none;
|
|
display: inline-block;
|
|
font-size: 16px;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
#generate-token-btn {
|
|
background-color: #007bff;
|
|
margin-right: 10px;
|
|
}
|
|
|
|
#logout-btn {
|
|
background-color: #dc3545;
|
|
}
|
|
</style>
|
|
|
|
<body>
|
|
<div id="modal" style="display: none; position: fixed; z-index: 1; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4);">
|
|
<div style="background-color: #fefefe; margin: 20% auto; padding: 20px; border: 1px solid #888; width: 50%; border-radius: 10px; box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);">
|
|
<span id="close" style="color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer;">×</span>
|
|
<p id="modal-text" style="font-size: 18px; color: #333;"></p>
|
|
</div>
|
|
</div>
|
|
<div class="student-box">
|
|
<div class="inner-box">
|
|
<h2>Student Information</h2>
|
|
<p><span id="student-name">Name:</span> </p>
|
|
<p><span id="student-surname">Surname:</span> </p>
|
|
<p><span id="student-email">Email:</span> </p>
|
|
</div>
|
|
|
|
<div class="linked-parent">
|
|
<h2>Linked Parent</h2>
|
|
<p><span id="linked-parent-info"></span></p>
|
|
</div>
|
|
|
|
<button id="generate-token-btn">Generate Parent Link Token</button>
|
|
|
|
<a href="/selfservice/api/logout" style="text-decoration: none;">
|
|
<button id="logout-btn">Logout</button>
|
|
</a>
|
|
</div>
|
|
</body>
|
|
<script>
|
|
$(document).ready(function() {
|
|
$.get('/selfservice/api/whoami')
|
|
.done(function(response) {
|
|
const upn = response.upn;
|
|
$.get(`/selfservice/api/student/${upn}`)
|
|
.done(function(student) {
|
|
$('#student-name').text(`Name: ${student.first_name}`);
|
|
$('#student-surname').text(`Surname: ${student.last_name}`);
|
|
$('#student-email').text(`Email: ${student.username}`);
|
|
$('#linked-parent-info').text(student.primary_parent ? `Email: ${student.primary_parent}` : 'No linked parent');
|
|
})
|
|
.fail(function() {
|
|
showModal('Session expired, please login again');
|
|
setTimeout(() => {
|
|
window.location.href = '/selfservice';
|
|
}, 1000);
|
|
});
|
|
|
|
// Add click event handler to the "Generate Parent Link Token" button
|
|
$('#generate-token-btn').click(function() {
|
|
$.get(`/selfservice/api/student/${upn}/pairing-code`)
|
|
.done(function(pairingCode) {
|
|
showModal(`Your pairing code is: ${pairingCode}`);
|
|
})
|
|
.fail(function() {
|
|
showModal('Failed to generate pairing code');
|
|
});
|
|
});
|
|
})
|
|
.fail(function() {
|
|
showModal('Session expired, please login again');
|
|
setTimeout(() => {
|
|
window.location.href = '/selfservice';
|
|
}, 1000);
|
|
});
|
|
|
|
function showModal(text) {
|
|
$('#modal-text').text(text);
|
|
$('#modal').show();
|
|
}
|
|
|
|
$('#close').click(function() {
|
|
$('#modal').hide();
|
|
});
|
|
});
|
|
</script> |