mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Moaaar buttons (reboot/poweroff)
This commit is contained in:
parent
52b4623222
commit
266e349d1f
2 changed files with 38 additions and 45 deletions
|
@ -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('<div id="main"><div class="alert alert-warning"><i class="fa-refresh"></i> ' + y18n.t('tools_rebooting') + '</div></div>');
|
||||
}
|
||||
else {
|
||||
$('#main').replaceWith('<div id="main"><div class="alert alert-warning"><i class="fa-power-off"></i> ' + y18n.t('tools_shuttingdown') + '</div></div>');
|
||||
}
|
||||
// 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('<div id="main"><div class="alert alert-warning"><i class="fa-refresh"></i> ' + y18n.t('tools_rebooting') + '</div></div>');
|
||||
}
|
||||
else {
|
||||
$('#main').replaceWith('<div id="main"><div class="alert alert-warning"><i class="fa-power-off"></i> ' + y18n.t('tools_shuttingdown') + '</div></div>');
|
||||
}
|
||||
|
||||
// Remove loader if any
|
||||
$('div.loader').remove();
|
||||
// Remove loader if any
|
||||
$('div.loader').remove();
|
||||
|
||||
// Force scrollTop on page load
|
||||
$('html, body').scrollTop(0);
|
||||
// Force scrollTop on page load
|
||||
$('html, body').scrollTop(0);
|
||||
}, false);
|
||||
}
|
||||
);
|
||||
}
|
||||
else {
|
||||
c.flash('fail', y18n.t('unknown_action', [action]));
|
||||
c.redirect_to('#/tools/reboot', {slide: false});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Diagnosis
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
</div>
|
||||
<div class="panel-body">
|
||||
<p>
|
||||
<a role="button" href="#/tools/reboot/reboot" class="btn btn-danger">
|
||||
<button class="btn btn-danger" data-action="reboot">
|
||||
<i class="fa-refresh"></i> {{t 'tools_reboot_btn'}}
|
||||
</a>
|
||||
</button>
|
||||
</p>
|
||||
<p>
|
||||
<a role="button" href="#/tools/reboot/shutdown" class="btn btn-danger">
|
||||
<button class="btn btn-danger" data-action="shutdown">
|
||||
<i class="fa-power-off"></i> {{t 'tools_shutdown_btn'}}
|
||||
</a>
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue