82 lines
3.3 KiB
PHP
82 lines
3.3 KiB
PHP
<?php
|
|
// Verificar se o usuário está logado
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header("Location: login.php");
|
|
exit();
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="pt-BR">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Status do Processamento</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<style>
|
|
.status { margin-top: 20px; }
|
|
.status p { margin: 5px 0; }
|
|
.completed { color: green; }
|
|
.pending { color: orange; }
|
|
.processing { color: blue; }
|
|
.error { color: red; }
|
|
.pagination { margin-top: 20px; text-align: center; }
|
|
.pagination a { margin: 0 5px; text-decoration: none; color: #007BFF; }
|
|
.pagination a:hover { text-decoration: underline; }
|
|
</style>
|
|
<script>
|
|
function checkStatus(page = 1) {
|
|
fetch(`./prova/status_check.php?page_num=${page}`)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
let statusContainer = document.getElementById('statusContainer');
|
|
statusContainer.innerHTML = '';
|
|
data.status.forEach(item => {
|
|
let p = document.createElement('p');
|
|
p.className = item.status;
|
|
p.textContent = `Arquivo: ${item.file_path} - Status: ${item.status}`;
|
|
statusContainer.appendChild(p);
|
|
});
|
|
|
|
// Paginação
|
|
let paginationContainer = document.getElementById('paginationContainer');
|
|
paginationContainer.innerHTML = '';
|
|
if (data.current_page > 1) {
|
|
let prevLink = document.createElement('a');
|
|
prevLink.href = `javascript:checkStatus(${data.current_page - 1})`;
|
|
prevLink.textContent = '« Anterior';
|
|
paginationContainer.appendChild(prevLink);
|
|
}
|
|
for (let i = 1; i <= data.total_pages; i++) {
|
|
let pageLink = document.createElement('a');
|
|
pageLink.href = `javascript:checkStatus(${i})`;
|
|
if (i === data.current_page) {
|
|
pageLink.style.fontWeight = 'bold';
|
|
}
|
|
pageLink.textContent = i;
|
|
paginationContainer.appendChild(pageLink);
|
|
}
|
|
if (data.current_page < data.total_pages) {
|
|
let nextLink = document.createElement('a');
|
|
nextLink.href = `javascript:checkStatus(${data.current_page + 1})`;
|
|
nextLink.textContent = 'Próximo »';
|
|
paginationContainer.appendChild(nextLink);
|
|
}
|
|
});
|
|
}
|
|
|
|
setInterval(() => checkStatus(), 15000); // Atualizar a cada 15 segundos
|
|
window.onload = () => checkStatus();
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h2>Status do Processamento</h2>
|
|
<div id="statusContainer" class="status">
|
|
<!-- Status dos arquivos será exibido aqui -->
|
|
</div>
|
|
<div id="paginationContainer" class="pagination">
|
|
<!-- Paginação será exibida aqui -->
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|