refs #4974 Minor changes

This commit is contained in:
Guillermo Bonet 2023-01-03 14:35:30 +01:00
parent 87814333ef
commit 192ac251cd
1 changed files with 27 additions and 29 deletions

View File

@ -1,9 +1,7 @@
var odbcPath = 'HKCU\\Software\\ODBC\\ODBC.INI\\';
var Conf = { var Conf = {
appName: 'Verdnatura', appName: 'Verdnatura',
dsName: 'verdnatura', dsName: 'verdnatura',
dsPath: odbcPath + 'verdnatura', odbcPath: 'HKCU\\Software\\ODBC\\ODBC.INI\\',
regPath: 'HKCU\\SOFTWARE\\Verdnatura\\vn-access', regPath: 'HKCU\\SOFTWARE\\Verdnatura\\vn-access',
defaultModule: 'vn', defaultModule: 'vn',
defaultLocale: 'es', defaultLocale: 'es',
@ -96,12 +94,12 @@ var App = {
if (!this.module) if (!this.module)
this.module = Conf.defaultModule; this.module = Conf.defaultModule;
this.appDir = this.getEnv('ProgramFiles') +'\\'+ Conf.appName; this.appDir = this.getEnv('ProgramFiles') + '\\' + Conf.appName;
this.moduleDir = this.shell.SpecialFolders('AppData') +'\\'+ Conf.appName; this.moduleDir = this.shell.SpecialFolders('AppData') + '\\' + Conf.appName;
this.compressFile = this.getEnv('TEMP') +'\\'+ this.module +'.7z'; this.compressFile = this.getEnv('TEMP') + '\\' + this.module + '.7z';
this.mdbFile = this.moduleDir +'\\'+ this.module +'.mdb'; this.mdbFile = this.moduleDir + '\\' + this.module + '.mdb';
this.lockFile = this.moduleDir +'\\'+ this.module +'.ldb'; this.lockFile = this.moduleDir + '\\' + this.module + '.ldb';
this.certFile = this.appDir +'\\cacert.pem'; this.certFile = this.appDir + '\\cacert.pem';
// Creates the necessary registry entries // Creates the necessary registry entries
var myVersion = this.regRead(Conf.regPath, 'version'); var myVersion = this.regRead(Conf.regPath, 'version');
@ -119,39 +117,39 @@ var App = {
// Creates the MySQL ODBC connection // Creates the MySQL ODBC connection
this.createODBC( this.createODBC(
odbcPath, Conf.odbcPath,
Conf.dsName, Conf.dsName,
Conf.odbcDriver Conf.odbcDriver
); );
// Datasources creation // Datasources creation
this.createDatasources(); 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)
}
// Upload the string value to version installed // Upload the string value to version installed
this.regWrite(Conf.regPath, 'version', Conf.version); this.regWrite(Conf.regPath, 'version', Conf.version);
} }
// 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')) if (!this.regRead(Conf.regPath, 'currentDatasource'))
this.regWrite(Conf.regPath, 'currentDatasource', Conf.defaultDatasource); this.regWrite(Conf.regPath, 'currentDatasource', Conf.defaultDatasource);
if (!this.regRead(Conf.regPath, 'notSignOut')) if (!this.regRead(Conf.regPath, 'notSignOut'))
this.regWrite(Conf.regPath, 'notSignOut', 0); this.regWrite(Conf.regPath, 'notSignOut', 0);
var notSignOut = this.regRead(Conf.regPath, 'notSignOut'); var notSignOut = this.regRead(Conf.regPath, 'notSignOut');
var password = this.regRead(Conf.odbcPath + Conf.dsName, 'PWD');
this.$('user').value = this.regRead(Conf.dsPath, 'UID'); this.$('user').value = this.regRead(Conf.odbcPath + Conf.dsName, 'UID');
this.$('password').value = this.regRead(Conf.dsPath, 'PWD'); this.$('password').value = password
if (notSignOut && password) { if (notSignOut && password) {
this.$('password').value = password; this.$('password').value = password;
@ -282,7 +280,7 @@ var App = {
if (!isOnLoad) { if (!isOnLoad) {
this.updateDatasource(myDatasource); this.updateDatasource(myDatasource);
this.updateODBC( this.updateODBC(
odbcPath, Conf.odbcPath,
Conf.dsName, Conf.dsName,
myDatasource myDatasource
); );
@ -352,8 +350,8 @@ var App = {
if (!password) if (!password)
throw new Error(_('Enter a password')); throw new Error(_('Enter a password'));
this.regWrite(Conf.dsPath, 'UID', user); this.regWrite(Conf.odbcPath + Conf.dsName, 'UID', user);
this.regWrite(Conf.dsPath, 'PWD', password); this.regWrite(Conf.odbcPath + Conf.dsName, 'PWD', password);
// Check the cretentials and return the last version number // Check the cretentials and return the last version number
var version = this.fetchVersion(); var version = this.fetchVersion();
@ -392,7 +390,7 @@ var App = {
var serverURL = Conf.datasources[datasource].SERVER; var serverURL = Conf.datasources[datasource].SERVER;
var sslMode = Conf.datasources[datasource].SSLMODE; var sslMode = Conf.datasources[datasource].SSLMODE;
// ToDo: Can't login to dev-db // FIXME: Can't login to dev-db
if (datasource == 'dev') { if (datasource == 'dev') {
serverURL = Conf.datasources.production.SERVER serverURL = Conf.datasources.production.SERVER
sslMode = Conf.datasources.production.SERVER sslMode = Conf.datasources.production.SERVER
@ -612,7 +610,7 @@ var App = {
var clearPassword = err.name == 'BadLogin'; var clearPassword = err.name == 'BadLogin';
if (!this.$('notSignOut').checked || clearPassword) if (!this.$('notSignOut').checked || clearPassword)
this.regWrite(Conf.dsPath, 'PWD', ''); this.regWrite(Conf.odbcPath + Conf.dsName, 'PWD', '');
this.disableUi(false); this.disableUi(false);
this.showMessage(err.message, 'error'); this.showMessage(err.message, 'error');