From 9d323bdb217b65a912464dca940db8b398ef53b6 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 4 Jun 2024 14:38:09 +0200 Subject: [PATCH 01/13] refactor: refs #6555 create call fn & WIP: replace jquery --- js/index.js | 129 ++++++++++++++---------------- js/main.js | 225 ++++++++++++++++++++++++++-------------------------- 2 files changed, 170 insertions(+), 184 deletions(-) diff --git a/js/index.js b/js/index.js index 929e86d..34d0176 100644 --- a/js/index.js +++ b/js/index.js @@ -1,84 +1,73 @@ let pin = ""; +if ("addEventListener" in document) { + document.addEventListener("DOMContentLoaded", () => { + FastClick.attach(document.body); -$(document).ready(function () { - FastClick.attach(document.body); - setEvents(); -}); + const heartEl = document.querySelector("body > h1 > span"); + refreshDeviceLabel(); -function setEvents() { - const heartEl = document.querySelector('body > h1 > span'); - refreshDeviceLabel() + heartEl.addEventListener("click", () => { + Swal.fire({ + title: "Iniciar sesión", + html: ` + + + `, + confirmButtonText: "Login", + showCloseButton: true, + showCancelButton: false, + }).then(async (result) => { + if (result.isConfirmed) + signIn(document.querySelector("#user").value, document.querySelector("#pass").value, document.querySelector("#device").value); + }); + }); - heartEl.addEventListener('click', function() { - Swal.fire({ - title: 'Iniciar sesión', - html: - ` - - `, - confirmButtonText: 'Login', - showCloseButton: true, - showCancelButton: false, - }).then(async (result) => { - if(result.isConfirmed) { - const user = $('#user').val(); - const pass = $('#pass').val(); - const device = $('#device').val(); - signIn(user, pass, device); + $(".btnnum").on("click", function () { + pin += parseInt($(this).children().html()); + $("#txtPin").text(pin); + }); + + $(".btnCancel").on("click", function () { + pin = ""; + $("#txtPin").text("ID USUARIO"); + }); + + $(".btnOk").on("click", function () { + if (pin) { + login(); } }); - }); - - $(".btnnum").on("click", function () { - pin += parseInt($(this).children().html()); - $("#txtPin").text(pin); }); +} - $(".btnCancel").on("click", function () { +async function login() { + try { + const res = await call("WorkerTimeControls/login", { + method: "POST", + body: { pin }, + }); + const data = await res.json(); + localStorage.setItem("userData", JSON.stringify(data)); + window.location = "clockIn.html"; + } catch (e) { + document.querySelector("#txtPin").textContent = "ID USUARIO"; pin = ""; - $("#txtPin").text("ID USUARIO"); - }); - - $(".btnOk").on("click", function () { - if (pin) { - login(); - }; - }); + } } -function login() { - $.post({ - urlPath: 'WorkerTimeControls/login', - jsonData: {pin}, - processData: false, - success: function (data) { - localStorage.setItem("userData", JSON.stringify(data)); - window.location = "clockIn.html"; - }, - error: function() { - $("#txtPin").text("ID USUARIO"); - pin = ""; - } +async function signIn(user, password, device) { + const res = await call("vnUsers/sign-in", { + method: "POST", + body: { user, password }, }); + const data = await res.json(); + localStorage.setItem("token", data.token); + localStorage.setItem("ttl", data.ttl); + localStorage.setItem("user", user); + localStorage.setItem("device", device); + localStorage.setItem("created", Date.now()); + getTokenConfig(); + refreshDeviceLabel(); } -function signIn(user, password, device) { - $.post({ - urlPath: 'vnUsers/sign-in', - jsonData: {user, password}, - processData: false, - success: function (data) { - localStorage.setItem("token", data.token); - localStorage.setItem("ttl", data.ttl); - localStorage.setItem("user", user); - localStorage.setItem("device", device); - localStorage.setItem("created", Date.now()); - getTokenConfig(); - refreshDeviceLabel(); - }, - }) -} - -function refreshDeviceLabel() { - $("#deviceLabel").text(localStorage.getItem('device') ?? '') -} \ No newline at end of file +const refreshDeviceLabel = () => (document.querySelector("#deviceLabel").textContent = localStorage.getItem("device") ?? ""); diff --git a/js/main.js b/js/main.js index 1d4f89b..82636cd 100644 --- a/js/main.js +++ b/js/main.js @@ -1,130 +1,127 @@ -const renewPeriod = localStorage.getItem('renewPeriod'); +const renewPeriod = localStorage.getItem("renewPeriod"); let intervalId, isCheckingToken; +const txtConfirm = document.querySelector(".txtConfirm"); +const confirm = document.querySelector(".confirm"); function confirmReset() { - $(".confirm").removeClass('confirmKO'); - $(".txtConfirm").empty(); + confirm.classList.remove("confirmKO"); + confirm.style.display = "none"; + txtConfirm.textContent = ""; } -function printError(msg){ +// WIP: fadeIn / fadeOut +function printError(msg) { confirmReset(); - $(".txtConfirm").append(msg); - $(".confirm").addClass('confirmKO'); + const txtConfirm = document.querySelector(".txtConfirm"); + txtConfirm.textContent = msg; + const confirm = document.querySelector(".confirm"); + confirm.classList.add("confirmKO"); + confirm.style.display = "block"; + $(".confirm").fadeIn(200); - setTimeout(function() { + setTimeout(() => { $(".confirm").fadeOut(200); setTimeout(confirmReset, 200); }, 2300); } -function renewToken() { - $.post({ - urlPath: 'vnUsers/renewToken', - processData: false, - success: function (data) { - localStorage.setItem("token", data.id); - localStorage.setItem("ttl", data.ttl); - localStorage.setItem("created", Date.now()); - }, - }) +async function renewToken() { + const res = await call("AccessTokens/renewToken", {}); + + const data = await res.json(); + localStorage.setItem("ttl", data.ttl); + localStorage.setItem("created", Date.now()); } -function getTokenConfig() { - const filter = {fields: ['renewInterval', 'renewPeriod']}; - $.get({ - urlPath: 'AccessTokenConfigs/findOne', - jsonData: filter, - processData: false, - success: function (data) { - if (!data) return; - localStorage.setItem('renewPeriod', data.renewPeriod); - clearInterval(intervalId); - intervalId = setInterval(() => checkValidity(), data.renewInterval * 1000); - }, - }) -} - -function checkValidity() { - const created = +localStorage.getItem('created'); - const ttl = localStorage.getItem('ttl'); - - if (isCheckingToken || !created) return; - isCheckingToken = true; - - const renewPeriodInSeconds = Math.min(ttl, renewPeriod) * 1000; - const maxDate = created + renewPeriodInSeconds; - const now = new Date(); - - if (now.getTime() <= maxDate) return isCheckingToken = false; - - renewToken(); - isCheckingToken = false; -} - -$.ajaxPrefilter(function(xhr) { - const orgErrorHandler = xhr.error; - const token = localStorage.getItem('token') - - Object.assign(xhr, { - url: `/api/${xhr.urlPath}`, - headers: { - Authorization : token - }, - timeout: 2000, - contentType: 'application/json; charset=utf-8', - dataType: 'json', - processData: false, - data: JSON.stringify(xhr.jsonData), - error: function(xhr, textStatus, err) { - if (orgErrorHandler) { - try { - orgErrorHandler(xhr, textStatus, err); - } catch (e) { - err = e; - } - } - - if(xhr?.responseJSON?.error?.code == 'periodNotExceeded') return; - - switch (textStatus){ - case 'parsererror': - mensaje = 'Requested JSON parse failed'; - break; - case 'timeout': - mensaje = 'Time out error'; - break; - case 'abort': - mensaje = 'Ajax request aborted'; - break; - case 'error': - if (xhr?.responseJSON?.error?.name == 'UserError') { - mensaje = xhr.responseJSON.error.message; - break; - } - switch (xhr.status){ - case 0: - mensaje = 'Not connect: Verify Network'; - break; - case 504: - mensaje = 'No se ha podido conectar con Salix, consulta con informática'; - break; - case 555: - mensaje = JSON.parse(xhr.statusText).Message; - break; - default: - if (xhr.status >= 400 && xhr.status < 500) - mensaje = xhr.statusText; - else - mensaje = 'Ha ocurrido un error, consulta con informática'; - } - break; - default: - mensaje = 'Ha ocurrido un error, consulta con informática'; - } - printError(mensaje); - - } +async function getTokenConfig() { + const res = await call("AccessTokenConfigs/findOne", { + params: JSON.stringify({ + filter: { fields: ["renewInterval", "renewPeriod"] }, + }), }); -}); -if(renewPeriod) getTokenConfig(); \ No newline at end of file + const data = await res.json(); + if (!data) return; + + localStorage.setItem("renewPeriod", data.renewPeriod); + clearInterval(intervalId); + + intervalId = setInterval(() => { + const created = +localStorage.getItem("created"); + const ttl = localStorage.getItem("ttl"); + + if (isCheckingToken || !created) return; + isCheckingToken = true; + + const renewPeriodInSeconds = Math.min(ttl, renewPeriod) * 1000; + const maxDate = created + renewPeriodInSeconds; + + if (new Date().getTime() <= maxDate) return (isCheckingToken = false); + + renewToken(); + isCheckingToken = false; + }, data.renewInterval * 1000); +} + +/// WIP: MUST try thru it! +async function call(url, { method = "GET", body = {}, params = {} }) { + const controller = new AbortController(); + const { signal } = controller; + const timeoutId = setTimeout(() => controller.abort(), 2000); + let mensaje; + const opts = { + method, + headers: { + Authorization: localStorage.getItem("token"), + "Content-Type": "application/json; charset=utf-8", + }, + signal, + }; + + if (method === "GET") url += "?" + new URLSearchParams(params).toString(); + else if (method === "POST") opts.body = JSON.stringify(body); + + try { + const res = await fetch(`/api/${url}`, opts); + clearTimeout(timeoutId); + return res; + } catch (e) { + switch (e.name) { + case "SyntaxError": + mensaje = "Requested JSON parse failed"; + break; + case "TimeoutError": + mensaje = "Time out error"; + break; + case "AbortError": + mensaje = "Ajax request aborted"; + break; + case "UserError": + mensaje = e.message; + break; + case "error": + switch (e.code) { + case 0: + mensaje = "Not connect: Verify Network"; + break; + case 504: + mensaje = "No se ha podido conectar con Salix, consulta con informática"; + break; + case 555: + mensaje = e.message; + break; + case e.code >= 400 && e.code < 500: + mensaje = e.name; + break; + default: + mensaje = "Ha ocurrido un error, consulta con informática"; + } + break; + default: + mensaje = "Ha ocurrido un error, consulta con informática"; + } + printError(mensaje); + } +} + +if (renewPeriod) getTokenConfig(); From d2b5e1fc76b5783fd42fedf986f4f5f749322fc6 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 14 Jun 2024 15:57:23 +0200 Subject: [PATCH 02/13] refactor: refs #6555 wip: improve error handler --- js/main.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/js/main.js b/js/main.js index 82636cd..15ae8aa 100644 --- a/js/main.js +++ b/js/main.js @@ -68,7 +68,6 @@ async function call(url, { method = "GET", body = {}, params = {} }) { const controller = new AbortController(); const { signal } = controller; const timeoutId = setTimeout(() => controller.abort(), 2000); - let mensaje; const opts = { method, headers: { @@ -86,6 +85,8 @@ async function call(url, { method = "GET", body = {}, params = {} }) { clearTimeout(timeoutId); return res; } catch (e) { + let mensaje = "Ha ocurrido un error, consulta con informática"; + switch (e.name) { case "SyntaxError": mensaje = "Requested JSON parse failed"; @@ -99,7 +100,7 @@ async function call(url, { method = "GET", body = {}, params = {} }) { case "UserError": mensaje = e.message; break; - case "error": + default: switch (e.code) { case 0: mensaje = "Not connect: Verify Network"; @@ -108,17 +109,11 @@ async function call(url, { method = "GET", body = {}, params = {} }) { mensaje = "No se ha podido conectar con Salix, consulta con informática"; break; case 555: - mensaje = e.message; - break; - case e.code >= 400 && e.code < 500: - mensaje = e.name; + mensaje = "Error 555"; break; default: - mensaje = "Ha ocurrido un error, consulta con informática"; + if (e.status >= 400 && e.status < 500) mensaje = e.message; } - break; - default: - mensaje = "Ha ocurrido un error, consulta con informática"; } printError(mensaje); } From ab326dd6ac2e994d0e8afa98e82bd3bd93c1a460 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 14 Jun 2024 17:01:06 +0200 Subject: [PATCH 03/13] fix: refs #6555 update package & fix params builder --- js/main.js | 15 +++-- package-lock.json | 161 ++++++++++++++++++++++++++-------------------- package.json | 2 +- 3 files changed, 103 insertions(+), 75 deletions(-) diff --git a/js/main.js b/js/main.js index 15ae8aa..6b7804f 100644 --- a/js/main.js +++ b/js/main.js @@ -35,9 +35,7 @@ async function renewToken() { async function getTokenConfig() { const res = await call("AccessTokenConfigs/findOne", { - params: JSON.stringify({ - filter: { fields: ["renewInterval", "renewPeriod"] }, - }), + params: { filter: { fields: ["renewInterval", "renewPeriod"] } }, }); const data = await res.json(); @@ -77,8 +75,15 @@ async function call(url, { method = "GET", body = {}, params = {} }) { signal, }; - if (method === "GET") url += "?" + new URLSearchParams(params).toString(); - else if (method === "POST") opts.body = JSON.stringify(body); + if (method === "GET") { + const searchParams = new URLSearchParams(); + for (let key in params) { + if (params.hasOwnProperty(key) && typeof params[key] === "object") searchParams.append(key, JSON.stringify(params[key])); + else searchParams.append(key, params[key]); + } + + url += "?" + searchParams.toString(); + } else if (method === "POST") opts.body = JSON.stringify(body); try { const res = await fetch(`/api/${url}`, opts); diff --git a/package-lock.json b/package-lock.json index d8203db..61f5938 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "worker-time-control", - "version": "1.0.2", + "version": "24.22.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -39,13 +39,13 @@ "dev": true }, "body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", "dev": true, "requires": { "bytes": "3.1.2", - "content-type": "~1.0.4", + "content-type": "~1.0.5", "debug": "2.6.9", "depd": "2.0.0", "destroy": "1.2.0", @@ -53,18 +53,29 @@ "iconv-lite": "0.4.24", "on-finished": "2.4.1", "qs": "6.11.0", - "raw-body": "2.5.1", + "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" } }, "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "requires": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" + }, + "dependencies": { + "fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + } } }, "bytes": { @@ -74,14 +85,16 @@ "dev": true }, "call-bind": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz", - "integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", "dev": true, "requires": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.1", - "set-function-length": "^1.1.1" + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.1" } }, "content-disposition": { @@ -100,9 +113,9 @@ "dev": true }, "cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "dev": true }, "cookie-signature": { @@ -121,14 +134,14 @@ } }, "define-data-property": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz", - "integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", "dev": true, "requires": { - "get-intrinsic": "^1.2.1", - "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.0" + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" } }, "depd": { @@ -160,6 +173,21 @@ "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", "dev": true }, + "es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dev": true, + "requires": { + "get-intrinsic": "^1.2.4" + } + }, + "es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true + }, "escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -179,17 +207,17 @@ "dev": true }, "express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dev": true, "requires": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -222,15 +250,6 @@ "resolved": "https://registry.npmjs.org/fastclick/-/fastclick-1.0.6.tgz", "integrity": "sha512-cXyDBT4g0uWl/Xe75QspBDAgAWQ0lkPi/zgp6YFEUHj6WV6VIZl7R6TiDZhdOVU3W4ehp/8tG61Jev1jit+ztQ==" }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, - "requires": { - "to-regex-range": "^5.0.1" - } - }, "finalhandler": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", @@ -247,9 +266,9 @@ } }, "follow-redirects": { - "version": "1.15.4", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz", - "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==", + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "dev": true }, "forwarded": { @@ -271,11 +290,12 @@ "dev": true }, "get-intrinsic": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz", - "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", "dev": true, "requires": { + "es-errors": "^1.3.0", "function-bind": "^1.1.2", "has-proto": "^1.0.1", "has-symbols": "^1.0.3", @@ -292,18 +312,18 @@ } }, "has-property-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", - "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", "dev": true, "requires": { - "get-intrinsic": "^1.2.2" + "es-define-property": "^1.0.0" } }, "has-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", - "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", + "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", "dev": true }, "has-symbols": { @@ -313,9 +333,9 @@ "dev": true }, "hasown": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", - "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", "dev": true, "requires": { "function-bind": "^1.1.2" @@ -531,9 +551,9 @@ "dev": true }, "raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", "dev": true, "requires": { "bytes": "3.1.2", @@ -602,15 +622,17 @@ } }, "set-function-length": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz", - "integrity": "sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", "dev": true, "requires": { - "define-data-property": "^1.1.1", - "get-intrinsic": "^1.2.1", + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.0" + "has-property-descriptors": "^1.0.2" } }, "setprototypeof": { @@ -620,14 +642,15 @@ "dev": true }, "side-channel": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", - "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", + "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", "dev": true, "requires": { - "call-bind": "^1.0.0", - "get-intrinsic": "^1.0.2", - "object-inspect": "^1.9.0" + "call-bind": "^1.0.7", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" } }, "statuses": { diff --git a/package.json b/package.json index fd39dfd..7ceacf6 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "sweetalert2": "11.10.1" }, "devDependencies": { - "express": "^4.18.2", + "express": "^4.19.2", "http-proxy-middleware": "^2.0.6" } } From 76411063bad5f333276679d8bb59b2c69f7e50be Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 14 Jun 2024 17:06:27 +0200 Subject: [PATCH 04/13] feat: refs #6555 iron out url parms builder --- js/main.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/js/main.js b/js/main.js index 6b7804f..7d53778 100644 --- a/js/main.js +++ b/js/main.js @@ -77,9 +77,8 @@ async function call(url, { method = "GET", body = {}, params = {} }) { if (method === "GET") { const searchParams = new URLSearchParams(); - for (let key in params) { - if (params.hasOwnProperty(key) && typeof params[key] === "object") searchParams.append(key, JSON.stringify(params[key])); - else searchParams.append(key, params[key]); + for (let [key, value] of Object.entries(params)) { + searchParams.append(key, typeof value === "object" ? JSON.stringify(value) : value); } url += "?" + searchParams.toString(); From b2fa1d341b8b6f2988443d9b28038478f437d442 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 14 Jun 2024 17:25:56 +0200 Subject: [PATCH 05/13] refactor: refs #6555 convert jquery index file to js --- js/index.js | 19 +++++++++---------- js/main.js | 1 - 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/js/index.js b/js/index.js index 34d0176..3161aac 100644 --- a/js/index.js +++ b/js/index.js @@ -4,6 +4,7 @@ if ("addEventListener" in document) { FastClick.attach(document.body); const heartEl = document.querySelector("body > h1 > span"); + const txtPin = document.querySelector("#txtPin"); refreshDeviceLabel(); heartEl.addEventListener("click", () => { @@ -22,21 +23,19 @@ if ("addEventListener" in document) { }); }); - $(".btnnum").on("click", function () { - pin += parseInt($(this).children().html()); - $("#txtPin").text(pin); + document.querySelectorAll(".btnnum").forEach((btn) => { + btn.addEventListener("click", (e) => { + pin += +e.currentTarget.children[0].innerHTML; + txtPin.textContent = pin; + }); }); - $(".btnCancel").on("click", function () { + document.querySelector(".btnCancel").addEventListener("click", () => { pin = ""; - $("#txtPin").text("ID USUARIO"); + txtPin.textContent = "ID USUARIO"; }); - $(".btnOk").on("click", function () { - if (pin) { - login(); - } - }); + document.querySelector(".btnOk").addEventListener("click", () => pin && login()); }); } diff --git a/js/main.js b/js/main.js index 7d53778..ef8954a 100644 --- a/js/main.js +++ b/js/main.js @@ -80,7 +80,6 @@ async function call(url, { method = "GET", body = {}, params = {} }) { for (let [key, value] of Object.entries(params)) { searchParams.append(key, typeof value === "object" ? JSON.stringify(value) : value); } - url += "?" + searchParams.toString(); } else if (method === "POST") opts.body = JSON.stringify(body); From 213b4f85204e3ad5a1b7cc322da3e865e47c6539 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 18 Jun 2024 16:39:32 +0200 Subject: [PATCH 06/13] refactor: #6555 code translation JQuery to Js --- clockIn.html | 1 - css/style.css | 25 +- index.html | 3 +- js/clockIn.js | 298 ++++++++-------------- js/index.js | 6 +- js/main.js | 36 ++- package-lock.json | 625 +++++++++++++++++++++++++++++++++------------- package.json | 3 +- 8 files changed, 592 insertions(+), 405 deletions(-) diff --git a/clockIn.html b/clockIn.html index 949c37d..c0d7cd9 100644 --- a/clockIn.html +++ b/clockIn.html @@ -11,7 +11,6 @@ and open the template in the editor. - diff --git a/css/style.css b/css/style.css index 4a9628a..6220860 100644 --- a/css/style.css +++ b/css/style.css @@ -202,7 +202,7 @@ h3 { text-align: center; } .footer { - animation: faceIn 0.2s ease-in-out; + animation: fadeIn 0.2s ease-in-out; } .in, .inMiddle { display: inline; @@ -372,6 +372,15 @@ header { margin-bottom: 20px; } +.fade-in { + display: block; + animation: fadeIn 0.2s ease-in-out forwards; +} + +.fade-out { + animation: fadeOut 0.2s ease-in-out forwards; +} + @keyframes slideIn { 0% { transform: translateY(-100%); @@ -382,7 +391,8 @@ header { opacity: 1; } } -@keyframes faceIn { + +@keyframes fadeIn { 0% { opacity: 0; } @@ -391,10 +401,21 @@ header { } } +@keyframes fadeOut { + 0% { + opacity: 1; + } + 100% { + opacity: 0; + display: none; + } +} + @font-face { font-family: 'Poppins'; src: url('../font/Poppins.ttf') format('truetype'); } + @font-face { font-family: 'Poppins'; src: url('../font/Poppins-Bold.ttf') format('truetype'); diff --git a/index.html b/index.html index 37f61f8..7747dbc 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,6 @@ and open the template in the editor. - @@ -80,7 +79,7 @@ and open the template in the editor.

- developed by Verdnatura with + powered by Verdnatura with

diff --git a/js/clockIn.js b/js/clockIn.js index 50bb19d..d4f87d3 100644 --- a/js/clockIn.js +++ b/js/clockIn.js @@ -1,237 +1,139 @@ let userData = ""; +const footer = document.querySelector(".footer"); +const txtName = document.querySelector("#txtNombre"); +const inBtn = document.querySelector(".in"); +const inMiddleBtn = document.querySelector(".inMiddle"); +const outMiddleBtn = document.querySelector(".outMiddle"); +const outBtn = document.querySelector(".out"); +const timetableList = document.querySelector(".listHorario"); +const weekDays = ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"]; -$(document).ready(function () { +document.addEventListener("DOMContentLoaded", () => { userData = JSON.parse(localStorage.getItem("userData")); - FastClick.attach(document.body); setView(); setEvents(); }); function setEvents() { + document.querySelector(".btnSalir").addEventListener("click", close); - $(".btnSalir").on("click", function () { - cerrar(); - }); + inBtn.addEventListener("click", () => clockIn("in")); + inMiddleBtn.addEventListener("click", () => clockIn("middle")); + outMiddleBtn.addEventListener("click", () => clockIn("middle")); + outBtn.addEventListener("click", () => clockIn("out")); - $(".in").on("click", function () { - fichar('in'); - }); - - $(".inMiddle").on("click", function () { - fichar('middle'); - }); - - $(".outMiddle").on("click", function () { - fichar('middle'); - }); - - $(".out").on("click", function () { - fichar('out'); - }); - - setTimeout(function () { - cerrar(); - }, 5000); + // setTimeout(close, 5000); } -function setView() { - $(".footer").hide(); - $("#txtNombre").text(userData["name"] + " " + userData["surname"]); - getInfo(); - $("." + userData["button1"]).show(); - $("." + userData["button2"]).show(); -} - -function fichar(direction) { - const data = { - workerFk: userData['userFk'], - direction, - device: localStorage.getItem("device") - } - - $.post({ - urlPath: 'WorkerTimeControls/clockIn', - jsonData: data, - processData: false, - success: function (msg) { - if (msg.error){ - printErrores(msg); - setTimeout(function () { - cerrar(); - }, 2000); - }else { - $(".confirm").fadeIn(200); - $(".txtConfirm").append('Fichada registrada correctamente'); - setTimeout(function () { - cerrar(); - }, 1000); - } - } +async function clockIn(direction) { + let timeout = 1000; + const data = await call("WorkerTimeControls/clockIn", { + method: "POST", + body: { + workerFk: userData["userFk"], + direction, + device: localStorage.getItem("device"), + }, }); -} -function setView() { - $(".footer").hide(); - $(".in").hide(); - $(".inMiddle").hide(); - $(".outMiddle").hide(); - $(".out").hide(); - $("#txtNombre").text(userData["name"] + " " + userData["surname"]); - getInfo(); - if(userData["button1"] === null && userData["button2"] === null ) { - printError ("Contacta con tu responsable") + if (data.error) { + let msg = ""; + for (const val of data) if (val.error) msg += `${val.error}\n`; + printError(msg); } else { - $("." + userData["button1"]).show(); - $("." + userData["button2"]).show(); + document.querySelector(".confirm").classList.add("fade-in"); + txtConfirm.textContent = "Fichada registrada correctamente"; + timeout = 2000; } + + setTimeout(close, timeout); } -function getInfo() { - const queryString = $.param({ workerFk: userData['userFk'] }); - - $.get({ - urlPath: `WorkerTimeControls/getClockIn?${queryString}`, - processData: false, - success: function (data) { - $('.footer').show(); - printTimetable(data); - } - }); +function setView() { + footer.style.display = "none"; + inBtn.style.display = "none"; + inMiddleBtn.style.display = "none"; + outMiddleBtn.style.display = "none"; + outBtn.style.display = "none"; + + txtName.textContent = `${userData.name} ${userData.surname}`; + getInfo(); + + if (userData.button1 === null && userData.button2 === null) return printError("Contacta con tu responsable"); + + document.querySelector(`.${userData.button1}`).style.display = "inline-block"; + if (userData.button2) document.querySelector(`.${userData.button2}`).style.display = "inline-block"; +} + +async function getInfo() { + const data = await call("WorkerTimeControls/getClockIn", { params: { workerFk: userData["userFk"] } }); + footer.style.display = "block"; + printTimetable(data); } function printTimetable(timetable) { - const listWeekName = [ - 'Domingo', - 'Lunes', - 'Martes', - 'Miércoles', - 'Jueves', - 'Viernes', - 'Sábado' - ];; - let dated = new Date(); + const dated = new Date(); dated.setDate(dated.getDate() - 6); - for (let i = 0; i < 6; i++) { - $(".listHorario").append(''); + const fragment = document.createDocumentFragment(); + const totalEl = document.querySelector(".total"); + let totalHr = 0; + + for (let day = 0; day < weekDays.length - 1; day++) { + const label = createElement("label", { text: weekDays[dated.getDay()] }); + fragment.append(label); dated.setDate(dated.getDate() + 1); } - $(".listHorario").append(''); - $(".listHorario").append('
  • '); - - for (let i = 0; i < timetable.length; i++) { - - $(".listHorario").append( - '
  • ' + - '
    ' + - '
    ' + - '' + - '

    ' + ifIsEmptyText(timetable[i]["6daysAgo"]) + '

    ' + - '
    ' + - '
    ' + - '
    ' + - '
    ' + - '' + - '

    ' + ifIsEmptyText(timetable[i]["5daysAgo"]) + '

    '+ - '
    ' + - '
    ' + - '
    ' + - '
    ' + - '' + - '

    ' + ifIsEmptyText(timetable[i]["4daysAgo"]) + '

    '+ - '
    ' + - '
    ' + - '
    ' + - '
    ' + - '' + - '

    ' + ifIsEmptyText(timetable[i]["3daysAgo"]) + '

    '+ - '
    ' + - '
    ' + - '
    ' + - '
    ' + - '' + - '

    ' + ifIsEmptyText(timetable[i]["2daysAgo"]) + '

    '+ - '
    ' + - '
    ' + - '
    ' + - '
    ' + - '' + - '

    ' + ifIsEmptyText(timetable[i]["1daysAgo"]) + '

    '+ - '
    ' + - '
    ' + - '
    ' + - '
    ' + - '' + - '

    ' + ifIsEmptyText(timetable[i]["0daysAgo"]) + '

    '+ - '
    ' + - '
    ' + - '
  • ' - ); - } - printTotalHours(timetable); -} -function printTotalHours(timetable) { - if(timetable.length > 0) { + fragment.append(createElement("label", { text: "HOY", classes: ["hoy"] }), createElement("li", { classes: ["hrTop"] })); - $(".listHorario").append('
    '); - $(".listHorario").append('
  • ' + secondsToHm(ifIsEmptyText(timetable[0]["6daysAgoTotal"])) - + ' h
    ' + secondsToHm(ifIsEmptyText(timetable[0]["5daysAgoTotal"])) - + ' h
    ' + secondsToHm(ifIsEmptyText(timetable[0]["4daysAgoTotal"])) - + ' h
    ' + secondsToHm(ifIsEmptyText(timetable[0]["3daysAgoTotal"])) - + ' h
    ' + secondsToHm(ifIsEmptyText(timetable[0]["2daysAgoTotal"])) - + ' h
    ' + secondsToHm(ifIsEmptyText(timetable[0]["1daysAgoTotal"])) - + ' h
    ' + secondsToHm(ifIsEmptyText(timetable[0]["0daysAgoTotal"])) - + ' h
  • '); - - $(".total").text('Total: ' + - secondsToHm( - Number(timetable[0]["6daysAgoTotal"] == null) + - Number(timetable[0]["5daysAgoTotal"]) + - Number(timetable[0]["4daysAgoTotal"]) + - Number(timetable[0]["3daysAgoTotal"]) + - Number(timetable[0]["2daysAgoTotal"]) + - Number(timetable[0]["1daysAgoTotal"]) + - Number(timetable[0]["0daysAgoTotal"]) - ) + ' h'); - } else{ - $(".total").text('Total: 0h'); - } + const liContent = createElement("li", {}); + const liTotals = createElement("li", {}); + timetable.forEach((row, index) => { + for (let day = weekDays.length - 1; day >= 0; day--) { + const img = createElement("img", { attrs: { src: ifIsEmptyImage(row[`${day}daysAgoDirection`]) } }); + const p = createElement("p", { text: row[`${day}daysAgo`] }); -} + const innerDiv = createElement("div", { childs: [img, p] }); + const outerDiv = createElement("div", { classes: ["time", ifIsEmpty(row[`${day}daysAgo`])], childs: [innerDiv] }); + liContent.append(outerDiv); -function printErrores(errores) { - let error = ''; - for (let i = 0; i < errores.length; i++) { - if (errores[i].error) { - error += errores[i].error + "
    "; + if (index === 0) { + const div = createElement("div", { classes: ["time"], text: secondsToHm(timetable[0][`${day}daysAgoTotal`]) }); + liTotals.append(div); + totalHr += timetable[0][`${day}daysAgoTotal`] || 0; + } } - } - printError(error); + fragment.append(liContent); + if (index === timetable.length - 1) fragment.append(createElement("hr", {}), liTotals); + }); + + totalEl.innerText = `Total: ${totalHr ? secondsToHm(totalHr) : 0} h`; + timetableList.append(fragment); } -function ifIsEmpty(value) { - return value.trim() ? "show" : "hide"; -} +const ifIsEmpty = (value) => (value?.trim() ? "show" : "hide"); -function ifIsEmptyImage(value) { - return value.trim() ? `img/${value}.svg` :"img/in.svg"; -} +const ifIsEmptyImage = (value) => (value?.trim() ? `img/${value}.svg` : "img/in.svg"); -function ifIsEmptyText(value) { - return value.toString().trim() ? value : "00:00"; -} - -function cerrar(){ +function close() { localStorage.removeItem("userData"); - setTimeout(function () { - window.location='index.html'; - }, 200); + setTimeout(() => (window.location = "index.html"), 200); } function secondsToHm(seconds) { - seconds = Number(seconds); + seconds = +seconds; let hours = Math.floor(seconds / 3600); - let minutes = Math.floor(seconds % 3600 / 60); - return hours.toString().padStart(2, '0') + ':' + minutes.toString().padStart(2, '0'); -} \ No newline at end of file + let minutes = Math.floor((seconds % 3600) / 60); + return hours.toString().padStart(2, "0") + ":" + minutes.toString().padStart(2, "0"); +} + +function createElement(tag, { classes = [], text, attrs = {}, childs = [] }) { + const el = document.createElement(tag); + if (classes) el.classList.add(...classes); + if (text) el.textContent = text; + for (const [key, value] of Object.entries(attrs)) el.setAttribute(key, value); + if (childs) el.append(...childs); + + return el; +} diff --git a/js/index.js b/js/index.js index 3161aac..bb95b9c 100644 --- a/js/index.js +++ b/js/index.js @@ -41,11 +41,10 @@ if ("addEventListener" in document) { async function login() { try { - const res = await call("WorkerTimeControls/login", { + const data = await call("WorkerTimeControls/login", { method: "POST", body: { pin }, }); - const data = await res.json(); localStorage.setItem("userData", JSON.stringify(data)); window.location = "clockIn.html"; } catch (e) { @@ -55,11 +54,10 @@ async function login() { } async function signIn(user, password, device) { - const res = await call("vnUsers/sign-in", { + const data = await call("vnUsers/sign-in", { method: "POST", body: { user, password }, }); - const data = await res.json(); localStorage.setItem("token", data.token); localStorage.setItem("ttl", data.ttl); localStorage.setItem("user", user); diff --git a/js/main.js b/js/main.js index ef8954a..7a605f2 100644 --- a/js/main.js +++ b/js/main.js @@ -1,44 +1,37 @@ const renewPeriod = localStorage.getItem("renewPeriod"); let intervalId, isCheckingToken; const txtConfirm = document.querySelector(".txtConfirm"); -const confirm = document.querySelector(".confirm"); +const confirmBtn = document.querySelector(".confirm"); function confirmReset() { - confirm.classList.remove("confirmKO"); - confirm.style.display = "none"; + confirmBtn.classList.remove("confirmKO", "fade-in", "fade-out"); + confirmBtn.style.display = "none"; txtConfirm.textContent = ""; } -// WIP: fadeIn / fadeOut function printError(msg) { confirmReset(); const txtConfirm = document.querySelector(".txtConfirm"); txtConfirm.textContent = msg; - const confirm = document.querySelector(".confirm"); - confirm.classList.add("confirmKO"); - confirm.style.display = "block"; + confirmBtn.classList.add("confirmKO"); + confirmBtn.style.display = "block"; - $(".confirm").fadeIn(200); - setTimeout(() => { - $(".confirm").fadeOut(200); - setTimeout(confirmReset, 200); - }, 2300); + confirmBtn.classList.add("fade-in"); + setTimeout(() => (confirmBtn.classList.add("fade-out"), confirmReset()), 2300); } async function renewToken() { - const res = await call("AccessTokens/renewToken", {}); + const data = await call("AccessTokens/renewToken", {}); - const data = await res.json(); localStorage.setItem("ttl", data.ttl); localStorage.setItem("created", Date.now()); } async function getTokenConfig() { - const res = await call("AccessTokenConfigs/findOne", { + const data = await call("AccessTokenConfigs/findOne", { params: { filter: { fields: ["renewInterval", "renewPeriod"] } }, }); - const data = await res.json(); if (!data) return; localStorage.setItem("renewPeriod", data.renewPeriod); @@ -61,7 +54,6 @@ async function getTokenConfig() { }, data.renewInterval * 1000); } -/// WIP: MUST try thru it! async function call(url, { method = "GET", body = {}, params = {} }) { const controller = new AbortController(); const { signal } = controller; @@ -85,8 +77,11 @@ async function call(url, { method = "GET", body = {}, params = {} }) { try { const res = await fetch(`/api/${url}`, opts); + const data = await res.json(); + + if (res.ok) return data; clearTimeout(timeoutId); - return res; + throw data.error; } catch (e) { let mensaje = "Ha ocurrido un error, consulta con informática"; @@ -104,7 +99,7 @@ async function call(url, { method = "GET", body = {}, params = {} }) { mensaje = e.message; break; default: - switch (e.code) { + switch (e.statusCode) { case 0: mensaje = "Not connect: Verify Network"; break; @@ -115,10 +110,11 @@ async function call(url, { method = "GET", body = {}, params = {} }) { mensaje = "Error 555"; break; default: - if (e.status >= 400 && e.status < 500) mensaje = e.message; + if (e.statusCode >= 400 && e.statusCode < 500) mensaje = e.message; } } printError(mensaje); + throw e; } } diff --git a/package-lock.json b/package-lock.json index 61f5938..39c1c9c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,49 +1,70 @@ { "name": "worker-time-control", "version": "24.22.1", - "lockfileVersion": 1, + "lockfileVersion": 3, "requires": true, - "dependencies": { - "@types/http-proxy": { + "packages": { + "": { + "name": "worker-time-control", + "version": "24.22.1", + "license": "GPL-3.0", + "dependencies": { + "dotenv": "^16.3.1", + "fastclick": "^1.0.6", + "sweetalert2": "^11.6.13" + }, + "devDependencies": { + "express": "^4.19.2", + "http-proxy-middleware": "^2.0.6" + }, + "engines": { + "node": ">=14", + "npm": ">=8" + } + }, + "node_modules/@types/http-proxy": { "version": "1.17.14", "resolved": "https://registry.npmjs.org/@types/http-proxy/-/http-proxy-1.17.14.tgz", "integrity": "sha512-SSrD0c1OQzlFX7pGu1eXxSEjemej64aaNPRhhVYUGqXh0BtldAAx37MG8btcumvpgKyZp1F5Gn3JkktdxiFv6w==", "dev": true, - "requires": { + "dependencies": { "@types/node": "*" } }, - "@types/node": { + "node_modules/@types/node": { "version": "20.10.7", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.7.tgz", "integrity": "sha512-fRbIKb8C/Y2lXxB5eVMj4IU7xpdox0Lh8bUPEdtLysaylsml1hOOx1+STloRs/B9nf7C6kPRmmg/V7aQW7usNg==", "dev": true, - "requires": { + "dependencies": { "undici-types": "~5.26.4" } }, - "accepts": { + "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", "dev": true, - "requires": { + "dependencies": { "mime-types": "~2.1.34", "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" } }, - "array-flatten": { + "node_modules/array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", "dev": true }, - "body-parser": { + "node_modules/body-parser": { "version": "1.20.2", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", "dev": true, - "requires": { + "dependencies": { "bytes": "3.1.2", "content-type": "~1.0.5", "debug": "2.6.9", @@ -56,162 +77,219 @@ "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" } }, - "braces": { + "node_modules/braces": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, - "requires": { + "dependencies": { "fill-range": "^7.1.1" }, - "dependencies": { - "fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "dev": true, - "requires": { - "to-regex-range": "^5.0.1" - } - } + "engines": { + "node": ">=8" } }, - "bytes": { + "node_modules/braces/node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8" + } }, - "call-bind": { + "node_modules/call-bind": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", "dev": true, - "requires": { + "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", "function-bind": "^1.1.2", "get-intrinsic": "^1.2.4", "set-function-length": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "content-disposition": { + "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", "dev": true, - "requires": { + "dependencies": { "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" } }, - "content-type": { + "node_modules/content-type": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "cookie": { + "node_modules/cookie": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "cookie-signature": { + "node_modules/cookie-signature": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", "dev": true }, - "debug": { + "node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, - "requires": { + "dependencies": { "ms": "2.0.0" } }, - "define-data-property": { + "node_modules/define-data-property": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", "dev": true, - "requires": { + "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "depd": { + "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8" + } }, - "destroy": { + "node_modules/destroy": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } }, - "dotenv": { + "node_modules/dotenv": { "version": "16.3.1", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", - "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==" + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" + } }, - "ee-first": { + "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", "dev": true }, - "encodeurl": { + "node_modules/encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8" + } }, - "es-define-property": { + "node_modules/es-define-property": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", "dev": true, - "requires": { + "dependencies": { "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" } }, - "es-errors": { + "node_modules/es-errors": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.4" + } }, - "escape-html": { + "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", "dev": true }, - "etag": { + "node_modules/etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "eventemitter3": { + "node_modules/eventemitter3": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==", "dev": true }, - "express": { + "node_modules/express": { "version": "4.19.2", "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dev": true, - "requires": { + "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", "body-parser": "1.20.2", @@ -243,19 +321,22 @@ "type-is": "~1.6.18", "utils-merge": "1.0.1", "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" } }, - "fastclick": { + "node_modules/fastclick": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/fastclick/-/fastclick-1.0.6.tgz", "integrity": "sha512-cXyDBT4g0uWl/Xe75QspBDAgAWQ0lkPi/zgp6YFEUHj6WV6VIZl7R6TiDZhdOVU3W4ehp/8tG61Jev1jit+ztQ==" }, - "finalhandler": { + "node_modules/finalhandler": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", "dev": true, - "requires": { + "dependencies": { "debug": "2.6.9", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", @@ -263,329 +344,483 @@ "parseurl": "~1.3.3", "statuses": "2.0.1", "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" } }, - "follow-redirects": { + "node_modules/follow-redirects": { "version": "1.15.6", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", - "dev": true + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } }, - "forwarded": { + "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "fresh": { + "node_modules/fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "function-bind": { + "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "dev": true + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, - "get-intrinsic": { + "node_modules/get-intrinsic": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", "dev": true, - "requires": { + "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2", "has-proto": "^1.0.1", "has-symbols": "^1.0.3", "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "gopd": { + "node_modules/gopd": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", "dev": true, - "requires": { + "dependencies": { "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "has-property-descriptors": { + "node_modules/has-property-descriptors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", "dev": true, - "requires": { + "dependencies": { "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "has-proto": { + "node_modules/has-proto": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, - "has-symbols": { + "node_modules/has-symbols": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, - "hasown": { + "node_modules/hasown": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", "dev": true, - "requires": { + "dependencies": { "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" } }, - "http-errors": { + "node_modules/http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", "dev": true, - "requires": { + "dependencies": { "depd": "2.0.0", "inherits": "2.0.4", "setprototypeof": "1.2.0", "statuses": "2.0.1", "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" } }, - "http-proxy": { + "node_modules/http-proxy": { "version": "1.18.1", "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz", "integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==", "dev": true, - "requires": { + "dependencies": { "eventemitter3": "^4.0.0", "follow-redirects": "^1.0.0", "requires-port": "^1.0.0" + }, + "engines": { + "node": ">=8.0.0" } }, - "http-proxy-middleware": { + "node_modules/http-proxy-middleware": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz", "integrity": "sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw==", "dev": true, - "requires": { + "dependencies": { "@types/http-proxy": "^1.17.8", "http-proxy": "^1.18.1", "is-glob": "^4.0.1", "is-plain-obj": "^3.0.0", "micromatch": "^4.0.2" + }, + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "@types/express": "^4.17.13" + }, + "peerDependenciesMeta": { + "@types/express": { + "optional": true + } } }, - "iconv-lite": { + "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "dev": true, - "requires": { + "dependencies": { "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" } }, - "inherits": { + "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, - "ipaddr.js": { + "node_modules/ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.10" + } }, - "is-extglob": { + "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "is-glob": { + "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, - "requires": { + "dependencies": { "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "is-number": { + "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.12.0" + } }, - "is-plain-obj": { + "node_modules/is-plain-obj": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-3.0.0.tgz", "integrity": "sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA==", - "dev": true + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, - "jquery": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.7.1.tgz", - "integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==" - }, - "media-typer": { + "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "merge-descriptors": { + "node_modules/merge-descriptors": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==", "dev": true }, - "methods": { + "node_modules/methods": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "micromatch": { + "node_modules/micromatch": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", "dev": true, - "requires": { + "dependencies": { "braces": "^3.0.2", "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" } }, - "mime": { + "node_modules/mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "dev": true + "dev": true, + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } }, - "mime-db": { + "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "mime-types": { + "node_modules/mime-types": { "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "dev": true, - "requires": { + "dependencies": { "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" } }, - "ms": { + "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, - "negotiator": { + "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "object-inspect": { + "node_modules/object-inspect": { "version": "1.13.1", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", - "dev": true + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, - "on-finished": { + "node_modules/on-finished": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", "dev": true, - "requires": { + "dependencies": { "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" } }, - "parseurl": { + "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8" + } }, - "path-to-regexp": { + "node_modules/path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==", "dev": true }, - "picomatch": { + "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } }, - "proxy-addr": { + "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", "dev": true, - "requires": { + "dependencies": { "forwarded": "0.2.0", "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" } }, - "qs": { + "node_modules/qs": { "version": "6.11.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", "dev": true, - "requires": { + "dependencies": { "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "range-parser": { + "node_modules/range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "raw-body": { + "node_modules/raw-body": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", "dev": true, - "requires": { + "dependencies": { "bytes": "3.1.2", "http-errors": "2.0.0", "iconv-lite": "0.4.24", "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" } }, - "requires-port": { + "node_modules/requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", "dev": true }, - "safe-buffer": { + "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] }, - "safer-buffer": { + "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "send": { + "node_modules/send": { "version": "0.18.0", "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", "dev": true, - "requires": { + "dependencies": { "debug": "2.6.9", "depd": "2.0.0", "destroy": "1.2.0", @@ -600,118 +835,156 @@ "range-parser": "~1.2.1", "statuses": "2.0.1" }, - "dependencies": { - "ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true - } + "engines": { + "node": ">= 0.8.0" } }, - "serve-static": { + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/serve-static": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", "dev": true, - "requires": { + "dependencies": { "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "parseurl": "~1.3.3", "send": "0.18.0" + }, + "engines": { + "node": ">= 0.8.0" } }, - "set-function-length": { + "node_modules/set-function-length": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", "dev": true, - "requires": { + "dependencies": { "define-data-property": "^1.1.4", "es-errors": "^1.3.0", "function-bind": "^1.1.2", "get-intrinsic": "^1.2.4", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" } }, - "setprototypeof": { + "node_modules/setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", "dev": true }, - "side-channel": { + "node_modules/side-channel": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", "dev": true, - "requires": { + "dependencies": { "call-bind": "^1.0.7", "es-errors": "^1.3.0", "get-intrinsic": "^1.2.4", "object-inspect": "^1.13.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "statuses": { + "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8" + } }, - "sweetalert2": { - "version": "11.10.1", - "resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-11.10.1.tgz", - "integrity": "sha512-qu145oBuFfjYr5yZW9OSdG6YmRxDf8CnkgT/sXMfrXGe+asFy2imC2vlaLQ/L/naZ/JZna1MPAY56G4qYM0VUQ==" + "node_modules/sweetalert2": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-11.12.0.tgz", + "integrity": "sha512-Fe6sitTNReNdPF1q1w4uz1GAVv9acZff9Q7YILH5n6O/ti3MzwgfEA0aQ6tLjpy+O1NLXnZjUE//xrbluGXzJw==", + "funding": { + "type": "individual", + "url": "https://github.com/sponsors/limonte" + } }, - "to-regex-range": { + "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, - "requires": { + "dependencies": { "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" } }, - "toidentifier": { + "node_modules/toidentifier": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.6" + } }, - "type-is": { + "node_modules/type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", "dev": true, - "requires": { + "dependencies": { "media-typer": "0.3.0", "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" } }, - "undici-types": { + "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "dev": true }, - "unpipe": { + "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8" + } }, - "utils-merge": { + "node_modules/utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.4.0" + } }, - "vary": { + "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8" + } } } } diff --git a/package.json b/package.json index 7ceacf6..aa2f3d6 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,7 @@ "dependencies": { "dotenv": "^16.3.1", "fastclick": "^1.0.6", - "jquery": "^3.7.0", - "sweetalert2": "11.10.1" + "sweetalert2": "^11.6.13" }, "devDependencies": { "express": "^4.19.2", From 5e413cc352a6b8be2a7a3ce235a6208cb6d3dd95 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 18 Jun 2024 17:00:09 +0200 Subject: [PATCH 07/13] refactor: refs #6555 improve performance --- clockIn.html | 4 ++-- css/style.css | 12 +++++------- js/clockIn.js | 20 ++++++++++---------- js/main.js | 4 ++-- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/clockIn.html b/clockIn.html index c0d7cd9..0241112 100644 --- a/clockIn.html +++ b/clockIn.html @@ -35,12 +35,12 @@ and open the template in the editor. - +
    diff --git a/css/style.css b/css/style.css index 6220860..5f4694b 100644 --- a/css/style.css +++ b/css/style.css @@ -193,17 +193,15 @@ h3 { background-size: cover; background-repeat: no-repeat; } -.footer { - display: none; +footer { position: absolute; bottom: 0; width: 100%; height: 100px; text-align: center; -} -.footer { animation: fadeIn 0.2s ease-in-out; } + .in, .inMiddle { display: inline; position: static; @@ -342,7 +340,7 @@ header { opacity: 1; } .confirm { - display: none; + visibility: hidden; position: fixed; top: 0; left: 0; @@ -373,11 +371,12 @@ header { } .fade-in { - display: block; + visibility: visible; animation: fadeIn 0.2s ease-in-out forwards; } .fade-out { + visibility: hidden; animation: fadeOut 0.2s ease-in-out forwards; } @@ -407,7 +406,6 @@ header { } 100% { opacity: 0; - display: none; } } diff --git a/js/clockIn.js b/js/clockIn.js index d4f87d3..84bbd40 100644 --- a/js/clockIn.js +++ b/js/clockIn.js @@ -1,5 +1,5 @@ let userData = ""; -const footer = document.querySelector(".footer"); +const footer = document.querySelector("footer"); const txtName = document.querySelector("#txtNombre"); const inBtn = document.querySelector(".in"); const inMiddleBtn = document.querySelector(".inMiddle"); @@ -22,7 +22,7 @@ function setEvents() { outMiddleBtn.addEventListener("click", () => clockIn("middle")); outBtn.addEventListener("click", () => clockIn("out")); - // setTimeout(close, 5000); + setTimeout(close, 5000); } async function clockIn(direction) { @@ -50,7 +50,7 @@ async function clockIn(direction) { } function setView() { - footer.style.display = "none"; + footer.style.hidden = true; inBtn.style.display = "none"; inMiddleBtn.style.display = "none"; outMiddleBtn.style.display = "none"; @@ -67,7 +67,7 @@ function setView() { async function getInfo() { const data = await call("WorkerTimeControls/getClockIn", { params: { workerFk: userData["userFk"] } }); - footer.style.display = "block"; + footer.style.hidden = false; printTimetable(data); } @@ -75,17 +75,17 @@ function printTimetable(timetable) { const dated = new Date(); dated.setDate(dated.getDate() - 6); - const fragment = document.createDocumentFragment(); + const table = document.createDocumentFragment(); const totalEl = document.querySelector(".total"); let totalHr = 0; for (let day = 0; day < weekDays.length - 1; day++) { const label = createElement("label", { text: weekDays[dated.getDay()] }); - fragment.append(label); + table.append(label); dated.setDate(dated.getDate() + 1); } - fragment.append(createElement("label", { text: "HOY", classes: ["hoy"] }), createElement("li", { classes: ["hrTop"] })); + table.append(createElement("label", { text: "HOY", classes: ["hoy"] }), createElement("li", { classes: ["hrTop"] })); const liContent = createElement("li", {}); const liTotals = createElement("li", {}); @@ -104,12 +104,12 @@ function printTimetable(timetable) { totalHr += timetable[0][`${day}daysAgoTotal`] || 0; } } - fragment.append(liContent); - if (index === timetable.length - 1) fragment.append(createElement("hr", {}), liTotals); + table.append(liContent); + if (index === timetable.length - 1) table.append(createElement("hr", {}), liTotals); }); totalEl.innerText = `Total: ${totalHr ? secondsToHm(totalHr) : 0} h`; - timetableList.append(fragment); + timetableList.append(table); } const ifIsEmpty = (value) => (value?.trim() ? "show" : "hide"); diff --git a/js/main.js b/js/main.js index 7a605f2..692e381 100644 --- a/js/main.js +++ b/js/main.js @@ -5,7 +5,7 @@ const confirmBtn = document.querySelector(".confirm"); function confirmReset() { confirmBtn.classList.remove("confirmKO", "fade-in", "fade-out"); - confirmBtn.style.display = "none"; + confirmBtn.style.hidden = true; txtConfirm.textContent = ""; } @@ -14,7 +14,7 @@ function printError(msg) { const txtConfirm = document.querySelector(".txtConfirm"); txtConfirm.textContent = msg; confirmBtn.classList.add("confirmKO"); - confirmBtn.style.display = "block"; + confirmBtn.style.hidden = false; confirmBtn.classList.add("fade-in"); setTimeout(() => (confirmBtn.classList.add("fade-out"), confirmReset()), 2300); From e2524362ed89e6ce76976643a41f084da0a27187 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 18 Jun 2024 17:01:30 +0200 Subject: [PATCH 08/13] refactor: refs #6555 drop excess spaces --- css/style.css | 5 ----- 1 file changed, 5 deletions(-) diff --git a/css/style.css b/css/style.css index 5f4694b..4c1b1ce 100644 --- a/css/style.css +++ b/css/style.css @@ -369,12 +369,10 @@ header { font-size: 2.5em; margin-bottom: 20px; } - .fade-in { visibility: visible; animation: fadeIn 0.2s ease-in-out forwards; } - .fade-out { visibility: hidden; animation: fadeOut 0.2s ease-in-out forwards; @@ -390,7 +388,6 @@ header { opacity: 1; } } - @keyframes fadeIn { 0% { opacity: 0; @@ -399,7 +396,6 @@ header { opacity: 1; } } - @keyframes fadeOut { 0% { opacity: 1; @@ -413,7 +409,6 @@ header { font-family: 'Poppins'; src: url('../font/Poppins.ttf') format('truetype'); } - @font-face { font-family: 'Poppins'; src: url('../font/Poppins-Bold.ttf') format('truetype'); From f540a51dd14eb1f6e2712d8ca980050bbb5bcb8f Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 18 Jun 2024 17:37:27 +0200 Subject: [PATCH 09/13] refactor: refs #6555 adjust footer height --- css/style.css | 2 +- js/clockIn.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/css/style.css b/css/style.css index 4c1b1ce..ff22a3f 100644 --- a/css/style.css +++ b/css/style.css @@ -197,7 +197,7 @@ footer { position: absolute; bottom: 0; width: 100%; - height: 100px; + height: 115px; text-align: center; animation: fadeIn 0.2s ease-in-out; } diff --git a/js/clockIn.js b/js/clockIn.js index 84bbd40..fd6ea1d 100644 --- a/js/clockIn.js +++ b/js/clockIn.js @@ -22,7 +22,7 @@ function setEvents() { outMiddleBtn.addEventListener("click", () => clockIn("middle")); outBtn.addEventListener("click", () => clockIn("out")); - setTimeout(close, 5000); + // setTimeout(close, 5000); } async function clockIn(direction) { From 30d9acf58b1d078f17389f076db354449749c47d Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 19 Jun 2024 09:52:07 +0200 Subject: [PATCH 10/13] fix: refs #6555 replace renewToken url --- js/main.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/main.js b/js/main.js index 692e381..8c255ce 100644 --- a/js/main.js +++ b/js/main.js @@ -17,11 +17,14 @@ function printError(msg) { confirmBtn.style.hidden = false; confirmBtn.classList.add("fade-in"); - setTimeout(() => (confirmBtn.classList.add("fade-out"), confirmReset()), 2300); + setTimeout(() => { + confirmBtn.classList.add("fade-out"); + setTimeout(confirmReset, 200); + }, 2300); } async function renewToken() { - const data = await call("AccessTokens/renewToken", {}); + const data = await call("vnUsers/renewToken", { method: "POST" }); localStorage.setItem("ttl", data.ttl); localStorage.setItem("created", Date.now()); From 1f9bf0378047cada0cfcde5767067c0d8c7161db Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 19 Jun 2024 11:40:30 +0200 Subject: [PATCH 11/13] fix: refs #6555 uncomment redirect --- js/clockIn.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/clockIn.js b/js/clockIn.js index fd6ea1d..84bbd40 100644 --- a/js/clockIn.js +++ b/js/clockIn.js @@ -22,7 +22,7 @@ function setEvents() { outMiddleBtn.addEventListener("click", () => clockIn("middle")); outBtn.addEventListener("click", () => clockIn("out")); - // setTimeout(close, 5000); + setTimeout(close, 5000); } async function clockIn(direction) { From 496182fa5451c9b8fce8ab8e7af04e644a146861 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 19 Jun 2024 12:43:02 +0200 Subject: [PATCH 12/13] fix: refs #6555 add ifIsEmptyText fn --- js/clockIn.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/clockIn.js b/js/clockIn.js index 84bbd40..9e0ac05 100644 --- a/js/clockIn.js +++ b/js/clockIn.js @@ -92,7 +92,7 @@ function printTimetable(timetable) { timetable.forEach((row, index) => { for (let day = weekDays.length - 1; day >= 0; day--) { const img = createElement("img", { attrs: { src: ifIsEmptyImage(row[`${day}daysAgoDirection`]) } }); - const p = createElement("p", { text: row[`${day}daysAgo`] }); + const p = createElement("p", { text: ifIsEmptyText(row[`${day}daysAgo`]) }); const innerDiv = createElement("div", { childs: [img, p] }); const outerDiv = createElement("div", { classes: ["time", ifIsEmpty(row[`${day}daysAgo`])], childs: [innerDiv] }); @@ -116,6 +116,8 @@ const ifIsEmpty = (value) => (value?.trim() ? "show" : "hide"); const ifIsEmptyImage = (value) => (value?.trim() ? `img/${value}.svg` : "img/in.svg"); +const ifIsEmptyText = (value) => (value?.toString()?.trim() ? value : "00:00"); + function close() { localStorage.removeItem("userData"); setTimeout(() => (window.location = "index.html"), 200); From 5e1a5f313a8da6c341e7c9352bdc3a24c3c6a011 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 19 Jun 2024 13:18:43 +0200 Subject: [PATCH 13/13] refactor: refs #6555 check if is Empty --- js/clockIn.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/js/clockIn.js b/js/clockIn.js index 9e0ac05..5552db3 100644 --- a/js/clockIn.js +++ b/js/clockIn.js @@ -91,11 +91,11 @@ function printTimetable(timetable) { const liTotals = createElement("li", {}); timetable.forEach((row, index) => { for (let day = weekDays.length - 1; day >= 0; day--) { - const img = createElement("img", { attrs: { src: ifIsEmptyImage(row[`${day}daysAgoDirection`]) } }); - const p = createElement("p", { text: ifIsEmptyText(row[`${day}daysAgo`]) }); + const img = createElement("img", { attrs: { src: isEmpty(row[`${day}daysAgoDirection`], "image") } }); + const p = createElement("p", { text: isEmpty(row[`${day}daysAgo`], "text") }); const innerDiv = createElement("div", { childs: [img, p] }); - const outerDiv = createElement("div", { classes: ["time", ifIsEmpty(row[`${day}daysAgo`])], childs: [innerDiv] }); + const outerDiv = createElement("div", { classes: ["time", isEmpty(row[`${day}daysAgo`])], childs: [innerDiv] }); liContent.append(outerDiv); if (index === 0) { @@ -112,11 +112,12 @@ function printTimetable(timetable) { timetableList.append(table); } -const ifIsEmpty = (value) => (value?.trim() ? "show" : "hide"); - -const ifIsEmptyImage = (value) => (value?.trim() ? `img/${value}.svg` : "img/in.svg"); - -const ifIsEmptyText = (value) => (value?.toString()?.trim() ? value : "00:00"); +const isEmpty = (value, type) => { + const val = value?.toString()?.trim(); + if (!type) return val ? "show" : "hide"; + if (type === "image") return val ? `img/${val}.svg` : "img/in.svg"; + if (type === "text") return val ? val : "00:00"; +}; function close() { localStorage.removeItem("userData");