refs #4974 Added logout button and auto-login
This commit is contained in:
parent
1a6f22e539
commit
12caa4014a
Binary file not shown.
After Width: | Height: | Size: 292 B |
104
src/main.js
104
src/main.js
|
@ -41,7 +41,9 @@ var Locale = {
|
||||||
"MDB file not found":
|
"MDB file not found":
|
||||||
"No se encontró el fichero MDB",
|
"No se encontró el fichero MDB",
|
||||||
"Cache files have been deleted":
|
"Cache files have been deleted":
|
||||||
"Se han borrado todos los ficheros almacenados en la caché"
|
"Se han borrado todos los ficheros almacenados en la caché",
|
||||||
|
"Session has been closed":
|
||||||
|
"Se han cerrado la sesión"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,7 +54,7 @@ var App = {
|
||||||
init: function() {
|
init: function() {
|
||||||
// Specify the size of window
|
// Specify the size of window
|
||||||
var width = 420;
|
var width = 420;
|
||||||
var height = 570;
|
var height = 590;
|
||||||
window.resizeTo(width, height);
|
window.resizeTo(width, height);
|
||||||
window.moveTo((screen.width - width) / 2, (screen.height - height) / 2);
|
window.moveTo((screen.width - width) / 2, (screen.height - height) / 2);
|
||||||
},
|
},
|
||||||
|
@ -113,8 +115,16 @@ var App = {
|
||||||
this.regDelete(Conf.regPath +'\\configured');
|
this.regDelete(Conf.regPath +'\\configured');
|
||||||
this.regDelete(Conf.regPath + '\\remember');
|
this.regDelete(Conf.regPath + '\\remember');
|
||||||
}
|
}
|
||||||
|
|
||||||
var notSignOut = this.regRead(Conf.regPath, 'notSignOut');
|
var notSignOut = this.regRead(Conf.regPath, 'notSignOut');
|
||||||
|
this.$('notSignOut').checked = notSignOut;
|
||||||
|
|
||||||
|
if (!notSignOut)
|
||||||
|
this.resetForm(true);
|
||||||
|
|
||||||
|
var autoLogin = this.regRead(Conf.regPath, 'autoLogin');
|
||||||
|
this.$('autoLogin').checked = autoLogin;
|
||||||
|
|
||||||
|
this.refreshLogout();
|
||||||
|
|
||||||
// Branch options
|
// Branch options
|
||||||
this.request('GET', 'mdbBranches', null, function(err, res) {
|
this.request('GET', 'mdbBranches', null, function(err, res) {
|
||||||
|
@ -154,13 +164,13 @@ var App = {
|
||||||
}
|
}
|
||||||
this.$('datasource').value = this.dsName;
|
this.$('datasource').value = this.dsName;
|
||||||
|
|
||||||
if (notSignOut && password) {
|
if (autoLogin) {
|
||||||
this.$('notSignOut').checked = true;
|
this.onChangeDatasource();
|
||||||
this.onChangeDatasource(true);
|
|
||||||
this.onEnterClick();
|
this.onEnterClick();
|
||||||
} else {
|
} else {
|
||||||
this.resetForm(true);
|
if (!notSignOut)
|
||||||
this.onChangeDatasource(true);
|
this.resetForm(true);
|
||||||
|
this.onChangeDatasource();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isDs: function(dsName) {
|
isDs: function(dsName) {
|
||||||
|
@ -172,11 +182,13 @@ var App = {
|
||||||
: dsName;
|
: dsName;
|
||||||
},
|
},
|
||||||
resetForm: function(clearPassword) {
|
resetForm: function(clearPassword) {
|
||||||
if (clearPassword)
|
if (clearPassword) {
|
||||||
this.$('password').value = '';
|
this.$('password').value = '';
|
||||||
|
this.regWrite(this.getOdbcPath(), 'PWD', '');
|
||||||
|
}
|
||||||
|
|
||||||
this.$('user').focus();
|
this.$('password').focus();
|
||||||
this.$('user').select();
|
this.$('password').select();
|
||||||
},
|
},
|
||||||
createODBC: function(path, dsName, driverName, description) {
|
createODBC: function(path, dsName, driverName, description) {
|
||||||
var driverPath = this.getEnv('ProgramFiles') + Conf.driverPath;
|
var driverPath = this.getEnv('ProgramFiles') + Conf.driverPath;
|
||||||
|
@ -195,21 +207,6 @@ var App = {
|
||||||
this.regWrite(path + 'ODBC Data Sources', dsName, driverName);
|
this.regWrite(path + 'ODBC Data Sources', dsName, driverName);
|
||||||
this.regWrites(path + dsName, params);
|
this.regWrites(path + dsName, params);
|
||||||
},
|
},
|
||||||
updateODBC: function() {
|
|
||||||
var odbcPath = this.getOdbcPath();
|
|
||||||
var myUID = this.regRead(odbcPath, 'remoteUser');
|
|
||||||
var myPWD = this.regRead(odbcPath, 'remotePass');
|
|
||||||
|
|
||||||
var params = [];
|
|
||||||
if (myUID && myPWD) {
|
|
||||||
params['UID'] = myUID;
|
|
||||||
params['PWD'] = myPWD;
|
|
||||||
} else {
|
|
||||||
params['UID'] = this.regRead(odbcPath, 'UID');
|
|
||||||
params['PWD'] = this.regRead(odbcPath, 'PWD');
|
|
||||||
}
|
|
||||||
this.regWrites(odbcPath, params);
|
|
||||||
},
|
|
||||||
disableUi: function(disabled, loadMessage) {
|
disableUi: function(disabled, loadMessage) {
|
||||||
if (disabled)
|
if (disabled)
|
||||||
this.hideMessage();
|
this.hideMessage();
|
||||||
|
@ -221,6 +218,7 @@ var App = {
|
||||||
this.$('user').disabled = disabled;
|
this.$('user').disabled = disabled;
|
||||||
this.$('password').disabled = disabled;
|
this.$('password').disabled = disabled;
|
||||||
this.$('notSignOut').disabled = disabled;
|
this.$('notSignOut').disabled = disabled;
|
||||||
|
this.$('autoLogin').disabled = disabled;
|
||||||
this.$('enter').disabled = disabled;
|
this.$('enter').disabled = disabled;
|
||||||
|
|
||||||
var display = disabled ? 'block' : 'none';
|
var display = disabled ? 'block' : 'none';
|
||||||
|
@ -248,6 +246,14 @@ var App = {
|
||||||
this.$('datasourceLogo').className = '';
|
this.$('datasourceLogo').className = '';
|
||||||
|
|
||||||
},
|
},
|
||||||
|
refreshLogout: function() {
|
||||||
|
var style = this.$('logout').style;
|
||||||
|
var password = this.regRead(this.getOdbcPath(), 'PWD');
|
||||||
|
if (password)
|
||||||
|
style.display = 'inline';
|
||||||
|
else
|
||||||
|
style.display = 'none';
|
||||||
|
},
|
||||||
onChangeBranch: function() {
|
onChangeBranch: function() {
|
||||||
if (this.$('branch').value == 'master'||'test'||'dev') {
|
if (this.$('branch').value == 'master'||'test'||'dev') {
|
||||||
this.$('branchButton').className = this.$('branch').value;
|
this.$('branchButton').className = this.$('branch').value;
|
||||||
|
@ -263,7 +269,7 @@ var App = {
|
||||||
*
|
*
|
||||||
* @param {Boolean} hasUpdate
|
* @param {Boolean} hasUpdate
|
||||||
*/
|
*/
|
||||||
onChangeDatasource: function(hasUpdate) {
|
onChangeDatasource: function() {
|
||||||
this.dsName = this.$('datasource').value;
|
this.dsName = this.$('datasource').value;
|
||||||
var myDatasource = this.getDatasource(this.dsName);
|
var myDatasource = this.getDatasource(this.dsName);
|
||||||
|
|
||||||
|
@ -277,25 +283,11 @@ var App = {
|
||||||
this.$('datasourceButton').className = null;
|
this.$('datasourceButton').className = null;
|
||||||
this.$('datasource').className = null;
|
this.$('datasource').className = null;
|
||||||
};
|
};
|
||||||
if (!hasUpdate) {
|
|
||||||
this.updateODBC();
|
|
||||||
};
|
|
||||||
var odbcPath = this.getOdbcPath();
|
var odbcPath = this.getOdbcPath();
|
||||||
var myUID = this.regRead(odbcPath, 'remoteUser');
|
this.$('user').value = this.regRead(odbcPath, 'UID')
|
||||||
var myPWD = this.regRead(odbcPath, 'remotePass');
|
this.$('password').value = this.regRead(odbcPath, 'PWD')
|
||||||
var notSignOut = this.regRead(Conf.regPath, 'notSignOut');
|
|
||||||
if (myUID && myPWD && !notSignOut) {
|
this.refreshLogout();
|
||||||
this.$('user').value = myUID;
|
|
||||||
this.$('password').value = myPWD;
|
|
||||||
} else {
|
|
||||||
var user = this.regRead(odbcPath, 'UID')
|
|
||||||
if (user)
|
|
||||||
this.$('user').value = user
|
|
||||||
if (!notSignOut)
|
|
||||||
this.resetForm(true)
|
|
||||||
else
|
|
||||||
this.$('password').value = this.regRead(odbcPath, 'PWD')
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$('user').focus();
|
this.$('user').focus();
|
||||||
},
|
},
|
||||||
|
@ -383,6 +375,11 @@ var App = {
|
||||||
this.catchError(err);
|
this.catchError(err);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
logout: function() {
|
||||||
|
this.resetForm(true);
|
||||||
|
this.refreshLogout();
|
||||||
|
this.showMessage(_('Session has been closed'), 'notice');
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Gets information about the version to download.
|
* Gets information about the version to download.
|
||||||
* cmdle
|
* cmdle
|
||||||
|
@ -532,9 +529,17 @@ var App = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openMdb: function() {
|
openMdb: function() {
|
||||||
var notSignOut = !!this.$('notSignOut').checked;
|
var autoLogin = this.$('autoLogin').checked;
|
||||||
|
this.regWrite(Conf.regPath, 'autoLogin', autoLogin);
|
||||||
|
|
||||||
|
if (autoLogin)
|
||||||
|
var notSignOut = true;
|
||||||
|
else
|
||||||
|
var notSignOut = this.$('notSignOut').checked;
|
||||||
this.regWrite(Conf.regPath, 'notSignOut', notSignOut);
|
this.regWrite(Conf.regPath, 'notSignOut', notSignOut);
|
||||||
|
|
||||||
|
this.$('notSignOut').checked = true;
|
||||||
|
|
||||||
var programFiles = this.getEnv('ProgramFiles');
|
var programFiles = this.getEnv('ProgramFiles');
|
||||||
var accessBin = programFiles +'\\Microsoft Office\\OFFICE11\\MSACCESS.EXE';
|
var accessBin = programFiles +'\\Microsoft Office\\OFFICE11\\MSACCESS.EXE';
|
||||||
|
|
||||||
|
@ -548,11 +553,8 @@ var App = {
|
||||||
catchError: function(err) {
|
catchError: function(err) {
|
||||||
var clearPassword = err.name == 'BadLogin';
|
var clearPassword = err.name == 'BadLogin';
|
||||||
|
|
||||||
if (this.$('notSignOut').checked) {
|
this.regWrite(Conf.regPath, 'autoLogin', 0)
|
||||||
this.regWrite(this.getOdbcPath(), 'PWD', '');
|
this.$('autoLogin').checked = false
|
||||||
this.regWrite(Conf.regPath, 'notSignOut', 0)
|
|
||||||
this.$('notSignOut').checked = false
|
|
||||||
}
|
|
||||||
|
|
||||||
this.disableUi(false);
|
this.disableUi(false);
|
||||||
this.showMessage(err.message, 'error');
|
this.showMessage(err.message, 'error');
|
||||||
|
|
|
@ -61,11 +61,22 @@ input[type='text']:focus,
|
||||||
input[type='password']:focus {
|
input[type='password']:focus {
|
||||||
border-bottom: 1px solid black;
|
border-bottom: 1px solid black;
|
||||||
}
|
}
|
||||||
#notSignOutSection {
|
#optionsSection {
|
||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
font-size: .8em;
|
font-size: .8em;
|
||||||
margin-bottom: 2.5em;
|
margin-bottom: 2.5em;
|
||||||
}
|
}
|
||||||
|
#logout {
|
||||||
|
float: right;
|
||||||
|
margin-top: -4.3em;
|
||||||
|
margin-left: .4em;
|
||||||
|
padding: .4em;
|
||||||
|
}
|
||||||
|
#logout:hover {
|
||||||
|
border-radius: 25px;
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
#submit {
|
#submit {
|
||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" http-equiv="X-UA-Compatible" content="IE=9"/>
|
<meta charset="UTF-8" http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||||
<title>ㅤ</title>
|
<title>v5</title>
|
||||||
<link rel="stylesheet" href="style.css"/>
|
<link rel="stylesheet" href="style.css"/>
|
||||||
<script type="text/javascript" src="main.js"></script>
|
<script type="text/javascript" src="main.js"></script>
|
||||||
<hta:application
|
<hta:application
|
||||||
|
@ -41,10 +41,14 @@
|
||||||
<input id="password" type="password"/>
|
<input id="password" type="password"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="notSignOutSection">
|
<div id="optionsSection">
|
||||||
<input id="notSignOut" type="checkbox"/>
|
<input id="notSignOut" type="checkbox">
|
||||||
<label for="notSignOut">No cerrar sesión</label>
|
<label for="notSignOut">No cerrar sesión</label>
|
||||||
|
<br/>
|
||||||
|
<input id="autoLogin" type="checkbox"/>
|
||||||
|
<label for="autoLogin">Auto-login</label>
|
||||||
</div>
|
</div>
|
||||||
|
<img id="logout" src="logout.png" onclick="App.logout()"/>
|
||||||
</div>
|
</div>
|
||||||
<div id="submit">
|
<div id="submit">
|
||||||
<button id="enter" onclick="App.onEnterClick()">Iniciar sesión</button>
|
<button id="enter" onclick="App.onEnterClick()">Iniciar sesión</button>
|
||||||
|
@ -72,7 +76,7 @@
|
||||||
onclick="App.openOptions()"
|
onclick="App.openOptions()"
|
||||||
alt="Change datasource"/>
|
alt="Change datasource"/>
|
||||||
<div id="datasourceSelector">
|
<div id="datasourceSelector">
|
||||||
<select id="datasource" onchange="App.onChangeDatasource(false)">
|
<select id="datasource" onchange="App.onChangeDatasource()">
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue