mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
[enh] Prevent infinite pacman when API is not responding.
This commit is contained in:
parent
299ee0179c
commit
ceea61ccb4
4 changed files with 30 additions and 4 deletions
|
@ -29,7 +29,7 @@
|
||||||
<div id="slideBack" style="display: none;"></div>
|
<div id="slideBack" style="display: none;"></div>
|
||||||
|
|
||||||
<div id="main" role="main">
|
<div id="main" role="main">
|
||||||
<a class="slide" href="#/login">
|
<a class="slide" href="#/">
|
||||||
<span class="ajax-loader" data-y19n="loading">loading…</span>
|
<span class="ajax-loader" data-y19n="loading">loading…</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
30
js/app.js
30
js/app.js
|
@ -48,6 +48,7 @@ app = Sammy('#main', function (sam) {
|
||||||
// Initialize storage
|
// Initialize storage
|
||||||
var store = new Sammy.Store({name: 'storage', type: storageType});
|
var store = new Sammy.Store({name: 'storage', type: storageType});
|
||||||
var loaded = false;
|
var loaded = false;
|
||||||
|
var isInstalledTry = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helpers
|
* Helpers
|
||||||
|
@ -396,15 +397,38 @@ app = Sammy('#main', function (sam) {
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
c.checkInstall(function(isInstalled) {
|
c.checkInstall(function(isInstalled) {
|
||||||
if (isInstalled) {
|
if (isInstalled) {
|
||||||
domain = window.location.hostname;
|
domain = window.location.hostname;
|
||||||
$('div.loader').remove();
|
$('div.loader').remove();
|
||||||
c.view('login', { 'domain': domain });
|
c.view('login', { 'domain': domain });
|
||||||
} else if (typeof isInstalled === 'undefined') {
|
} else if (typeof isInstalled === 'undefined') {
|
||||||
setTimeout(function() {
|
if (isInstalledTry > 0) {
|
||||||
c.redirect('#/');
|
isInstalledTry--;
|
||||||
}, 5000);
|
loaded = false; // Show pacman
|
||||||
|
setTimeout(function() {
|
||||||
|
c.redirect('#/');
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Reset count
|
||||||
|
isInstalledTry = 3;
|
||||||
|
|
||||||
|
// API is not responding after 3 try
|
||||||
|
$( 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');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Remove pacman
|
||||||
|
loaded = true;
|
||||||
|
$('div.loader').remove();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$('div.loader').remove();
|
$('div.loader').remove();
|
||||||
c.redirect('#/postinstall');
|
c.redirect('#/postinstall');
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
"warning_first_user" : "You probably need to <a href='#/users/create' class='alert-link'>create a user</a> first.",
|
"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_action" : "Unknown action %s",
|
||||||
"unknown_argument" : "Unknown argument : %s",
|
"unknown_argument" : "Unknown argument : %s",
|
||||||
|
"api_not_responding" : "API is not responding (Error : %s)",
|
||||||
|
|
||||||
"confirm_delete" : "Are you sure you want to delete %s ?",
|
"confirm_delete" : "Are you sure you want to delete %s ?",
|
||||||
"confirm_change_maindomain" : "Are you sure you want to change the main domain ?",
|
"confirm_change_maindomain" : "Are you sure you want to change the main domain ?",
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
"warning_first_user" : "Vous devez probablement d'abord <a href='#/users/create' class='alert-link'>créer un utilisateur</a>.",
|
"warning_first_user" : "Vous devez probablement d'abord <a href='#/users/create' class='alert-link'>créer un utilisateur</a>.",
|
||||||
"unknown_action" : "Action %s inconnue",
|
"unknown_action" : "Action %s inconnue",
|
||||||
"unknown_argument" : "Argument inconnu : %s",
|
"unknown_argument" : "Argument inconnu : %s",
|
||||||
|
"api_not_responding" : "l'API ne répond pas (Erreur : %s)",
|
||||||
|
|
||||||
"confirm_delete" : "Êtes-vous sur de vouloir supprimer %s ?",
|
"confirm_delete" : "Êtes-vous sur de vouloir supprimer %s ?",
|
||||||
"confirm_change_maindomain" : "Êtes-vous sur de vouloir changer le domaine principal ?",
|
"confirm_change_maindomain" : "Êtes-vous sur de vouloir changer le domaine principal ?",
|
||||||
|
|
Loading…
Add table
Reference in a new issue