#6274 proxy workerTimeControl #14
|
@ -88,6 +88,7 @@ and open the template in the editor.
|
|||
<h4 class="txtConfirm"></h4>
|
||||
</div>
|
||||
</div>
|
||||
<script src="js/sweetalert2.js"></script>
|
||||
<script src="config.js" type="text/javascript"></script>
|
||||
<script src="js/main.js" type="text/javascript"></script>
|
||||
<script src="js/index.js" type="text/javascript"></script>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
var userData = "";
|
||||
|
||||
$(document).ready(function () {
|
||||
userData = $.parseJSON(localStorage.getItem("userData"));
|
||||
userData = JSON.parse(localStorage.getItem("userData"));
|
||||
FastClick.attach(document.body);
|
||||
setView();
|
||||
setEvents();
|
||||
|
@ -43,9 +43,14 @@ function setView() {
|
|||
}
|
||||
|
||||
function fichar(direction) {
|
||||
const data = {
|
||||
workerFk: userData['userFk'],
|
||||
direction
|
||||
}
|
||||
|
||||
$.post({
|
||||
urlPath: 'clockIn',
|
||||
jsonData: [userData['userFk'], direction],
|
||||
urlPath: 'WorkerTimeControls/clockIn',
|
||||
jsonData: data,
|
||||
processData: false,
|
||||
success: function (msg) {
|
||||
if (msg[0].error){
|
||||
|
@ -81,9 +86,10 @@ function setView() {
|
|||
}
|
||||
|
||||
function getInfo() {
|
||||
$.post({
|
||||
urlPath: 'getClockIn',
|
||||
jsonData: [userData['userFk']],
|
||||
const queryString = $.param({ workerFk: userData['userFk'] });
|
||||
|
||||
$.get({
|
||||
urlPath: `WorkerTimeControls/getClockIn?${queryString}`,
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
$('.footer').show();
|
||||
|
|
39
js/index.js
39
js/index.js
|
@ -1,5 +1,7 @@
|
|||
var pin = "";
|
||||
var datoUsuario = "";
|
||||
jorgep marked this conversation as resolved
Outdated
|
||||
var user = "";
|
||||
jorgep marked this conversation as resolved
Outdated
jgallego
commented
porque no crear let como en salix? porque no crear let como en salix?
jorgep
commented
Era por seguir en la línea del proyecto. Pero lo cambio todo a let y const. Era por seguir en la línea del proyecto. Pero lo cambio todo a let y const.
|
||||
var pass = "";
|
||||
|
||||
$(document).ready(function () {
|
||||
FastClick.attach(document.body);
|
||||
|
@ -9,9 +11,25 @@ $(document).ready(function () {
|
|||
function setEvents() {
|
||||
const heartEl = document.querySelector('body > h1 > span');
|
||||
heartEl.addEventListener('click', function() {
|
||||
const key = prompt('Introduce la clave');
|
||||
if (key === null) return
|
||||
localStorage.setItem('vnKey', key);
|
||||
Swal.fire({
|
||||
title: 'Iniciar sesión',
|
||||
html:
|
||||
'<input id="user" class="swal2-input" placeholder="Usuario">' +
|
||||
'<input id="pass" class="swal2-input" type="password" placeholder="Contraseña">',
|
||||
confirmButtonText: 'Login',
|
||||
showCloseButton: true,
|
||||
showCancelButton: false,
|
||||
}).then(async (result) => {
|
||||
if(result.isConfirmed) {
|
||||
const user =$('#user').val();
|
||||
const pass = $('#pass').val();
|
||||
signIn(user,pass);
|
||||
}
|
||||
});
|
||||
|
||||
jorgep marked this conversation as resolved
Outdated
jgallego
commented
creas y usas el token? creas y usas el token?
|
||||
let token;
|
||||
if (token === null) return
|
||||
localStorage.setItem('token', token);
|
||||
});
|
||||
|
||||
$(".btnnum").on("click", function () {
|
||||
|
@ -36,8 +54,8 @@ function setEvents() {
|
|||
|
||||
function login() {
|
||||
$.post({
|
||||
urlPath: 'login',
|
||||
jsonData: [pin],
|
||||
urlPath: 'WorkerTimeControls/login',
|
||||
jsonData: {pin},
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
localStorage.setItem("userData", JSON.stringify(data));
|
||||
|
@ -48,5 +66,16 @@ function login() {
|
|||
pin = "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function signIn(user, password) {
|
||||
$.post({
|
||||
urlPath: 'vnUsers/sign-in',
|
||||
jsonData: {user, password},
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
localStorage.setItem("token", data.token);
|
||||
localStorage.setItem("ttl", data.ttl);
|
||||
},
|
||||
})
|
||||
}
|
10
js/main.js
10
js/main.js
|
@ -16,16 +16,12 @@ function printError(msg){
|
|||
|
||||
$.ajaxPrefilter(function(xhr) {
|
||||
var orgErrorHandler = xhr.error;
|
||||
|
||||
var key = localStorage.getItem('vnKey');
|
||||
if (key) {
|
||||
xhr.jsonData.push(key)
|
||||
}
|
||||
var token = localStorage.getItem('token')
|
||||
|
||||
Object.assign(xhr, {
|
||||
url: `api/WorkerTimeControls/${xhr.urlPath}`,
|
||||
url: `api/${xhr.urlPath}`,
|
||||
headers: {
|
||||
//Authorization : token
|
||||
Authorization : token
|
||||
},
|
||||
timeout: 1000,
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -10,8 +10,7 @@
|
|||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"fastclick": "^1.0.6",
|
||||
"jquery": "^3.7.0",
|
||||
"sweetalert2": "^11.6.13"
|
||||
"jquery": "^3.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"express": "^4.18.2",
|
||||
|
@ -865,15 +864,6 @@
|
|||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/sweetalert2": {
|
||||
"version": "11.10.1",
|
||||
"resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-11.10.1.tgz",
|
||||
"integrity": "sha512-qu145oBuFfjYr5yZW9OSdG6YmRxDf8CnkgT/sXMfrXGe+asFy2imC2vlaLQ/L/naZ/JZna1MPAY56G4qYM0VUQ==",
|
||||
"funding": {
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/limonte"
|
||||
}
|
||||
},
|
||||
"node_modules/to-regex-range": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"fastclick": "^1.0.6",
|
||||
"jquery": "^3.7.0",
|
||||
"sweetalert2": "^11.6.13"
|
||||
"jquery": "^3.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"express": "^4.18.2",
|
||||
|
|
Loading…
Reference in New Issue
revisa esta porque tiene un uso extraño, no parece que se asigne