137 lines
5.4 KiB
HTML
137 lines
5.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="es">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Gases del Oriente</title>
|
|
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js" defer></script>
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<!-- Cargar jQuery primero -->
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
<!-- Luego cargar Select2 -->
|
|
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
|
<style>
|
|
[x-cloak] {
|
|
display: none !important;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body class="bg-gray-200 w-full">
|
|
<main class="flex justify-between w-full">
|
|
<!-- Componente Lateral (Barra Lateral) -->
|
|
{{template "partials/lateral" .}}
|
|
<div class="w-full">
|
|
{{template "partials/header" .}}
|
|
<div class="w-full px-3 py-3 h-[calc(100vh-64px)] overflow-auto">
|
|
{{embed}}
|
|
</div>
|
|
{{template "partials/footer" .}}
|
|
</div>
|
|
</main>
|
|
<div x-data="sessionTimeout" x-init="init()" x-cloak class="hidden sm:block">
|
|
<!-- Contador General de Inactividad -->
|
|
<div x-show="!showModal" class="fixed top-2 right-20 border text rounded-lg p-2 bg-gray-100 text-sm">
|
|
<p>Tiempo restante: <span x-text="formatTime(inactivityCountdown)"></span></p>
|
|
</div>
|
|
<!-- Modal -->
|
|
<div x-show="showModal" class="fixed inset-0 flex items-center justify-center bg-gray-800 bg-opacity-75">
|
|
<div class="bg-white rounded-lg shadow-md p-8 w-[600px] relative">
|
|
<h2 class="text-xl font-bold mb-6 text-center">¿Deseas continuar?</h2>
|
|
<p class="text-gray-600 mb-6 text-center text-base">
|
|
Has estado inactivo. Elige "Continuar" para seguir con tu sesión o "Cerrar sesión" para salir.
|
|
</p>
|
|
<!-- Contador del tiempo para responder -->
|
|
<p class="text-center text-red-500 font-semibold mb-4">
|
|
Tiempo para responder: <span x-text="countdown"></span> seg
|
|
</p>
|
|
<div class="flex justify-around">
|
|
<button @click="continueSession"
|
|
class="px-6 py-3 bg-[#8eb02f] text-white text-base rounded-lg hover:bg-[#698126]">
|
|
Continuar
|
|
</button>
|
|
<form action="/do/logout" method="POST" class="inline-block">
|
|
<button type="submit"
|
|
class="px-6 py-3 bg-gray-500 text-white text-base rounded-lg hover:bg-gray-600">
|
|
Cerrar sesión
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.addEventListener("alpine:init", () => {
|
|
Alpine.data("sessionTimeout", () => ({
|
|
showModal: false,
|
|
countdown: 60, // 10 segundos para responder
|
|
inactivityCountdown: 300, // 5 minutos
|
|
inactivityTimer: null,
|
|
timer: null,
|
|
|
|
init() {
|
|
this.resetInactivityTimer();
|
|
|
|
// Detectar actividad
|
|
window.addEventListener("mousemove", () => this.resetInactivityTimer());
|
|
window.addEventListener("keydown", () => this.resetInactivityTimer());
|
|
},
|
|
|
|
resetInactivityTimer() {
|
|
clearTimeout(this.inactivityTimer);
|
|
this.inactivityCountdown = 300; // Reiniciar contador a 5 minutos
|
|
this.startInactivityTimer();
|
|
},
|
|
|
|
startInactivityTimer() {
|
|
this.inactivityTimer = setInterval(() => {
|
|
this.inactivityCountdown--;
|
|
if (this.inactivityCountdown <= 0) {
|
|
clearInterval(this.inactivityTimer);
|
|
this.promptLogout();
|
|
}
|
|
}, 1000);
|
|
},
|
|
|
|
promptLogout() {
|
|
this.showModal = true;
|
|
this.startCountdown();
|
|
},
|
|
|
|
startCountdown() {
|
|
this.countdown = 60; // Reiniciar contador del modal
|
|
clearInterval(this.timer);
|
|
this.timer = setInterval(() => {
|
|
this.countdown--;
|
|
if (this.countdown <= 0) {
|
|
this.logout();
|
|
}
|
|
}, 1000);
|
|
},
|
|
|
|
continueSession() {
|
|
clearInterval(this.timer);
|
|
this.showModal = false;
|
|
this.resetInactivityTimer();
|
|
},
|
|
|
|
logout() {
|
|
clearInterval(this.timer);
|
|
document.querySelector('form[action="/do/logout"]').submit();
|
|
},
|
|
|
|
formatTime(seconds) {
|
|
const minutes = Math.floor(seconds / 60);
|
|
const remainingSeconds = seconds % 60;
|
|
return `${minutes}:${remainingSeconds.toString().padStart(2, "0")}`;
|
|
},
|
|
}));
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html> |