Commit 35159061 authored by Eric Seigne's avatar Eric Seigne
Browse files

update ldf ok

parent cae1caa5
......@@ -15,6 +15,8 @@
<script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="js/jquery.validate.js"></script>
<script type="text/javascript" src="js/ndf-head.js"></script>
<script type="text/javascript" src="js/jquery.serialize-object.min.js"></script>
</head>
<body>
......
......@@ -245,7 +245,7 @@ ons-carousel[fullscreen] {
height: 20px;
padding: 0 16px 0 6px;
box-sizing: border-box;
z-index: 30000;
z-index: 40000;
display: -webkit-box;
display: -webkit-flex;
display: flex;
......
......@@ -305,7 +305,7 @@ function distanceAutomatique(depart, arrivee) {
}
*/
$.ajaxSetup({
timeout: 30000,
timeout: 40000,
});
/*
beforeSend: function (xhr) {
......@@ -419,7 +419,7 @@ function updateServerUserFromLocal() {
// myDebug("updateServerUserFromLocal");
$.ajaxSetup({
timeout: 30000,
timeout: 40000,
headers: {
'X-CSRF-TOKEN': localGetData("api_token")
}
......
......@@ -293,7 +293,7 @@ function sendForm() {
showWait();
$.ajaxSetup({
timeout: 30000,
timeout: 40000,
headers: {
'X-CSRF-TOKEN': localGetData("api_token")
}
......@@ -306,10 +306,10 @@ function sendForm() {
}
var formdata = new FormData($("#leform")[0]);
myDebug("formdata tout neuf");
myDebug(formdata);
// myDebug("formdata tout neuf");
// myDebug(formdata);
formdata.append('_token', localGetData("api_token"));
myDebug(formdata);
// myDebug(formdata);
//Si on est en UPDATE, pas besoin de l'image
if (document.getElementById('updateID').value == 0) {
......@@ -336,80 +336,71 @@ function sendForm() {
}
}
else {
// myDebug('pas d image ...');
myDebug('pas d image ...');
// myDebug(formdata);
endSendForm(formdata, "");
}
}
else {
//en mode update
myDebug("On n'essaye pas de joindre le fichier on est en UPDATE")
myDebug(formdata);
// myDebug(formdata);
endSendFormForUpdate(formdata);
}
}
//On ne fait qu'un update de la facturette ...
function endSendFormForUpdate(formdata) {
hideWait();
myDebug("Appel pour UPDATE avec formdata qui vaut : ")
myDebug(formdata);
var formdata = new FormData($("#leform")[0]);
myDebug("formdata tout neuf");
myDebug(formdata);
myDebug("ID a updater : " + $('#updateID').value);
formdata.append('_token', localGetData("api_token"));
myDebug(formdata);
let ajaxURL = localGetData("api_server") + "/api/ldfs/" + document.getElementById('updateID').value;
let ajaxTYPE = "PUT";
var object = {};
formdata.forEach((value, key) => {object[key] = value});
var json = JSON.stringify(object);
// var ajaxRequest = $.ajax({
// url: ajaxURL,
// timeout: 30000,
// type: ajaxTYPE,
// data: json,
// processData: false,
// cache: false,
// contentType: false,
// tryCount: 0,
// retryLimit: 3,
// beforeSend: function (xhr) {
// xhr.setRequestHeader('Authorization', 'Bearer ' + localGetData("api_token"));
// },
// success: function (result, textStatus, request) {
// globalNetworkResponse = Date.now();
// hideWait();
// myDebug("Request PUT finished (success signal) : " + textStatus + (result + '').length);
// myDebug("Request PUT status (success signal) : " + request.status);
// //Cote serveur on a un code 201 "special" dans ce cas
// if (request.status == "201") {
// gotoPage('messageDone.html', false);
// }
// else {
// gotoPage('messageError.html', false);
// }
// },
// error: function (request, textStatus, errorThrown) {
// hideWait();
// myDebug("Request finished (error signal) : " + textStatus);
// },
// complete: function (request, textStatus, errorThrown) {
// myDebug("Request PUT finished (complete signal) : " + textStatus);
// myDebug('Taille des donees envoyees sur le serveur : ' + request.getResponseHeader('Content-Length') + ' octets');
// if (request.status == "201") {
// gotoPage('messageDone.html', false);
// }
// else {
// gotoPage('messageError.html', false);
// }
// }
// });
//Transformer les données du formulaire en JSON
formJSON = $('form#leform').serializeJSON();
myDebug("JSON : " + formJSON);
//remettre à zéro la structure de données provoquant l'accès au mode "mise à jour"
dataLDF = "";
var ajaxRequest = $.ajax({
url: localGetData("api_server") + "/api/ldfs/" + document.getElementById('updateID').value,
timeout: 40000,
type: "PUT",
data: formJSON,
processData: true,
cache: false,
contentType: 'application/json',
tryCount: 0,
retryLimit: 3,
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', 'Bearer ' + localGetData("api_token"));
},
success: function (result, textStatus, request) {
globalNetworkResponse = Date.now();
hideWait();
myDebug("Request PUT finished (success signal) : " + textStatus + '(' + result.length + ')');
myDebug("Request PUT status (success signal) : " + request.status);
//Cote serveur on a un code 201 "special" dans ce cas
if (request.status == "200") {
gotoPage('messageDone.html', false);
}
else {
gotoPage('messageError.html', false);
}
},
error: function (request, textStatus, errorThrown) {
hideWait();
myDebug("Request finished (error signal) : " + textStatus);
},
complete: function (request, textStatus, errorThrown) {
myDebug("Request PUT finished (complete signal) : " + textStatus);
myDebug('Taille des donees envoyees sur le serveur : ' + request.getResponseHeader('Content-Length') + ' octets');
if (request.status == "201") {
gotoPage('messageDone.html', false);
}
else {
gotoPage('messageError.html', false);
}
}
});
}
......@@ -468,7 +459,7 @@ function endSendForm(formdata, filename) {
var ajaxRequest = $.ajax({
url: ajaxURL,
timeout: 30000,
timeout: 40000,
type: ajaxTYPE,
data: formdata,
processData: false,
......@@ -497,17 +488,17 @@ function endSendForm(formdata, filename) {
globalLastInsertId = "";
}
}
gotoPage('messageDone.html', false);
}
else {
gotoPage('messageError.html', false);
ons.notification.alert("Reconnexion en cours, patientez.", { title: "Réseau lent" });
}
},
error: function (request, textStatus, errorThrown) {
hideWait();
myDebug("Request finished (error signal) : " + textStatus);
if (textStatus == 'timeout') {
ons.notification.alert("Reconnexion en cours, patientez.", { title: "Réseau lent" });
myDebug('timeout, try again ...');
this.tryCount++;
if (this.tryCount <= this.retryLimit) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment