Initial version
gitea/worker-time-control/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Andrés 2021-10-20 15:13:30 +02:00
parent 5c05bdc835
commit 43748ba6c6
6 changed files with 27 additions and 39 deletions

View File

@ -4,10 +4,3 @@ Launch application in development environment.
``` ```
$ php -S 0.0.0.0:9090 -t . $ php -S 0.0.0.0:9090 -t .
``` ```
Enable CORS on server side
```
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: *");
if($_SERVER['REQUEST_METHOD'] == "OPTIONS") die();
```

View File

@ -67,6 +67,6 @@ and open the template in the editor.
</div> </div>
<script src="config.js" type="text/javascript"></script> <script src="config.js" type="text/javascript"></script>
<script src="js/main.js" type="text/javascript"></script> <script src="js/main.js" type="text/javascript"></script>
<script src="js/clock.js" type="text/javascript"></script> <script src="js/clockIn.js" type="text/javascript"></script>
</body> </body>
</html> </html>

View File

@ -284,25 +284,18 @@ header{
opacity: 1; opacity: 1;
} }
.confirm{ .confirm {
display: none; display: none;
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
color: #fff;
background: #8DD202; background: #8DD202;
color: #fff;
} }
.confirmKO{ .confirm.confirmKO {
display: inline;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(237,73,71); background: rgba(237,73,71);
color: #fff;
} }
.contConfirm{ .contConfirm{

View File

@ -143,17 +143,8 @@ var weekDays = [
'Sábado' 'Sábado'
]; ];
function printError(msg){
$(".txtConfirm").empty();
$(".txtConfirm").append(msg);
$(".txtConfirm").append("<br>");
$(".loading").fadeOut(200);
$(".confirm").addClass('confirmKO');
}
function printErrores(errores) { function printErrores(errores) {
var error =''; var error ='';
$(".txtConfirm").empty();
for (var i = 0; i < errores.length; i++) { for (var i = 0; i < errores.length; i++) {
if (errores[i].error) { if (errores[i].error) {
error += errores[i].error + "<br>"; error += errores[i].error + "<br>";

View File

@ -29,16 +29,19 @@ function setEvents() {
} }
function login() { function login() {
$(".loading").fadeIn(200);
$.post({ $.post({
urlPath: 'login', urlPath: 'login',
jsonData: [pin], jsonData: [pin],
processData: false, processData: false,
success: function (data) { success: function (data) {
localStorage.setItem("userData", JSON.stringify(data)); localStorage.setItem("userData", JSON.stringify(data));
$("#txtPin").text("USUARIO O DNI");
pin = "";
window.location = "clockIn.html"; window.location = "clockIn.html";
},
error: function() {
$(".loading").fadeOut(200); $(".loading").fadeOut(200);
$("#txtPin").text("USUARIO");
pin = "";
} }
}); });

View File

@ -1,20 +1,25 @@
var config = config[process.env.NODE_ENV]; var config = config[process.env.NODE_ENV];
var urlBase = config.urlBase; var urlBase = config.urlBase;
function confirmReset() {
$(".confirm").removeClass('confirmKO');
$(".txtConfirm").empty();
}
function printError(msg){ function printError(msg){
$(".txtConfirm").empty(); confirmReset();
$(".txtConfirm").append(msg); $(".txtConfirm").append(msg);
$(".confirm").addClass('confirmKO'); $(".confirm").addClass('confirmKO');
pin = ""; $(".confirm").fadeIn(200);
$("#txtPin").text("USUARIO");
setTimeout(function() { setTimeout(function() {
$(".confirm").removeClass('confirmKO'); $(".confirm").fadeOut(200);
setTimeout(confirmReset, 200);
}, 1500); }, 1500);
} }
$.ajaxPrefilter(function(xhr) { $.ajaxPrefilter(function(xhr) {
$(".loading").fadeIn(200); var orgErrorHandler = xhr.error;
Object.assign(xhr, { Object.assign(xhr, {
url: `${urlBase}/workerTimeControl/${xhr.urlPath}`, url: `${urlBase}/workerTimeControl/${xhr.urlPath}`,
headers: { headers: {
@ -26,8 +31,14 @@ $.ajaxPrefilter(function(xhr) {
dataType: 'json', dataType: 'json',
processData: false, processData: false,
data: JSON.stringify(xhr.jsonData), data: JSON.stringify(xhr.jsonData),
error: function (xhr, textStatus, err) { error: function(xhr, textStatus, err) {
var mensaje; if (orgErrorHandler) {
try {
orgErrorHandler(xhr, textStatus, err);
} catch (e) {
err = e;
}
}
switch (textStatus){ switch (textStatus){
case 'parsererror': case 'parsererror':
@ -58,9 +69,6 @@ $.ajaxPrefilter(function(xhr) {
mensaje = 'Ha ocurrido un error, consulta con informática'; mensaje = 'Ha ocurrido un error, consulta con informática';
} }
printError(mensaje); printError(mensaje);
},
complete: function() {
$(".loading").fadeOut(200);
} }
}); });
}); });