diff --git a/src/js/yunohost/controllers/tools.js b/src/js/yunohost/controllers/tools.js index 03f6f1a7..3f2e08c5 100644 --- a/src/js/yunohost/controllers/tools.js +++ b/src/js/yunohost/controllers/tools.js @@ -208,52 +208,45 @@ // Reboot or shutdown button app.get('#/tools/reboot', function (c) { - c.view('tools/tools_reboot'); - }); + c.view('tools/tools_reboot', {}, function() { + // Configure reboot/shutdown buttons behavior + $("button[data-action]").on("click", function() { + var action = $(this).data("action"); - // Reboot or shutdown actions - app.get('#/tools/reboot/:action', function (c) { - var action = c.params['action'].toLowerCase(); - if (action == 'reboot' || action == 'shutdown') { - c.confirm( - y18n.t('tools_' + action), - // confirm_reboot_action_reboot or confirm_reboot_action_shutdown - y18n.t('confirm_reboot_action_' + action), - function(){ - c.api('PUT', '/'+action+'?force', {}, function(data) { - // This code is not executed due to 502 response (reboot or shutdown) - c.redirect_to('#/logout'); - }, function (xhr) { - c.flash('success', y18n.t('tools_' + action + '_done')) - // Disconnect from the webadmin - store.clear('url'); - store.clear('connected'); - store.set('path', '#/'); + c.confirm( + y18n.t('tools_' + action), + y18n.t('confirm_reboot_action_' + action), + function(){ + c.api('PUT', '/'+action+'?force', {}, function(data) { + // This code is not executed due to 502 response (reboot or shutdown) + c.redirect_to('#/logout'); + }, 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('