#4076 Access Branches

This commit is contained in:
Carlos Andrés 2022-07-19 10:48:27 +02:00
parent 73a442bc1f
commit fc84414286
2 changed files with 64 additions and 5 deletions

View File

@ -48,7 +48,7 @@ var App = {
init: function() {
var width = 420;
var height = 420;
var height = 500;
window.resizeTo(width, height);
window.moveTo((screen.width - width) / 2, (screen.height - height) / 2);
@ -137,6 +137,25 @@ var App = {
this.onEnterClick();
} else
this.resetForm(true);
/* revisar
var sql = "SELECT name FROM vn.mdbBranch";
mysqlConn.query(sql, function(err, rows, fields) {
rows.forEach(function(row) {
this.$('branch').add(new Option(row.name));
});
});*/
/*
this.$('branch').add(new Option('master','master'));
this.$('branch').add(new Option('test','test'));
*/
/*
this.$('branch').value = this.getBranch();
if(this.$('branch').value != this.getBranch()){
this.$('branch').value = 'master';
}*/
},
resetForm: function(clearPassword) {
@ -223,21 +242,24 @@ var App = {
try {
var user = this.$('user').value;
var password = this.$('password').value;
var branch = this.$('branch').value;
if (!user || user === '')
throw new Error(_('Enter a user name'));
if (!password || password === '')
throw new Error(_('Enter a password'));
if (!password || password === '')
throw new Error(_('Select a branch'));
this.regWrite(Conf.dsPath, 'UID', user);
this.regWrite(Conf.dsPath, 'PWD', password);
var version = this.fetchVersion();
if (version !== null) {
this.disableUi(true, _('Updating'));
var remoteFile = version
? '.archive/'+ this.module +'/'+ version +'.7z'
? '.archive/'+ this.module +'/'+ branch +'/'+ version +'.7z'
: this.module +'.7z?'+ new Date().getTime();
remoteFile = Conf.remoteUrl +'/'+ remoteFile;
@ -301,8 +323,14 @@ var App = {
throw err;
}
var sql = "SELECT version FROM versiones WHERE programa = '"+ this.module +"'";
// revisar var sql = "SELECT version FROM versiones WHERE programa = '"+ this.module +"'";
var sql = "SELECT version " +
" FROM vn.mdbVersion " +
" WHERE app = '"+ this.module +"' " +
" AND branchFk = '" + this.$('branch').value + "'";
// var sql = "SELECT version FROM versiones WHERE programa = '"+ this.module +"'";
var rs = mysqlConn.execute(sql);
var version = rs.EOF ? false : parseInt(rs.fields(0).value);
@ -528,6 +556,29 @@ var App = {
try {
this.shell.regDelete(path);
} catch (e) {}
},
/**
* Gets information about the branch config in access
*
* @return {string} Branch name, master if cannot
*/
getBranch: function() {
var branch = 'master';
try {
var mdbConn = new ActiveXObject('ADODB.Connection');
mdbConn.open(this.getOdbcString({
'Provider': 'Microsoft.Jet.OLEDB.4.0',
'Data Source': this.mdbFile
}));
var rs = new ActiveXObject('ADODB.Recordset');
rs.Open('SELECT branch FROM tblVariables', mdbConn);
branch = String(rs('branch'));
rs.close();
mdbConn.close();
} catch (e) {}
return branch;
}
};

View File

@ -32,6 +32,13 @@
alt="Verdnatura"/>
<div id="fields">
<div id="inputs">
<div>
<label for="branch">Branch</label>
<select id="branch" >
<option>master</option>
<option>test</option>
</select>
</div>
<div>
<label for="user">Usuario</label>
<input id="user" type="text"/>
@ -40,6 +47,7 @@
<label for="password">Contraseña</label>
<input id="password" type="password"/>
</div>
</div>
<div id="checkbox">
<input id="remember" type="checkbox"/>