diff --git a/src/js/yunohost/controllers/tools.js b/src/js/yunohost/controllers/tools.js
index 17d26b9d..25a08500 100644
--- a/src/js/yunohost/controllers/tools.js
+++ b/src/js/yunohost/controllers/tools.js
@@ -172,8 +172,34 @@
y18n.t('confirm_reboot_action_' + action),
function(){
c.api('/'+action+'?force', function(data) {
+ // This code is not executed due to 502 response (reboot or shutdown)
c.redirect('#/logout');
- }, 'PUT');
+ }, 'PUT', {}, false, function (xhr) {
+ c.flash('success', y18n.t('tools_' + action + '_done'))
+ // Disconnect from the webadmin
+ store.clear('url');
+ store.clear('connected');
+ store.set('path', '#/');
+
+ // Rename the page to allow refresh without ask for rebooting
+ window.location.href = window.location.href.split('#')[0] + '#/';
+ // Display reboot or shutdown info
+ // We can't use template because now the webserver is off
+ if (action == 'reboot') {
+ $('#main').replaceWith('
' + y18n.t('tools_rebooting') + '
');
+ }
+ else {
+ $('#main').replaceWith(' ' + y18n.t('tools_shuttingdown') + '
');
+ }
+
+ // Remove loader if any
+ $('div.loader').remove();
+
+ // Force scrollTop on page load
+ $('html, body').scrollTop(0);
+ store.clear('slide');
+ });
+
},
function(){
store.clear('slide');
@@ -187,6 +213,11 @@
c.redirect('#/tools/reboot');
}
});
+ app.get('#/tools/reboot/:action/done', function (c) {
+ var action = c.params['action'].toLowerCase();
+ if (action == 'reboot' || action == 'shutdown') {
+ }
+ });
// Diagnosis
app.get('#/tools/diagnosis(/:private)?', function (c) {
diff --git a/src/js/yunohost/helpers.js b/src/js/yunohost/helpers.js
index 98fe5236..4422abf5 100644
--- a/src/js/yunohost/helpers.js
+++ b/src/js/yunohost/helpers.js
@@ -62,10 +62,10 @@
},
// API call
- api: function(uri, callback, method, data, websocket) {
+ api: function(uri, callback, method, data, websocket, callbackOnFailure) {
c = this;
- call = function(uri, callback, method, data) {
+ call = function(uri, callback, method, data, callbackOnFailure) {
method = typeof method !== 'undefined' ? method : 'GET';
data = typeof data !== 'undefined' ? data : {};
if (window.navigator && window.navigator.language && (typeof data.locale === 'undefined')) {
@@ -84,6 +84,71 @@
if ($('div.loader').length === 0) {
$('#main').append('