mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Simplify /login route code...
This commit is contained in:
parent
72b4e66a7f
commit
e16e822a89
1 changed files with 22 additions and 26 deletions
|
@ -27,37 +27,33 @@
|
||||||
|
|
||||||
c.showLoader();
|
c.showLoader();
|
||||||
|
|
||||||
|
// We gonna retry 3 times to check if yunohost is installed
|
||||||
|
if (app.isInstalledTry === undefined) {
|
||||||
|
app.isInstalledTry = 3;
|
||||||
|
}
|
||||||
|
|
||||||
c.checkInstall(function(isInstalled) {
|
c.checkInstall(function(isInstalled) {
|
||||||
|
|
||||||
if (isInstalled) {
|
if (isInstalled) {
|
||||||
c.hideLoader();
|
|
||||||
// Pass domain to hide form field
|
|
||||||
c.view('login', { 'domain': window.location.hostname });
|
c.view('login', { 'domain': window.location.hostname });
|
||||||
} else if (typeof isInstalled === 'undefined') {
|
return;
|
||||||
if (app.isInstalledTry > 0) {
|
}
|
||||||
app.isInstalledTry--;
|
|
||||||
setTimeout(function() {
|
|
||||||
c.redirect('#/');
|
|
||||||
}, 5000);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Reset count
|
|
||||||
app.isInstalledTry = 3;
|
|
||||||
|
|
||||||
// API is not responding after 3 try
|
if (typeof isInstalled !== 'undefined') {
|
||||||
$( document ).ajaxError(function( event, request, settings ) {
|
|
||||||
// Display error if status != 200.
|
|
||||||
// .ajaxError fire even with status code 200 because json is sometimes not valid.
|
|
||||||
if (request.status !== 200) c.flash('fail', y18n.t('api_not_responding', [request.status+' '+request.statusText] ));
|
|
||||||
|
|
||||||
// Unbind directly
|
|
||||||
$(document).off('ajaxError');
|
|
||||||
});
|
|
||||||
|
|
||||||
c.hideLoader();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
c.hideLoader();
|
|
||||||
c.redirect('#/postinstall');
|
c.redirect('#/postinstall');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the retry counter is still up, retry this function 5 sec
|
||||||
|
// later
|
||||||
|
if (app.isInstalledTry > 0) {
|
||||||
|
app.isInstalledTry--;
|
||||||
|
setTimeout(function() {
|
||||||
|
c.redirect('#/');
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
c.flash('fail', y18n.t('api_not_responding'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue