Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
DoliSCAN
client-cordova
Commits
ac03b916
Commit
ac03b916
authored
Jan 16, 2020
by
Eric Seigne
Browse files
ajout de la version de l'api serveur
parent
c6cb12d8
Changes
5
Hide whitespace changes
Inline
Side-by-side
www/index.html
View file @
ac03b916
...
...
@@ -211,7 +211,7 @@
function
loginWithAPIToken
()
{
if
(
localGetData
(
"
api_token
"
)
==
null
)
{
myDebug
(
"
loginWithAPIToken : aucun token, return
"
);
//
myDebug("loginWithAPIToken : aucun token, return");
// myDebug("carouselLogin 1");
carouselLogin
();
return
;
...
...
@@ -234,8 +234,32 @@
globalNetworkResponse
=
Date
.
now
();
hideWait
();
// myDebug("loginWithAPIToken : OK (" + textStatus + "/" + request.status + ")");
updateLocalUserFromServer
(
result
);
window
.
location
.
assign
(
"
app.html
"
);
if
(
typeof
result
!==
'
undefined
'
)
{
if
(
typeof
result
.
data
!==
'
undefined
'
)
{
if
(
result
.
data
.
api_version
==
globalCompatibleWithAPIVersion
)
{
updateLocalUserFromServer
(
result
);
//pour une raison obscure l'appel direct deconne parfois alors que via
window
.
location
.
assign
(
"
app.html
"
);
}
else
{
//Si on a un message specifique du serveur (genre api trop vieille) on l'affiche
if
(
typeof
result
.
data
.
api_version_message
!==
'
undefined
'
)
{
// myDebug("result.data.api_token undefined : " + result);
$
(
"
#messagePopupMessage
"
).
replaceWith
(
result
.
data
.
api_version_message
);
$
(
"
#messagePopup
"
).
show
();
// myDebug("carouselLogin 2");
}
// setTimeout(function(){ $("#erreurLogin").hide(); }, 5000);
}
carouselLogin
();
}
else
{
carouselLogin
();
}
}
else
{
carouselLogin
();
}
},
//logout
error
:
function
(
result
)
{
...
...
@@ -311,10 +335,19 @@
if (typeof result.data !== 'undefined') {
if (typeof result.data.api_token !== 'undefined') {
hideWait();
updateLocalUserFromServer(result);
//pour une raison obscure l'appel direct deconne parfois alors que via
window.location.assign(
"
app
.
html
"
);
if (result.data.api_version == globalCompatibleWithAPIVersion) {
updateLocalUserFromServer(result);
//pour une raison obscure l'appel direct deconne parfois alors que via
window.location.assign(
"
app
.
html
"
);
}
else {
// myDebug(
"
result
.
data
.
api_token
undefined
:
"
+ result);
$(
"
#
messagePopupMessage
"
).replaceWith(result.data.api_version_message);
$(
"
#
messagePopup
"
).show();
// myDebug(
"
carouselLogin
2
"
);
carouselLogin();
// setTimeout(function(){ $(
"
#
erreurLogin
"
).hide(); }, 5000);
}
}
else {
hideWait();
...
...
www/js/index.js
View file @
ac03b916
...
...
@@ -52,7 +52,7 @@ Date.prototype.toDateInputValue = (function () {
//initialise le formulaire avec des valeurs par défaut ...
function
initialiseForm
()
{
myDebug
(
'
initialiseForm ...
'
+
device
.
platform
);
//
myDebug('initialiseForm ... ' + device.platform);
if
(
document
.
getElementById
(
'
feedPaiements
'
))
{
// myDebug('feedPaiements ...');
$
(
'
#feedPaiements
'
).
load
(
'
parts/paiement.html
'
,
function
()
{
...
...
@@ -64,9 +64,9 @@ function initialiseForm() {
if
(
document
.
getElementById
(
'
ladate
'
))
{
let
today
=
new
Date
();
$
(
'
#ladate
'
).
val
(
today
.
toDateInputValue
());
myDebug
(
'
date :
'
);
myDebug
(
today
.
toDateInputValue
());
myDebug
(
"
Résultat de l'affectation :
"
+
document
.
getElementById
(
'
ladate
'
).
value
);
//
myDebug('date : ');
//
myDebug(today.toDateInputValue());
//
myDebug("Résultat de l'affectation : " + document.getElementById('ladate').value);
}
if
(
document
.
getElementById
(
'
feedVehiculesPerso
'
))
{
...
...
www/js/ndf-head.js
View file @
ac03b916
...
...
@@ -10,6 +10,7 @@ var globalCurrentPage = ""; // Page courante pour gérer le retour p
var
globalAppVersion
=
""
;
// La version de DoliSCAN
var
globalDB
=
null
;
// Le connecteur vers la base de données SQLite
var
globalTenMinuts
=
60
*
10
*
1000
;
// 10 minutes pour l'implementation du keepalive (avant de basculer en full API je pense)
var
globalCompatibleWithAPIVersion
=
1
;
// On incrémentera la version de l'API compatible quand on modifie des choses importantes sur le serveur
//liste des donnees que le serveur peut eventuellement échanger avec nous (factorisation de code)
var
globalSrvKeys
=
[
'
email
'
,
'
api_token
'
,
'
name
'
,
'
adresse
'
,
'
cp
'
,
'
ville
'
,
'
send_copy_to
'
,
'
compta_email
'
,
'
compta_ik
'
,
'
compta_peage
'
,
'
compta_hotel
'
,
'
compta_train
'
,
'
compta_carburant
'
,
'
compta_taxi
'
,
'
compta_restauration
'
,
'
compta_divers
'
,
'
compta_compteperso
'
,
'
compta_tvadeductible
'
];
...
...
@@ -177,7 +178,7 @@ function feedDoliscanInfos() {
}
function
cleanHistorique
()
{
myDebug
(
'
on vide l historique
'
);
//
myDebug('on vide l historique');
listeContent
=
new
Array
(
''
);
localStoreData
(
"
history
"
,
JSON
.
stringify
(
listeContent
));
}
...
...
@@ -186,9 +187,9 @@ function cleanHistorique() {
function
closeSession
()
{
localStoreData
(
'
api_token
'
,
''
);
globalDB
.
close
(
function
()
{
myDebug
(
'
database is closed ok
'
);
//
myDebug('database is closed ok');
},
function
(
error
)
{
myDebug
(
'
ERROR closing database
'
);
//
myDebug('ERROR closing database');
});
window
.
location
.
replace
(
'
index.html
'
);
}
...
...
@@ -196,7 +197,7 @@ function closeSession() {
//Ajoute une valeur dans la base de données - remplace celle qui existerait deja
function
localStoreData
(
key
,
value
)
{
localStorage
.
setItem
(
key
,
value
);
myDebug
(
'
localStoreData :
'
+
key
+
'
et
'
+
value
);
//
myDebug('localStoreData : ' + key + ' et ' + value);
//Pas la peine de stocker ça en SQL
if
(
key
==
'
history
'
)
{
return
;
...
...
@@ -219,10 +220,10 @@ function localStoreData(key, value) {
//retourne null si vide ou n'existe pas
function
localGetData
(
key
)
{
if
(
typeof
(
localStorage
.
getItem
(
key
))
!=
'
undefined
'
&&
(
localStorage
.
getItem
(
key
)
!=
null
)
&&
(
localStorage
.
getItem
(
key
)
!=
""
)
&&
(
localStorage
.
getItem
(
key
)
!=
'
undefined
'
))
{
myDebug
(
'
localGetData :
'
+
key
+
'
et
'
+
localStorage
.
getItem
(
key
));
//
myDebug('localGetData : ' + key + ' et ' + localStorage.getItem(key));
return
localStorage
.
getItem
(
key
);
}
myDebug
(
"
localGetData: on retourne null pour
"
+
key
)
//
myDebug("localGetData: on retourne null pour " + key)
return
null
;
// globalDB.transaction(function (tx) {
// req = 'SELECT value FROM config WHERE key = ?';
...
...
@@ -244,7 +245,7 @@ function localGetData(key) {
//Factorisation de code: on analyse un result serveur pour sauvegarder en local les donnees
function
updateLocalUserFromServer
(
result
)
{
let
ret
=
false
;
myDebug
(
JSON
.
stringify
(
result
));
//
myDebug(JSON.stringify(result));
if
(
typeof
(
result
!=
'
undefined
'
)
&&
(
result
!=
null
)
&&
(
result
!=
""
))
{
for
(
let
key
of
globalSrvKeys
)
{
// console.log("On cherche " + key);
...
...
@@ -340,7 +341,7 @@ ons.ready(function () {
});
if
(
globalDB
==
null
)
{
myDebug
(
"
On essaye d'ouvrir la base de données ...
"
);
//
myDebug("On essaye d'ouvrir la base de données ...");
globalDB
=
window
.
sqlitePlugin
.
openDatabase
({
name
:
'
doliscan.db
'
,
location
:
'
default
'
,
...
...
@@ -362,10 +363,10 @@ ons.ready(function () {
let
k
=
rs
.
rows
.
item
(
i
).
key
;
let
v
=
rs
.
rows
.
item
(
i
).
value
;
localStorage
.
setItem
(
k
,
v
);
myDebug
(
'
(c) SQL create localStorage
'
+
k
+
'
->
'
+
v
);
//
myDebug(' (c) SQL create localStorage ' + k + ' -> ' + v);
}
},
function
(
error
)
{
myDebug
(
'
SQL Transaction ERROR:
'
+
error
.
message
);
//
myDebug('SQL Transaction ERROR: ' + error.message);
},
function
()
{
// myDebug('SQL Create database OK');
});
...
...
www/js/ndf.js
View file @
ac03b916
...
...
@@ -419,7 +419,7 @@ function historique(page) {
else
{
listeContent
=
new
Array
(
page
);
}
myDebug
(
'
history list apres la magie :
'
+
listeContent
);
//
myDebug('history list apres la magie : ' + listeContent);
localStoreData
(
"
history
"
,
JSON
.
stringify
(
listeContent
));
}
}
...
...
@@ -495,7 +495,7 @@ ons.ready(function () {
}
else
{
listeContent
.
push
(
prevPage
);
myDebug
(
'
history apres le traitement du bouton prev :
'
+
listeContent
);
//
myDebug('history apres le traitement du bouton prev : ' + listeContent);
localStoreData
(
"
history
"
,
JSON
.
stringify
(
listeContent
));
$
(
'
#container
'
).
load
(
prevPage
);
}
...
...
www/moncompte.html
View file @
ac03b916
...
...
@@ -77,7 +77,7 @@
ons
.
ready
(
function
()
{
for
(
let
key
of
configKeys
)
{
// console.log("On cherche " + key);
myDebug
(
"
on cherche
"
+
key
);
//
myDebug("on cherche " + key);
if
(
localGetData
(
key
)
!=
null
)
{
if
(
$
(
'
#
'
+
key
)[
0
].
type
==
"
text
"
||
$
(
'
#
'
+
key
)[
0
].
type
==
"
number
"
||
$
(
'
#
'
+
key
)[
0
].
type
==
"
email
"
)
{
$
(
'
#
'
+
key
).
val
(
localGetData
(
key
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment