From 192ac251cd808527d7ec2fa96dfdabedb312007d Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 3 Jan 2023 14:35:30 +0100 Subject: [PATCH] refs #4974 Minor changes --- src/main.js | 56 ++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/src/main.js b/src/main.js index d3397d3..3acdce0 100755 --- a/src/main.js +++ b/src/main.js @@ -1,9 +1,7 @@ - -var odbcPath = 'HKCU\\Software\\ODBC\\ODBC.INI\\'; var Conf = { appName: 'Verdnatura', dsName: 'verdnatura', - dsPath: odbcPath + 'verdnatura', + odbcPath: 'HKCU\\Software\\ODBC\\ODBC.INI\\', regPath: 'HKCU\\SOFTWARE\\Verdnatura\\vn-access', defaultModule: 'vn', defaultLocale: 'es', @@ -96,12 +94,12 @@ var App = { if (!this.module) this.module = Conf.defaultModule; - this.appDir = this.getEnv('ProgramFiles') +'\\'+ Conf.appName; - this.moduleDir = this.shell.SpecialFolders('AppData') +'\\'+ Conf.appName; - this.compressFile = this.getEnv('TEMP') +'\\'+ this.module +'.7z'; - this.mdbFile = this.moduleDir +'\\'+ this.module +'.mdb'; - this.lockFile = this.moduleDir +'\\'+ this.module +'.ldb'; - this.certFile = this.appDir +'\\cacert.pem'; + this.appDir = this.getEnv('ProgramFiles') + '\\' + Conf.appName; + this.moduleDir = this.shell.SpecialFolders('AppData') + '\\' + Conf.appName; + this.compressFile = this.getEnv('TEMP') + '\\' + this.module + '.7z'; + this.mdbFile = this.moduleDir + '\\' + this.module + '.mdb'; + this.lockFile = this.moduleDir + '\\' + this.module + '.ldb'; + this.certFile = this.appDir + '\\cacert.pem'; // Creates the necessary registry entries var myVersion = this.regRead(Conf.regPath, 'version'); @@ -119,39 +117,39 @@ var App = { // Creates the MySQL ODBC connection this.createODBC( - odbcPath, + Conf.odbcPath, Conf.dsName, Conf.odbcDriver ); // Datasources creation 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 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')) this.regWrite(Conf.regPath, 'currentDatasource', Conf.defaultDatasource); if (!this.regRead(Conf.regPath, 'notSignOut')) this.regWrite(Conf.regPath, 'notSignOut', 0); 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.$('password').value = this.regRead(Conf.dsPath, 'PWD'); + this.$('user').value = this.regRead(Conf.odbcPath + Conf.dsName, 'UID'); + this.$('password').value = password if (notSignOut && password) { this.$('password').value = password; @@ -282,7 +280,7 @@ var App = { if (!isOnLoad) { this.updateDatasource(myDatasource); this.updateODBC( - odbcPath, + Conf.odbcPath, Conf.dsName, myDatasource ); @@ -352,8 +350,8 @@ var App = { if (!password) throw new Error(_('Enter a password')); - this.regWrite(Conf.dsPath, 'UID', user); - this.regWrite(Conf.dsPath, 'PWD', password); + this.regWrite(Conf.odbcPath + Conf.dsName, 'UID', user); + this.regWrite(Conf.odbcPath + Conf.dsName, 'PWD', password); // Check the cretentials and return the last version number var version = this.fetchVersion(); @@ -392,7 +390,7 @@ var App = { var serverURL = Conf.datasources[datasource].SERVER; var sslMode = Conf.datasources[datasource].SSLMODE; - // ToDo: Can't login to dev-db + // FIXME: Can't login to dev-db if (datasource == 'dev') { serverURL = Conf.datasources.production.SERVER sslMode = Conf.datasources.production.SERVER @@ -612,7 +610,7 @@ var App = { var clearPassword = err.name == 'BadLogin'; if (!this.$('notSignOut').checked || clearPassword) - this.regWrite(Conf.dsPath, 'PWD', ''); + this.regWrite(Conf.odbcPath + Conf.dsName, 'PWD', ''); this.disableUi(false); this.showMessage(err.message, 'error');