refs #4974 First commit v4

This commit is contained in:
Guillermo Bonet 2022-12-22 08:37:37 +01:00
parent 8128c74ec2
commit 79d578cf29
24 changed files with 282 additions and 143 deletions

View File

@ -1,4 +1,4 @@
Copyright (C) 2020 - Verdnatura Levante S.L.
Copyright (C) 2023 - Verdnatura Levante S.L.
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

BIN
fonts/Poppins-Black.ttf Normal file

Binary file not shown.

Binary file not shown.

BIN
fonts/Poppins-Bold.ttf Normal file

Binary file not shown.

Binary file not shown.

BIN
fonts/Poppins-ExtraBold.ttf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
fonts/Poppins-Italic.ttf Normal file

Binary file not shown.

BIN
fonts/Poppins-Light.ttf Normal file

Binary file not shown.

Binary file not shown.

BIN
fonts/Poppins-Medium.ttf Normal file

Binary file not shown.

Binary file not shown.

BIN
fonts/Poppins-Regular.ttf Normal file

Binary file not shown.

BIN
fonts/Poppins-SemiBold.ttf Normal file

Binary file not shown.

Binary file not shown.

BIN
fonts/Poppins-Thin.ttf Normal file

Binary file not shown.

Binary file not shown.

View File

@ -56,6 +56,8 @@ Source: "ocx\*"; \
DestDir: {sys}; Flags: onlyifdoesntexist regserver 32bit
Source: "fonts\Roboto*"; \
DestDir: "{fonts}"; FontInstall: "Roboto"; Flags: onlyifdoesntexist uninsneveruninstall
Source: "fonts\Poppins*"; \
DestDir: "{fonts}"; FontInstall: "Poppins"; Flags: onlyifdoesntexist uninsneveruninstall
Source: "fonts\Lucida Sans - *"; \
DestDir: "{fonts}"; FontInstall: "Lucida Sans"; Flags: onlyifdoesntexist uninsneveruninstall
Source: "fonts\Code128B.ttf"; \

BIN
src/datasource.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 893 B

View File

@ -1,45 +1,74 @@
var Conf = {
appName: 'Verdnatura'
,dsName: 'verdnatura'
,dsPath: 'HKCU\\Software\\ODBC\\ODBC.INI\\verdnatura'
,regPath: 'HKCU\\Software\\Verdnatura\\vn-access'
,remoteUrl: 'https://cdn.verdnatura.es/vn-access'
,dbHost: 'db.verdnatura.es'
,defaultModule: 'tpv'
,defaultLocale: 'es'
,defaultBranch: 'master'
,dbName: 'vn2008'
,maxCorruptSize: 600
,odbcDriver: 'MySQL ODBC 8.0 Unicode Driver'
,driverPath: '\\MySQL\\Connector ODBC 8.0\\myodbc8w.dll'
,version: 3
appName: 'Verdnatura',
dsName: 'verdnatura',
dsPath: 'HKCU\\SOFTWARE\\ODBC\\ODBC.INI\\verdnatura',
regPath: 'HKCU\\SOFTWARE\\Verdnatura\\vn-access',
remoteUrl: 'https://cdn.verdnatura.es/vn-access',
dbHost: 'db.verdnatura.es',
defaultModule: 'vn',
defaultLocale: 'es',
defaultBranch: 'master',
dbName: 'vn2008',
maxCorruptSize: 600,
odbcDriver: 'MySQL ODBC 8.0 Unicode Driver',
driverPath: '\\MySQL\\Connector ODBC 8.0\\myodbc8w.dll',
defaultDatasource: 'production',
version: 4,
cdnURL: 'https://cdn.verdnatura.es/vn-access',
cdnURL: 'https://salix.verdnatura.es',
datasources: {
production: {
DESCRIPTION: 'production',
SERVER: 'db.verdnatura.es',
PORT: '3306',
SSLMODE: 'VERIFY_IDENTITY'
},
test: {
DESCRIPTION: 'test',
SERVER: 'test-db.verdnatura.es',
PORT: '3307',
SSLMODE: 'DISABLED'
},
dev: {
DESCRIPTION: 'dev',
SERVER: 'dev-db.verdnatura.es',
PORT: '3307',
SSLMODE: 'DISABLED'
},
local: {
DESCRIPTION: 'local',
SERVER: 'localhost',
PORT: '3306',
SSLMODE: 'DISABLED'
}
}
};
var Locale = {
es: {
"Enter a user name":
"Introduce un nombre de usuario"
,"Enter a password":
"Introduce una contraseña"
,"Server can't be reached":
"No se ha podido conectar con el servidor"
,"Updating":
"Actualizando"
,"Bad login":
"Usuario o contraseña incorrectos"
,"Application it's already open":
"La aplicación ya está abierta"
,"Loading":
"Cargando"
,"Error while updating":
"Error al actualizar"
,"Microsoft Access 2003 is not installed":
"Microsoft Access 2003 no está instalado en el sistema"
,"MDB file not found":
"No se encontró el fichero MDB"
,"Cache files have been deleted":
"Se han borrado todos los ficheros de la caché"
"Introduce un nombre de usuario",
"Enter a password":
"Introduce una contraseña",
"Server can't be reached":
"No se ha podido conectar con el servidor",
"Updating":
"Actualizando",
"Bad login":
"Usuario o contraseña incorrectos, recuerda que se hace distinción entre mayúsculas y minúsculas",
"Application it's already open":
"La aplicación ya está abierta",
"Loading":
"Cargando",
"Error while updating":
"Error al actualizar",
"Microsoft Access 2003 is not installed":
"Microsoft Access 2003 no está instalado en el sistema",
"MDB file not found":
"No se encontró el fichero MDB",
"Cache files have been deleted":
"Se han borrado todos los ficheros almacenados en la caché"
}
};
@ -48,9 +77,10 @@ var App = {
fso: new ActiveXObject('scripting.filesystemobject'),
init: function() {
var width = 420;
var height = 525;
// Specify the size of window
var width = 420;
var height = 560;
window.resizeTo(width, height);
window.moveTo((screen.width - width) / 2, (screen.height - height) / 2);
},
@ -78,9 +108,9 @@ var App = {
// Creates the necessary registry entries
var configured = this.regRead(Conf.regPath, 'configured');
var myVersion = this.regRead(Conf.regPath, 'version');
if (!configured || configured < Conf.version) {
if (!myVersion || myVersion != Conf.version) {
var path;
// Creates the Access configuration entries
@ -118,26 +148,51 @@ var App = {
params
);
// Marks the application as configured
this.regWrite(Conf.regPath, 'configured', Conf.version);
// Upload the string value to version installed
this.regWrite(Conf.regPath, 'version', Conf.version);
}
// Loads the form data
//Datasources creations
this.createDatasources();
// Check the strings values and the respective keys
var stringValues = [
'remoteURL',
'remoteUser',
'remotePass'
]
for (var i in stringValues) {
if (!this.regRead(Conf.regPath, stringValues[i]))
this.regWrite(Conf.regPath, stringValues[i], null)
}
if (!this.regRead(Conf.regPath, 'currentDatasource'))
this.regWrite(Conf.regPath, 'currentDatasource', Conf.defaultDatasource);
if (!this.regRead(Conf.regPath, 'notSignOut'))
this.regWrite(Conf.regPath, 'notSignOut', 0);
// Loads the form data
var user = this.regRead(Conf.dsPath, 'UID');
var password = this.regRead(Conf.dsPath, 'PWD');
var remember = this.regRead(Conf.regPath, 'remember');
var notSignOut = this.regRead(Conf.regPath, 'notSignOut');
this.$('branch').value = this.getBranch();
this.onChangeBranchChange();
this.onChangeBranch();
this.$('datasource').value = this.getDatasource();
this.onChangeDatasource();
if (user)
this.$('user').value = user;
if (remember && password) {
if (notSignOut && password) {
this.$('password').value = password;
this.$('remember').checked = true;
this.$('notSignOut').checked = true;
this.onEnterClick();
} else
this.resetForm(true);
@ -167,7 +222,7 @@ var App = {
this.$('user').disabled = disabled;
this.$('password').disabled = disabled;
this.$('remember').disabled = disabled;
this.$('notSignOut').disabled = disabled;
this.$('enter').disabled = disabled;
var display = disabled ? 'block' : 'none';
@ -179,14 +234,27 @@ var App = {
setTimeout(function() { App.cleanCache(); });
},
onShowOptionsClick: function() {
onShowBranchOptionsClick: function() {
var style = this.$("branchSelector").style;
style.display = style.display == 'none' || !style.display
? 'inline'
: 'none';
},
onChangeBranchChange: function() {
onShowDatasourceOptionsClick: function() {
var style = this.$("datasourceSelector").style;
style.display = style.display == 'none' || !style.display
? 'inline'
: 'none';
if (!this.$("datasourceLogo").className)
this.$("datasourceLogo").className = "on";
else
this.$("datasourceLogo").className = "";
},
onChangeBranch: function() {
if (this.$("branch").value == "master"||"test"||"dev") {
this.$("branchButton").className = this.$("branch").value;
this.$("branch").className = this.$("branch").value;
@ -197,6 +265,18 @@ var App = {
this.$('user').focus();
},
onChangeDatasource: function() {
if (this.$("datasource").value == "production"||"test"||"dev") {
this.$("datasourceButton").className = this.$("datasource").value;
this.$("datasource").className = this.$("datasource").value;
} else {
this.$("datasourceButton").className = null;
this.$("datasource").className = null;
}
this.updateDatasource(this.$("datasource").value);
this.$('user').focus();
},
cleanCache: function() {
if (this.fso.folderExists(this.moduleDir)) {
var folder = this.fso.getFolder(this.moduleDir);
@ -245,13 +325,16 @@ var App = {
var user = this.$('user').value;
var password = this.$('password').value;
var branch = this.$('branch').value;
var datasource = this.$('datasource').value;
if (!user || user === '')
throw new Error(_('Enter a user name'));
if (!password || password === '')
throw new Error(_('Enter a password'));
if (!branch || branch === '')
throw new Error(_('Select a branch'));
throw new Error(_('Select a branch'));
if (!datasource || datasource === '')
throw new Error(_('Select a datasource'));
this.regWrite(Conf.dsPath, 'UID', user);
this.regWrite(Conf.dsPath, 'PWD', password);
@ -262,7 +345,7 @@ var App = {
var remoteFile = version
? '.archive/'+ this.module +'/'+ version +'.7z'
: this.module +'.7z?'+ new Date().getTime();
remoteFile = Conf.remoteUrl +'/'+ remoteFile;
remoteFile = Conf.cdnURL +'/'+ remoteFile;
var request = new ActiveXObject("MSXML2.XMLHTTP");
request.open('GET', remoteFile, true);
request.onreadystatechange = function() {
@ -334,9 +417,6 @@ var App = {
rs.close();
mysqlConn.close();
if (this.$('previous-version').checked && version > 1)
version -= 1;
// Checks if it's already open
if (this.fso.fileExists(this.lockFile))
try {
@ -368,7 +448,6 @@ var App = {
? version
: null;
},
mdbGetValue: function(query, field, parseFn) {
var value;
@ -393,14 +472,12 @@ var App = {
return value;
},
getOdbcString: function(options) {
var optionsArray = [];
for (var option in options)
optionsArray.push(option +'='+ options[option]);
return optionsArray.join(';');
},
onRequestReady: function(request) {
if (request.readyState !== 4)
return;
@ -438,10 +515,9 @@ var App = {
this.catchError(e);
}
},
openMdb: function() {
var remember = !!this.$('remember').checked;
this.regWrite(Conf.regPath, 'remember', remember);
var notSignOut = !!this.$('notSignOut').checked;
this.regWrite(Conf.regPath, 'notSignOut', notSignOut);
var programFiles = this.getEnv('ProgramFiles');
var accessBin = programFiles +'\\Microsoft Office\\OFFICE11\\MSACCESS.EXE';
@ -452,18 +528,16 @@ var App = {
this.shell.exec('"'+ accessBin +'" "'+ this.mdbFile +'"');
window.close();
},
catchError: function(err) {
var clearPassword = err.name == 'BadLogin';
if (!this.$('remember').checked || clearPassword)
if (!this.$('notSignOut').checked || clearPassword)
this.regWrite(Conf.dsPath, 'PWD', '');
this.disableUi(false);
this.showMessage(err.message, 'error');
this.resetForm(clearPassword);
},
/**
* Displays a non-intrusive message.
*
@ -475,7 +549,6 @@ var App = {
App.showMessageAsync(message, className);
});
},
showMessageAsync: function(message, className) {
if (this.messageTimeout)
clearTimeout(this.messageTimeout);
@ -488,11 +561,9 @@ var App = {
App.hideMessage();
}, 10000);
},
onBodyClick: function() {
this.hideMessage();
},
/**
* Hides the last displayed non-intrusive message.
*/
@ -503,7 +574,6 @@ var App = {
this.messageTimeout = null;
}
},
/**
* Obtains a DOM element by it's identifier.
*
@ -512,18 +582,15 @@ var App = {
$: function(id) {
return document.getElementById(id);
},
run: function(command, wait) {
if (!wait)
wait = false;
this.shell.run(command, 0, wait);
},
getEnv: function(varName) {
return this.shell.expandEnvironmentStrings('%'+ varName +'%');
},
regRead: function(path, key) {
try {
var value = this.shell.regRead(path +'\\'+ key);
@ -533,7 +600,6 @@ var App = {
return value;
},
regWrite: function(path, key, value, type) {
if (!type)
switch (typeof (value))
@ -547,16 +613,16 @@ var App = {
break;
default:
type = 'REG_SZ';
if (!value)
value = '';
}
this.shell.regWrite(path +'\\'+ key, value.toString(), type);
this.shell.regWrite(path + '\\' + key, value.toString(), type);
},
regWrites: function(path, values, type) {
for(var key in values)
this.regWrite(path, key, values[key], type);
},
regDelete: function(path) {
try {
this.shell.regDelete(path);
@ -573,7 +639,20 @@ var App = {
'branch', String
);
return branch || Conf.defaultBranch;
}
},
getDatasource: function() {
var datasource = this.regRead(
'HKCU\\SOFTWARE\\Verdnatura\\vn-access',
'currentDatasource'
);
return datasource || Conf.defaultDatasource;
},
updateDatasource: function(datasource) {
this.regWrite(Conf.regPath, 'currentDatasource', datasource);
},
createDatasources: function() {
},
};
App.init();

View File

@ -1,13 +1,13 @@
body {
font-family: 'Poppins', 'Verdana', 'Sans';
font-size: 18px;
padding: .8em;
overflow: hidden;
color: #222;
font-family: Roboto;
}
a {
text-decoration: none;
color: #44f;
color: black;
}
/* Login form */
@ -15,8 +15,8 @@ a {
#logo {
display: block;
margin: 0 auto;
margin-bottom: 2.5em;
width: 80%;
margin-bottom: 4em;
width: 62%;
}
button,
input {
@ -28,21 +28,12 @@ select {
font-size: 1em;
background-color: #8d8d8d;
}
select.master {
background-color: #c20000;
}
select.test {
background-color: #31a527;
}
select.dev {
background-color: #a59827;
}
option {
color: white;
}
#fields {
max-width: 11em;
margin: 0 auto;
max-width: 13em;
margin-left: 3.32em;
}
#inputs > div {
margin-top: 1em;
@ -74,17 +65,10 @@ input[type='text']:focus,
input[type='password']:focus {
border-bottom: 1px solid black;
}
input[type='text']::selection,
input[type='password']::selection {
background-color: #97d700;
}
#rememberMe {
#notSignOut {
margin-top: 1em;
font-size: .9em;
}
#oldVersion {
margin-top: .5em;
font-size: .9em;
margin-bottom: 2.5em;
}
#submit {
margin-top: 1em;
@ -104,15 +88,16 @@ input[type='password']::selection {
}
button {
color: #FFF;
background-color: #f7931e;
padding: .7em;
padding-right: 2.5em;
padding-left: 2.5em;
background-color: black;
padding: 1em;
padding-right: 4.5em;
padding-left: 4.5em;
border: none;
border-radius: 25px;
font-size: .9em;
}
button:hover {
background-color: #eb8b1d;
background-color: #3d3f42;
cursor: pointer;
}
@ -124,14 +109,12 @@ button:hover {
#branchLogo {
cursor: pointer;
padding-top: .4em;
padding-bottom: .2em;
padding-left: .4em;
padding-right: .4em;
}
#branch {
border: none;
cursor: pointer;
margin-left: .4em;
float: right;
}
#branchSelector {
@ -145,7 +128,7 @@ button:hover {
float: left;
border-radius: 25px;
color: black;
box-shadow: 0px 0px 5px 0px #000000;
box-shadow: 0px 0px 5px 0px black;
background-color: #8d8d8d;
}
#branchButton:hover {
@ -160,36 +143,105 @@ button:hover {
#branchButton.dev {
background-color: #a59827;
}
select.master {
background-color: #c20000;
}
select.test {
background-color: #31a527;
}
select.dev {
background-color: #a59827;
}
/* Datasource */
#datasourceOptions {
margin-top: 1em;
margin-left: 17.3em;
}
#datasourceLogo {
cursor: pointer;
padding-top: .4em;
padding-left: .4em;
padding-right: .4em;
}
#datasourceLogo.on {
cursor: pointer;
padding-top: .4em;
padding-left: .4em;
padding-right: .4em;
margin-left: 7em;
}
#datasource {
border: none;
cursor: pointer;
margin-right: 1.5em;
float: left;
}
#datasourceSelector {
float: right;
display: none;
padding-right: .8em;
margin-right: 0.5em;
margin-top: -1.91em;
}
#datasourceButton {
float: right;
border-radius: 25px;
color: black;
box-shadow: 0px 0px 5px 0px #000000;
background-color: #8d8d8d;
}
#datasourceButton:hover {
box-shadow: none;
}
#datasourceButton.production {
background-color: #c20000;
}
#datasourceButton.test {
background-color: #31a527;
}
#datasourceButton.dev {
background-color: #a59827;
}
select.production {
background-color: #c20000;
}
select.test {
background-color: #31a527;
}
select.dev {
background-color: #a59827;
}
/* Message */
#message {
z-index: 2;
position: absolute;
top: 2em;
left: 49.2%;
width: 16em;
top: 1.8em;
left: 11.8em;
width: 20em;
padding: .5em;
margin-left: -8.25em;
margin-top: 2em;
border: 1px solid #644;
background-color: #EBB;
color: #644;
text-align: center;
font-size: .9em;
font-size: .8em;
display: none;
border-radius: 25px;
box-shadow: 0px 0px 5px 0px #000000
border-radius: 5px;
box-shadow: 0 0 0.4em rgba(1,1,1,0.6);
}
#message.error {
border-color: black;
background-color: #a52727;
color: white;
background-color: #ffcdd2;
color: #bf0000;
}
#message.notice {
border-color: black;
background-color: #2773a5;
color: white;
background-color: #d0cdff;
color: #0d00bf;
;
}
@ -202,7 +254,7 @@ button:hover {
height: 100%;
background-color: black;
opacity: 0.7;
filter: alpha(opacity=70);
filter: alpha(opacity=50);
top: 0;
left: 0;
display: none;
@ -214,7 +266,7 @@ button:hover {
width: 10em;
height: 5em;
margin-top: -4em;
margin-left: -5.9em;
margin-left: -6.1em;
top: 50%;
left: 50%;
background-color: white;
@ -233,4 +285,4 @@ button:hover {
}
#loading-message {
font-size: .9em;
}
}

View File

@ -41,38 +41,27 @@
<input id="password" type="password"/>
</div>
</div>
<div id="rememberMe">
<input id="remember" type="checkbox"/>
<label for="remember">Recu&eacute;rdame</label>
</div>
<div id="oldVersion">
<input id="previous-version" type="checkbox"/>
<label for="previous-version">Usar versi&oacute;n anterior</label>
<div id="notSignOut">
<input id="notSignOutInput" type="checkbox"/>
<label for="notSignOutInput">No cerrar sesión</label>
</div>
</div>
<div id="submit">
<button
id="enter"
onclick="App.onEnterClick()">
Entrar
</button>
<button id="enter" onclick="App.onEnterClick()"> Iniciar sesión</button>
</div>
<div id="clean">
<a
href="#"
onclick="App.onCleanCacheClick()">
Limpiar cach&eacute;
</a>
<a href="#" onclick="App.onCleanCacheClick()"> Limpiar caché </a>
</div>
<div id="branchOptions">
<div id="branchButton">
<img
id="branchLogo"
src="branch.png"
onclick="App.onShowOptionsClick()"
onclick="App.onShowBranchOptionsClick(),
App.onShowDatasourceOptionsClick()"
alt="Change branch"/>
<div id="branchSelector">
<select id="branch" onchange="App.onChangeBranchChange()">
<select id="branch" onchange="App.onChangeBranch()">
<option value="master">master</option>
<option value="test">test</option>
<option value="dev">dev</option>
@ -80,8 +69,25 @@
</div>
</div>
</div>
<div id="background">
<div id="datasourceOptions">
<div id="datasourceButton">
<img
id="datasourceLogo"
src="datasource.png"
onclick="App.onShowDatasourceOptionsClick(),
App.onShowBranchOptionsClick()"
alt="Change datasource"/>
<div id="datasourceSelector">
<select id="datasource" onchange="App.onChangeDatasource()">
<option value="production">production</option>
<option value="test">test</option>
<option value="dev">dev</option>
<option value="localhost">localhost</option>
</select>
</div>
</div>
</div>
<div id="background"></div>
<div id="spinner">
<img
alt="Cargando..."