mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
[fix] Reorder and catch proper response from API failed calls
This commit is contained in:
parent
87a7ea0d4a
commit
0ca78c8769
2 changed files with 25 additions and 30 deletions
|
@ -96,7 +96,22 @@
|
|||
callback(data);
|
||||
})
|
||||
.fail(function(xhr) {
|
||||
if (xhr.status == 200) {
|
||||
if (uri === '/postinstall') {
|
||||
if (installing) {
|
||||
interval = window.location.hostname === args.domain ? 20000 : 5000;
|
||||
checkInstall = setInterval(function () {
|
||||
c.checkInstall(function(isInstalled) {
|
||||
if (isInstalled || typeof isInstalled === 'undefined') {
|
||||
c.flash('success', y18n.t('installation_complete'));
|
||||
clearInterval(checkInstall);
|
||||
window.location.href = 'https://'+ window.location.hostname +'/yunohost/admin/';
|
||||
}
|
||||
});
|
||||
}, interval);
|
||||
} else {
|
||||
c.flash('fail', y18n.t('error_occured'));
|
||||
}
|
||||
} else if (xhr.status == 200) {
|
||||
// Fail with 200, WTF
|
||||
callback({});
|
||||
} else if (xhr.status == 401) {
|
||||
|
@ -106,34 +121,13 @@
|
|||
c.flash('fail', y18n.t('unauthorized'));
|
||||
c.redirect('#/login');
|
||||
}
|
||||
} else if (typeof xhr.responseJSON !== 'undefined') {
|
||||
c.flash('fail', xhr.responseJSON.error);
|
||||
} else if (typeof xhr.statusText !== 'undefined' && uri !== '/postinstall') {
|
||||
var errorMessage = xhr.status+' '+xhr.statusText;
|
||||
// If some more text is available, display it to user.
|
||||
if (typeof xhr.responseText !== 'undefined') {
|
||||
errorMessage += ' - ' + xhr.responseText;
|
||||
}
|
||||
c.flash('fail', y18n.t('api_not_responding', [errorMessage]));
|
||||
} else if (xhr.status == 502) {
|
||||
c.flash('fail', y18n.t('api_not_responding'));
|
||||
} else if (typeof xhr.responseText !== 'undefined') {
|
||||
c.flash('fail', xhr.responseText);
|
||||
} else {
|
||||
if (uri === '/postinstall') {
|
||||
if (installing) {
|
||||
interval = window.location.hostname === args.domain ? 20000 : 5000;
|
||||
checkInstall = setInterval(function () {
|
||||
c.checkInstall(function(isInstalled) {
|
||||
if (isInstalled || typeof isInstalled === 'undefined') {
|
||||
c.flash('success', y18n.t('installation_complete'));
|
||||
clearInterval(checkInstall);
|
||||
window.location.href = 'https://'+ window.location.hostname +'/yunohost/admin/';
|
||||
}
|
||||
});
|
||||
}, interval);
|
||||
} else {
|
||||
c.flash('fail', y18n.t('error_occured'));
|
||||
}
|
||||
} else {
|
||||
c.flash('fail', y18n.t('error_server'));
|
||||
}
|
||||
var errorMessage = xhr.status+' '+xhr.statusText;
|
||||
c.flash('fail', y18n.t('error_server_unexpected', [errorMessage]));
|
||||
}
|
||||
if (uri !== '/postinstall') {
|
||||
store.clear('slide');
|
||||
|
|
|
@ -55,13 +55,14 @@
|
|||
"unauthorized" : "Unauthorized",
|
||||
"error_occured" : "An error occured, try again",
|
||||
"error_server" : "Server error",
|
||||
"error_server_unexpected" : "Unexpected server error (%s)",
|
||||
"error_select_domain" : "You should indicate a domain",
|
||||
"error_modify_something" : "You should modify something",
|
||||
"non_compatible_api" : "Non-compatible API",
|
||||
"warning_first_user" : "You probably need to <a href='#/users/create' class='alert-link'>create a user</a> first.",
|
||||
"unknown_action" : "Unknown action %s",
|
||||
"unknown_argument" : "Unknown argument : %s",
|
||||
"api_not_responding" : "API is not responding (Error : %s)",
|
||||
"api_not_responding" : "API is not responding",
|
||||
"error_retrieve_feed" : "Could not retrieve feed : %s",
|
||||
|
||||
"confirm_delete" : "Are you sure you want to delete %s ?",
|
||||
|
|
Loading…
Reference in a new issue