This commit is contained in:
@@ -0,0 +1,207 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="pt-BR">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Resetar Sistema - DentalSys</title>
|
||||
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700&display=swap">
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
<style>
|
||||
body {
|
||||
background-color: #f8f9fa;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
.reset-container {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 30px rgba(0,0,0,0.1);
|
||||
width: 100%;
|
||||
max-width: 450px;
|
||||
padding: 40px;
|
||||
border-top: 5px solid #dc3545;
|
||||
}
|
||||
.reset-header {
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.reset-header h1 {
|
||||
color: #dc3545;
|
||||
font-size: 1.8rem;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.reset-header p {
|
||||
color: #666;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.warning-box {
|
||||
background: #fff3cd;
|
||||
color: #856404;
|
||||
padding: 15px;
|
||||
border-radius: 8px;
|
||||
border-left: 4px solid #ffeeba;
|
||||
margin-bottom: 25px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
.form-control {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
font-size: 1rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.btn {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 1rem;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
.btn-danger {
|
||||
background: #dc3545;
|
||||
color: white;
|
||||
}
|
||||
.btn-danger:hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.btn-link {
|
||||
background: none;
|
||||
color: #667eea;
|
||||
margin-top: 15px;
|
||||
text-decoration: underline;
|
||||
}
|
||||
.spinner {
|
||||
border: 2px solid #f3f3f3;
|
||||
border-top: 2px solid white;
|
||||
border-radius: 50%;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
animation: spin 1s linear infinite;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
margin-right: 8px;
|
||||
display: none;
|
||||
}
|
||||
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
||||
|
||||
.toast {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%) translateY(100px);
|
||||
background: #333;
|
||||
color: white;
|
||||
padding: 12px 24px;
|
||||
border-radius: 8px;
|
||||
transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
||||
z-index: 1000;
|
||||
opacity: 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
|
||||
.toast.error { background: #e74c3c; }
|
||||
.toast.success { background: #2ecc71; }
|
||||
</style>
|
||||
<script>
|
||||
// Proteger rota
|
||||
if (!localStorage.getItem('auth_token')) {
|
||||
window.location.href = '/login';
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="reset-container">
|
||||
<div class="reset-header">
|
||||
<h1>⚠️ Apagar Tudo</h1>
|
||||
<p>Preparação para Servidor de Produção</p>
|
||||
</div>
|
||||
|
||||
<div class="warning-box">
|
||||
<strong>Atenção:</strong> Esta ação é <b>irreversível</b>. Ela irá apagar todos os pacientes, GTOs, histórico e todas as imagens (físicas e do banco). O seu usuário e senha de acesso serão mantidos.
|
||||
</div>
|
||||
|
||||
<form id="resetForm" onsubmit="factoryReset(event)">
|
||||
<div class="form-group">
|
||||
<label for="password">Confirme sua senha atual:</label>
|
||||
<input type="password" id="password" class="form-control" placeholder="Sua senha de administrador" required>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-danger" id="btnReset">
|
||||
<span class="spinner" id="spinner"></span> DELETAR TODOS OS DADOS
|
||||
</button>
|
||||
<button type="button" class="btn btn-link" onclick="window.location.href='/'">Cancelar e voltar</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="toast" class="toast">Mensagem</div>
|
||||
|
||||
<script>
|
||||
function showToast(msg, type = 'success') {
|
||||
const t = document.getElementById('toast');
|
||||
t.textContent = msg;
|
||||
t.className = 'toast show ' + type;
|
||||
setTimeout(() => { t.className = 'toast'; }, 4000);
|
||||
}
|
||||
|
||||
async function factoryReset(event) {
|
||||
event.preventDefault();
|
||||
const password = document.getElementById('password').value;
|
||||
if (!password) return;
|
||||
|
||||
const btn = document.getElementById('btnReset');
|
||||
const spinner = document.getElementById('spinner');
|
||||
btn.disabled = true;
|
||||
spinner.style.display = 'inline-block';
|
||||
|
||||
try {
|
||||
const token = localStorage.getItem('auth_token');
|
||||
const res = await fetch('/api/system/factory-reset', {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({ password })
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error || 'Erro desconhecido');
|
||||
|
||||
showToast(`Sucesso! ${data.filesDeleted} arquivos foram apagados.`, 'success');
|
||||
document.getElementById('password').value = '';
|
||||
|
||||
// Redireciona para o painel limpo após 2 segundos
|
||||
setTimeout(() => {
|
||||
window.location.href = '/';
|
||||
}, 2000);
|
||||
|
||||
} catch (err) {
|
||||
showToast(err.message, 'error');
|
||||
btn.disabled = false;
|
||||
spinner.style.display = 'none';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user