31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import Swal from "sweetalert2";
|
|
import trans from "./modules/trans";
|
|
import validateSession from "./modules/session_pinger";
|
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
let timeOut: ReturnType<typeof setTimeout> | undefined = undefined;
|
|
const sessionInvalidAction = () => {
|
|
Swal.fire({
|
|
title: trans.methods.__("Session expirée"),
|
|
text: trans.methods.__(
|
|
"Votre session à expiré vous devrez recharger la page pour soumettre des informations."
|
|
),
|
|
icon: "error",
|
|
// * Bootstrap Styling
|
|
customClass: {
|
|
confirmButton: "btn btn-lg btn-success ms-3 me-3",
|
|
cancelButton: "btn btn-lg btn-danger ms-3 me-3",
|
|
},
|
|
});
|
|
clearTimeout(timeOut);
|
|
},
|
|
timer = 10000,
|
|
timerAction = () => {
|
|
validateSession.methods.validateSession(sessionInvalidAction);
|
|
timeOut = setTimeout(timerAction, timer);
|
|
};
|
|
|
|
if (window.__SESSION_WATCH) {
|
|
timerAction();
|
|
}
|
|
});
|