lti-provider/src/main/resources/static/tool/lti/js/main.js

45 lines
1.7 KiB
JavaScript

document.getElementById('submitBtn').addEventListener('click', function () {
// Показываем, что загрузка началась
const statusContainer = document.getElementById('statusContainer');
const icon = document.getElementById('icon');
const statusLabel = document.getElementById('statusLabel');
// Получаем данные пользователя
const contextId = document.getElementById('contextId')?.value || 'unknown';
const participantId = document.getElementById('participantId')?.value || 'unknown';
const payload = {
contextId: contextId,
participantId: participantId
};
fetch('/tool/lti/result/docker', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
})
.then(response => {
if (!response.ok) throw new Error(`Ошибка сети: ${response.status}`);
return response.json();
})
.then(data => {
// Показываем статус
statusContainer.style.display = 'flex';
if (data.status === 'success') {
icon.className = 'fa-solid fa-check-circle status-success';
statusLabel.textContent = 'Success';
statusLabel.className = 'status-label status-success';
} else {
icon.className = 'fa-solid fa-xmark-circle status-failed';
statusLabel.textContent = 'Failed';
statusLabel.className = 'status-label status-failed';
}
})
.catch(() => {
statusContainer.style.display = 'flex';
icon.className = 'fa-solid fa-xmark-circle status-failed';
statusLabel.textContent = 'Failed';
statusLabel.className = 'status-label status-failed';
});
});