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 .
```
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>
<script src="config.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>
</html>

View File

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

View File

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

View File

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

View File

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